Advertisement
Guest User

Untitled

a guest
Feb 11th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. float4x4 World;
  2. float4x4 View;
  3. float4x4 Projection;
  4.  
  5. float3 CameraPosition;
  6.  
  7. Texture SkyBoxTexture;
  8. samplerCUBE SkyBoxSampler = sampler_state //unlike a texture sampler it is a cube instead of 2D
  9. {
  10. texture = <SkyBoxTexture>;
  11. magfilter = LINEAR;
  12. minfilter = LINEAR;
  13. mipfilter = LINEAR;
  14. AddressU = Mirror;
  15. AddressV = Mirror;
  16. };
  17.  
  18. struct VertexShaderInput
  19. {
  20. float4 Position : POSITION0;
  21. };
  22.  
  23. struct VertexShaderOutput
  24. {
  25. float4 Position : POSITION0;
  26. float3 TextureCoordinate : TEXCOORD0;
  27. };
  28.  
  29. VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
  30. {
  31. VertexShaderOutput output;
  32.  
  33. float4 worldPosition = mul(input.Position, World);
  34. float4 viewPosition = mul(worldPosition, View);
  35. output.Position = mul(viewPosition, Projection);
  36.  
  37. float4 VertexPosition = mul(input.Position, World);
  38. output.TextureCoordinate = VertexPosition - CameraPosition;
  39.  
  40. return output;
  41. }
  42.  
  43. float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
  44. {
  45. return texCUBE(SkyBoxSampler, normalize(input.TextureCoordinate));
  46. }
  47.  
  48.  
  49. technique Skybox
  50. {
  51. pass Pass1
  52. {
  53. VertexShader = compile vs_4_0_level_9_3 VertexShaderFunction();
  54. PixelShader = compile ps_4_0_level_9_3 PixelShaderFunction();
  55. }
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement