Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //hlsl ps_2_0
- #include "pixel_program/include/pixel_shader_constants.inc"
- #include "pixel_program/include/functions.inc"
- sampler diffuseMap : register(s0);
- sampler specularMap : register(s1);
- sampler envMap : register(s2);
- float4 main
- (
- in float3 vertexDiffuse : COLOR0,
- in float3 vertexSpecular : COLOR1,
- in float2 tcs_MAIN : TEXCOORD0,
- in float2 tcs_ENVM : TEXCOORD1
- )
- : COLOR
- {
- float4 result;
- // Sample color map and env mask
- float3 diffuseColor;
- float envMask;
- {
- float4 sample = tex2D(diffuseMap, tcs_MAIN);
- diffuseColor = sample.rgb;
- envMask = sample.a;
- }
- float specularMask = tex2D(specularMap, tcs_MAIN).a;
- // sample environment map
- float3 envColor = tex2D(envMap, tcs_ENVM);
- // apply lighting
- float3 diffuseLitSurface = diffuseColor * vertexDiffuse;
- float3 allSpecularLightRaw = (vertexSpecular * specularMask);
- float3 allSpecularLight = allSpecularLightRaw;
- if (bloomEnabled > 0.0f)
- allSpecularLight *= bloomSpecularRgbScale;
- // lerp masked environment back on after lighting and add specular
- result.rgb = lerp(diffuseLitSurface, envColor, envMask) + allSpecularLight;
- if (alphaFadeOpacityEnabled > 0.0f)
- {
- result.a = alphaFadeOpacity;
- }
- else
- {
- result.a = intensity(allSpecularLightRaw);
- if (bloomEnabled > 0.0f)
- result.a *= bloomSpecularAlphaScale;
- }
- return result;
- }
Add Comment
Please, Sign In to add comment