Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LIGHTING
- texture texNormal;
- texture texPosition;
- texture texColor;
- sampler gPosition = sampler_state
- {
- Texture = (texPosition);
- AddressU = CLAMP;
- AddressV = CLAMP;
- MagFilter = LINEAR;
- MinFilter = LINEAR;
- Mipfilter = LINEAR;
- };
- sampler gNormal = sampler_state
- {
- Texture = (texNormal);
- AddressU = CLAMP;
- AddressV = CLAMP;
- MagFilter = LINEAR;
- MinFilter = LINEAR;
- Mipfilter = LINEAR;
- };
- sampler gColor = sampler_state
- {
- Texture = (texColor);
- AddressU = CLAMP;
- AddressV = CLAMP;
- MagFilter = LINEAR;
- MinFilter = LINEAR;
- Mipfilter = LINEAR;
- };
- const int Lights = 32;
- float3 lightPosition;
- float3 lightColor;
- float3 viewPosition;
- struct LightInput
- {
- float4 Position : POSITION;
- float2 UV : TEXCOORD;
- };
- struct LightOutput
- {
- float4 Position : POSITION;
- float2 UV : TEXCOORD;
- };
- LightOutput LightVS(LightInput input)
- {
- LightOutput output = (LightOutput)0;
- output.Position = input.Position;
- output.UV = input.UV;
- return output;
- }
- float4 LightPS(LightOutput input) : COLOR
- {
- float3 fragPosition = tex2D(gPosition, input.UV).rgb;
- float3 normal = tex2D(gNormal, input.UV).rgb;
- float3 color = tex2D(gColor, input.UV).rgb;
- float3 lighting = color*0.1;
- float3 viewDirection = normalize(viewPosition - fragPosition);
- float3 lightDirection = normalize(lightPosition - fragPosition);
- float3 diffuse = max(dot(normal, lightDirection), 0) * color * lightColor;
- lighting += diffuse;
- return float4(normal, 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement