GizmoPickingAlpha.bsl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. Parameters =
  2. {
  3. mat4x4 matViewProj;
  4. float alphaCutoff;
  5. Sampler2D mainTexSamp : alias("mainTexture");
  6. Texture2D mainTexture;
  7. };
  8. Technique =
  9. {
  10. Language = "HLSL11";
  11. Pass =
  12. {
  13. Scissor = true;
  14. Vertex =
  15. {
  16. float4x4 matViewProj;
  17. void main(
  18. in float3 inPos : POSITION,
  19. in float2 uv : TEXCOORD0,
  20. in float4 color : COLOR0,
  21. out float4 oPosition : SV_Position,
  22. out float2 oUv : TEXCOORD0,
  23. out float4 oColor : COLOR0)
  24. {
  25. oPosition = mul(matViewProj, float4(inPos.xyz, 1));
  26. oUv = uv;
  27. oColor = color;
  28. }
  29. };
  30. Fragment =
  31. {
  32. SamplerState mainTexSamp : register(s0);
  33. Texture2D mainTexture : register(t0);
  34. float alphaCutoff;
  35. float4 main(in float4 inPos : SV_Position,
  36. in float2 uv : TEXCOORD0,
  37. in float4 inColor : COLOR0) : SV_Target
  38. {
  39. float4 color = mainTexture.Sample(mainTexSamp, uv);
  40. if(color.a < alphaCutoff)
  41. discard;
  42. return inColor;
  43. }
  44. };
  45. };
  46. };
  47. Technique =
  48. {
  49. Language = "HLSL9";
  50. Pass =
  51. {
  52. Scissor = true;
  53. Vertex =
  54. {
  55. float4x4 matViewProj;
  56. void main(
  57. in float3 inPos : POSITION,
  58. in float2 uv : TEXCOORD0,
  59. in float4 color : COLOR0,
  60. out float4 oPosition : POSITION,
  61. out float2 oUv : TEXCOORD0,
  62. out float4 oColor : COLOR0)
  63. {
  64. oPosition = mul(matViewProj, float4(inPos.xyz, 1));
  65. oUv = uv;
  66. oColor = color;
  67. }
  68. };
  69. Fragment =
  70. {
  71. sampler2D mainTexture;
  72. float alphaCutoff;
  73. float4 main(in float4 inPos : POSITION,
  74. in float2 inUv : TEXCOORD0,
  75. in float4 inColor : COLOR0) : COLOR0
  76. {
  77. float4 color = tex2D(mainTexture, inUv);
  78. if(color.a < alphaCutoff)
  79. discard;
  80. return inColor;
  81. }
  82. };
  83. };
  84. };
  85. Technique =
  86. {
  87. Language = "GLSL";
  88. Pass =
  89. {
  90. Scissor = true;
  91. Vertex =
  92. {
  93. uniform mat4 matViewProj;
  94. in vec3 bs_position;
  95. in vec4 bs_color0;
  96. in vec2 bs_texcoord0;
  97. out vec2 texcoord0;
  98. out vec4 color0;
  99. out gl_PerVertex
  100. {
  101. vec4 gl_Position;
  102. };
  103. void main()
  104. {
  105. gl_Position = matViewProj * vec4(bs_position.xyz, 1);
  106. texcoord0 = bs_texcoord0;
  107. color0 = bs_color0;
  108. }
  109. };
  110. Fragment =
  111. {
  112. uniform sampler2D mainTexture;
  113. uniform float alphaCutoff;
  114. in vec2 texcoord0;
  115. in vec4 color0;
  116. out vec4 fragColor;
  117. void main()
  118. {
  119. vec4 texColor = texture2D(mainTexture, texcoord0);
  120. if(texColor.a < alphaCutoff)
  121. discard;
  122. fragColor = color0;
  123. }
  124. };
  125. };
  126. };