Unlit.hlsl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "Uniforms.hlsl"
  2. #include "Samplers.hlsl"
  3. #include "Transform.hlsl"
  4. #include "Fog.hlsl"
  5. void VS(float4 iPos : POSITION,
  6. float2 iTexCoord : TEXCOORD0,
  7. #ifdef VERTEXCOLOR
  8. float4 iColor : COLOR0,
  9. #endif
  10. #ifdef SKINNED
  11. float4 iBlendWeights : BLENDWEIGHT,
  12. int4 iBlendIndices : BLENDINDICES,
  13. #endif
  14. #ifdef INSTANCED
  15. float4x3 iModelInstance : TEXCOORD2,
  16. #endif
  17. #ifdef BILLBOARD
  18. float2 iSize : TEXCOORD1,
  19. #endif
  20. out float2 oTexCoord : TEXCOORD0,
  21. out float oDepth : TEXCOORD1,
  22. #ifdef VERTEXCOLOR
  23. out float4 oColor : COLOR0,
  24. #endif
  25. out float4 oPos : POSITION)
  26. {
  27. float4x3 modelMatrix = iModelMatrix;
  28. float3 worldPos = GetWorldPos(modelMatrix);
  29. oPos = GetClipPos(worldPos);
  30. oTexCoord = GetTexCoord(iTexCoord);
  31. oDepth = GetDepth(oPos);
  32. #ifdef VERTEXCOLOR
  33. oColor = iColor;
  34. #endif
  35. }
  36. void PS(float2 iTexCoord : TEXCOORD0,
  37. float iDepth : TEXCOORD1,
  38. #ifdef VERTEXCOLOR
  39. float4 iColor : COLOR0,
  40. #endif
  41. out float4 oColor : COLOR0)
  42. {
  43. #ifdef DIFFMAP
  44. float4 diffColor = cMatDiffColor * tex2D(sDiffMap, iTexCoord);
  45. #else
  46. float4 diffColor = cMatDiffColor;
  47. #endif
  48. #ifdef VERTEXCOLOR
  49. diffColor *= iColor;
  50. #endif
  51. oColor = float4(GetFog(diffColor.rgb, iDepth), diffColor.a);
  52. }