Advertisement
Guest User

Untitled

a guest
May 14th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. float4x4 World;
  2. float4x4 View;
  3. float4x4 Projection;
  4.  
  5. texture2D BasicTexture;
  6. sampler2D basicTextureSampler = sampler_state {
  7.     texture = <BasicTexture>;
  8.     addressU = wrap;
  9.     addressV = wrap;
  10.     minfilter = anisotropic;
  11.     magfilter = anisotropic;
  12.     mipfilter = linear;
  13. };
  14. bool TextureEnabled = true;
  15.  
  16. texture2D LightTexture;
  17. sampler2D lightSampler = sampler_state {
  18.     texture = <LightTexture>;
  19.     minfilter = point;
  20.     magfilter = point;
  21.     mipfilter = point;
  22. };
  23.  
  24. float3 AmbientColor = float3(0.15, 0.15, 0.15);
  25. float3 DiffuseColor;
  26.  
  27. #include "PPShared.vsi"
  28.  
  29. struct VertexShaderInput
  30. {
  31.     float4 Position : POSITION0;
  32.     float2 UV : TEXCOORD0;
  33. };
  34.  
  35. struct VertexShaderOutput
  36. {
  37.     float4 Position : POSITION0;
  38.     float2 UV : TEXCOORD0;
  39.     float4 PositionCopy : TEXCOORD1;
  40. };
  41.  
  42. VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
  43. {
  44.     VertexShaderOutput output;
  45.  
  46.     float4x4 worldViewProjection = mul(World, mul(View, Projection));
  47.    
  48.     output.Position = mul(input.Position, worldViewProjection);
  49.     output.PositionCopy = output.Position;
  50.    
  51.     output.UV = input.UV;
  52.  
  53.     return output;
  54. }
  55.  
  56. float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
  57. {
  58.     // Sample model's texture
  59.     float3 basicTexture = tex2D(basicTextureSampler, input.UV);
  60.    
  61.     if (!TextureEnabled)
  62.         basicTexture = float4(1, 1, 1, 1);
  63.        
  64.     // Extract lighting value from light map
  65.     float2 texCoord = postProjToScreen(input.PositionCopy) + halfPixel();
  66.     float3 light = tex2D(lightSampler, texCoord);
  67.    
  68.     light += AmbientColor;
  69.  
  70.     return float4(basicTexture * DiffuseColor * light, 1);
  71. }
  72.  
  73. technique Technique1
  74. {
  75.     pass Pass1
  76.     {
  77.         VertexShader = compile vs_1_1 VertexShaderFunction();
  78.         PixelShader = compile ps_2_0 PixelShaderFunction();
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement