Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float4 ps_lighting(VS_OUTPUT IN) : SV_Target
- {
- if (renderingSkel || renderingRBody)
- {
- return float4(1, 1, 1, 1);
- }
- else
- {
- //shadow mapping stuff
- IN.lpos.xyz /= IN.lpos.w;
- float4 ambient = ambientBright * materialAmbient;
- 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 )
- return ambient;
- IN.lpos.x = IN.lpos.x/2 + 0.5;
- IN.lpos.y = IN.lpos.y/-2 + 0.5;
- float shadowMapDepth = shadowMap.Sample(ShadowSampler, IN.lpos.xy).r;
- if (shadowMapDepth < IN.lpos.z) return ambient;
- float3 V = normalize(IN.eye - IN.position);
- float3 R = reflect(lightDir, IN.normal);
- float4 diffuse = diffuseBright * (materialDiffuse * saturate(dot(lightDir, IN.normal)));
- float4 specular = specularBright * pow(saturate(dot(R, V)), normalize(shine));
- float4 finalColor = ambient + diffuse;
- if (shine > 0)
- {
- finalColor = saturate(finalColor + specular);
- }
- float4 color = texDiffuse.Sample(DiffuseSampler, IN.tex0);
- float4 sphCol = sphTexture.Sample(SphereSampler, IN.spTex);
- if (useTexture)
- {
- finalColor *= color;
- }
- if (useSphere)
- {
- if (isSphereAdd)
- {
- finalColor += sphCol;
- }
- else
- {
- finalColor *= sphCol;
- }
- }
- float4 o = (finalColor * extraBright) * fadeCoef;
- if (useTexture)
- {
- o.a = color.a * materialDiffuse.a;
- }
- else
- {
- o.a = materialDiffuse.a;
- }
- return o;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement