Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------------------------------------------------------------------------
- // Pixel Shader
- //-----------------------------------------------------------------------------------------
- float4 ColorPS(
- float4 position : TEXCOORD0) : SV_Target
- {
- // Hardcode a generic directional light
- float3 L = normalize(float3(0.5, 0.25, -1.0));
- // Compute the surface normal
- float3 dx = ddx(position);
- float3 dy = ddy(position);
- float3 dn = normalize(cross(dx, dy));
- // Calculate a half-lambert diffuse factor
- float NdotL = saturate(-dot(dn, L) * 0.5 + 0.5);
- // Basic colouring
- float4 color = float4(1, 1, 1, 1);
- float3 diffuse = color.xyz * NdotL;
- // Return the result
- return float4(diffuse, 1.0f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement