Background.fx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. float4x4 World;
  2. float4x4 View;
  3. float4x4 Projection;
  4. float4 Fog;
  5. // TODO: add effect parameters here.
  6. struct VertexShaderInput
  7. {
  8. float4 Position : POSITION0;
  9. // TODO: add input channels such as texture
  10. // coordinates and vertex colors here.
  11. };
  12. struct VertexShaderOutput
  13. {
  14. float4 Position : POSITION0;
  15. float Depth : TEXCOORD0;
  16. // TODO: add vertex shader outputs such as colors and texture
  17. // coordinates here. These values will automatically be interpolated
  18. // over the triangle, and provided as input to your pixel shader.
  19. };
  20. VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
  21. {
  22. VertexShaderOutput output;
  23. float4 worldPosition = mul(input.Position, World);
  24. float4 viewPosition = mul(worldPosition, View);
  25. output.Depth = length(viewPosition);
  26. output.Position = mul(viewPosition, Projection);
  27. // TODO: add your vertex shader code here.
  28. return output;
  29. }
  30. float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
  31. {
  32. // TODO: add your pixel shader code here.
  33. return lerp(Fog * 0.25, Fog * 0.95, clamp(input.Depth * 0.005, 0, 1));
  34. }
  35. technique Technique1
  36. {
  37. pass Pass1
  38. {
  39. // TODO: set renderstates here.
  40. VertexShader = compile vs_2_0 VertexShaderFunction();
  41. PixelShader = compile ps_2_0 PixelShaderFunction();
  42. }
  43. }