Advertisement
Guest User

Untitled

a guest
Nov 18th, 2012
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. float4 ps_lighting(VS_OUTPUT IN) : SV_Target
  2. {
  3.     if (renderingSkel || renderingRBody)
  4.     {
  5.         return float4(1, 1, 1, 1);
  6.     }
  7.     else
  8.     {
  9.         //shadow mapping stuff
  10.         IN.lpos.xyz /= IN.lpos.w;
  11.        
  12.         float4 ambient = ambientBright * materialAmbient;
  13.  
  14.         if( IN.lpos.x < -1.0f || IN.lpos.x > 1.0f || IN.lpos.y < -1.0f || IN.lpos.y > 1.0f || IN.lpos.z < 0.0f  || IN.lpos.z > 1.0f )
  15.             return ambient;
  16.  
  17.         IN.lpos.x = IN.lpos.x/2 + 0.5;
  18.         IN.lpos.y = IN.lpos.y/-2 + 0.5;
  19.  
  20.         float shadowMapDepth = shadowMap.Sample(ShadowSampler, IN.lpos.xy).r;
  21.  
  22.         if (shadowMapDepth < IN.lpos.z) return ambient;
  23.  
  24.         float3 V = normalize(IN.eye - IN.position);
  25.         float3 R = reflect(lightDir, IN.normal);
  26.        
  27.         float4 diffuse = diffuseBright * (materialDiffuse * saturate(dot(lightDir, IN.normal)));
  28.         float4 specular = specularBright * pow(saturate(dot(R, V)), normalize(shine));
  29.         float4 finalColor = ambient + diffuse;
  30.         if (shine > 0)
  31.         {
  32.             finalColor = saturate(finalColor + specular);
  33.         }
  34.  
  35.        
  36.  
  37.         float4 color = texDiffuse.Sample(DiffuseSampler, IN.tex0);
  38.         float4 sphCol = sphTexture.Sample(SphereSampler, IN.spTex);
  39.         if (useTexture)
  40.         {
  41.             finalColor *= color;
  42.         }
  43.         if (useSphere)
  44.         {
  45.             if (isSphereAdd)
  46.             {
  47.                 finalColor += sphCol;
  48.             }
  49.             else
  50.             {
  51.                 finalColor *= sphCol;
  52.             }
  53.         }
  54.         float4 o = (finalColor * extraBright) * fadeCoef;
  55.         if (useTexture)
  56.         {
  57.             o.a = color.a * materialDiffuse.a;
  58.         }
  59.         else
  60.         {
  61.             o.a = materialDiffuse.a;
  62.         }
  63.         return o;
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement