source: GTP/trunk/App/Demos/Illum/DepthOfField/shaders/illum.hlsl @ 765

Revision 765, 1.2 KB checked in by szirmay, 19 years ago (diff)

Added a folder remotely

Line 
1// material constants
2const float3 ambientMaterial= float3(0.5, 0.5, 0.5);
3const float3 diffuseMaterial = float3(1.0, 1.0, 1.0);   
4const float3 specularMaterial = float3(0.3, 0.3, 0.3);
5
6//------------------------------------------
7// a fényerõt számító fv.
8// l = light vector, r = reciprok négyzet radius: 1.0/(r*r)
9//------------------------------------------
10float SQR(float x) { return x*x; }
11float Attenuation(float3 Light)
12{
13        return 10.0 / dot(Light, Light);
14}
15
16//-----------------------------------------------------------------------------
17// Illumination function used in shading: all input vectors are normalized
18//-----------------------------------------------------------------------------
19float4 Illumination(float3 Light, float3 Normal, float3 View, float2 TexCoord, float Attenuation)
20{
21        // Blinn lighting
22        float3 Half = normalize(Light + View);
23        float Diffuse = dot(Normal, Light);
24        float Specular = dot(Normal, Half);
25        float4 Lighting = lit(Diffuse, Specular, 16);
26        float4 Color= tex2D(ColorMapSampler, TexCoord);
27
28        return float4(
29                Lighting.x * ambientMaterial * Color +
30                (Lighting.y * diffuseMaterial * Color +
31                Lighting.z * specularMaterial) * Attenuation, 1);
32}
Note: See TracBrowser for help on using the repository browser.