61 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
		
		
			
		
	
	
			61 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
|  | #include "Macros.fxh" | ||
|  | 
 | ||
|  | DECLARE_TEXTURE(gPosition, 0); | ||
|  | DECLARE_TEXTURE(gAlbedo, 1); | ||
|  | DECLARE_TEXTURE(gNormal, 2); | ||
|  | 
 | ||
|  | BEGIN_CONSTANTS | ||
|  | 
 | ||
|  | float3 EyePosition                  _ps(c0)     _cb(c0); | ||
|  | 
 | ||
|  | float3 DirectionalLightDirection    _ps(c1)     _cb(c1); | ||
|  | float3 AmbientLightColor            _ps(c2)     _cb(c2); | ||
|  | 
 | ||
|  | END_CONSTANTS | ||
|  | 
 | ||
|  | struct VertexInput | ||
|  | { | ||
|  |     float4 Position : POSITION; | ||
|  |     float2 TexCoord : TEXCOORD; | ||
|  | }; | ||
|  | 
 | ||
|  | struct PixelInput | ||
|  | { | ||
|  |     float4 Position : SV_POSITION; | ||
|  |     float2 TexCoord : TEXCOORD0; | ||
|  | }; | ||
|  | 
 | ||
|  | PixelInput main_vs(VertexInput input) | ||
|  | { | ||
|  |     PixelInput output; | ||
|  | 
 | ||
|  |     output.Position = input.Position; | ||
|  |     output.TexCoord = input.TexCoord; | ||
|  | 
 | ||
|  |     return output; | ||
|  | } | ||
|  | 
 | ||
|  | float4 main_ps(PixelInput input) : SV_TARGET0 | ||
|  | { | ||
|  |     float3 worldPosition = SAMPLE_TEXTURE(gPosition, input.TexCoord).rgb; | ||
|  |     float3 normal = SAMPLE_TEXTURE(gNormal, input.TexCoord).xyz; | ||
|  |     float3 albedo = SAMPLE_TEXTURE(gAlbedo, input.TexCoord).rgb; | ||
|  | 
 | ||
|  |     float3 V = normalize(EyePosition - worldPosition); | ||
|  |     float3 L = normalize(DirectionalLightDirection); | ||
|  |     float3 N = normalize(normal); | ||
|  |     float NdotL = dot(N, L); | ||
|  | 
 | ||
|  |     float lightIntensity = (NdotL > 0.0) ? 1.0 : 0.0; | ||
|  |     return float4(albedo * (lightIntensity, 1.0); | ||
|  | } | ||
|  | 
 | ||
|  | Technique Deferred_Toon | ||
|  | { | ||
|  |     Pass | ||
|  |     { | ||
|  |         VertexShader = compile vs_3_0 main_vs(); | ||
|  |         PixelShader = compile ps_3_0 main_ps(); | ||
|  |     } | ||
|  | } |