PXR_CubemapBlit.shader 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Shader "PXR_SDK/PXR_CubemapBlit" {
  2. Properties{
  3. _MainTex("MainTex", CUBE) = "white" {}
  4. _d("Direction", Int) = 0
  5. }
  6. SubShader{
  7. Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
  8. Pass{
  9. ZWrite Off
  10. ColorMask RGBA
  11. CGPROGRAM
  12. #pragma vertex vert
  13. #pragma fragment frag
  14. #include "UnityCG.cginc"
  15. struct appdata
  16. {
  17. float4 vertex : POSITION;
  18. float2 texcoord : TEXCOORD0;
  19. };
  20. struct v2f
  21. {
  22. float4 vertex : POSITION;
  23. half3 cubedir : TEXCOORD0;
  24. };
  25. samplerCUBE _MainTex;
  26. int _d;
  27. v2f vert(appdata v)
  28. {
  29. v2f o;
  30. o.vertex = UnityObjectToClipPos(v.vertex);
  31. float3 of[6] = { {1.0, -1.0, 1.0}, {-1.0, -1.0, -1.0}, {-1.0, 1.0, 1.0}, {-1.0, -1.0, -1.0}, {-1.0, -1.0, 1.0}, { 1.0, -1.0, -1.0} };
  32. float3 uf[6] = { {0.0, 0.0, -1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0} };
  33. float3 vf[6] = { {0.0, 1.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, -1.0}, { 0.0, 0.0, 1.0}, { 0.0, 1.0, 0.0}, { 0.0, 1.0, 0.0} };
  34. o.cubedir = of[_d] + 2.0 * v.texcoord.x * uf[_d] + 2.0 * (1.0 - v.texcoord.y) * vf[_d];
  35. return o;
  36. }
  37. fixed4 frag(v2f v) : COLOR
  38. {
  39. fixed4 col = texCUBE(_MainTex, v.cubedir);
  40. return col;
  41. }
  42. ENDCG
  43. }
  44. }
  45. }