暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Universal2D.hlsl 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef UNIVERSAL_FALLBACK_2D_INCLUDED
  2. #define UNIVERSAL_FALLBACK_2D_INCLUDED
  3. struct Attributes
  4. {
  5. float4 positionOS : POSITION;
  6. float2 uv : TEXCOORD0;
  7. UNITY_VERTEX_INPUT_INSTANCE_ID
  8. };
  9. struct Varyings
  10. {
  11. float2 uv : TEXCOORD0;
  12. float4 vertex : SV_POSITION;
  13. UNITY_VERTEX_INPUT_INSTANCE_ID
  14. };
  15. Varyings vert(Attributes input)
  16. {
  17. Varyings output = (Varyings)0;
  18. UNITY_SETUP_INSTANCE_ID(input);
  19. UNITY_TRANSFER_INSTANCE_ID(input, output);
  20. VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
  21. output.vertex = vertexInput.positionCS;
  22. output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
  23. return output;
  24. }
  25. half4 frag(Varyings input) : SV_Target
  26. {
  27. UNITY_SETUP_INSTANCE_ID(input);
  28. half2 uv = input.uv;
  29. half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv);
  30. half3 color = texColor.rgb * _BaseColor.rgb;
  31. half alpha = texColor.a * _BaseColor.a;
  32. AlphaDiscard(alpha, _Cutoff);
  33. #ifdef _ALPHAPREMULTIPLY_ON
  34. color *= alpha;
  35. #endif
  36. return half4(color, alpha);
  37. }
  38. #endif