Guest User

pixel_program/a_envmask_specmap_ps20_nodot3.psh

a guest
May 11th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. //hlsl ps_2_0
  2.  
  3. #include "pixel_program/include/pixel_shader_constants.inc"
  4. #include "pixel_program/include/functions.inc"
  5.  
  6. sampler diffuseMap  : register(s0);
  7. sampler specularMap     : register(s1);
  8. sampler envMap      : register(s2);
  9.  
  10. float4 main
  11. (
  12.     in float3 vertexDiffuse     : COLOR0,
  13.     in float3 vertexSpecular    : COLOR1,
  14.     in float2 tcs_MAIN      : TEXCOORD0,
  15.     in float2 tcs_ENVM      : TEXCOORD1
  16. )
  17. : COLOR
  18. {
  19.     float4 result; 
  20.  
  21.     // Sample color map and env mask
  22.     float3 diffuseColor;
  23.     float envMask;
  24.     {
  25.         float4 sample = tex2D(diffuseMap, tcs_MAIN);
  26.         diffuseColor = sample.rgb;
  27.         envMask = sample.a;
  28.     }
  29.     float specularMask = tex2D(specularMap, tcs_MAIN).a;
  30.  
  31.     // sample environment map
  32.     float3 envColor = tex2D(envMap, tcs_ENVM);
  33.    
  34.     // apply lighting
  35.     float3 diffuseLitSurface = diffuseColor * vertexDiffuse;
  36.  
  37.     float3 allSpecularLightRaw = (vertexSpecular * specularMask);
  38.     float3 allSpecularLight = allSpecularLightRaw;
  39.     if (bloomEnabled > 0.0f)
  40.         allSpecularLight *= bloomSpecularRgbScale;
  41.  
  42.     // lerp masked environment back on after lighting and add specular
  43.     result.rgb = lerp(diffuseLitSurface, envColor, envMask) + allSpecularLight;
  44.  
  45.     if (alphaFadeOpacityEnabled > 0.0f)
  46.     {
  47.         result.a = alphaFadeOpacity;
  48.     }
  49.     else
  50.     {
  51.         result.a = intensity(allSpecularLightRaw);
  52.         if (bloomEnabled > 0.0f)
  53.             result.a *= bloomSpecularAlphaScale;
  54.     }
  55.  
  56.     return result;
  57. }
Add Comment
Please, Sign In to add comment