Advertisement
Boost

Untitled

Jul 12th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include "$ENGINE$\BasePass.bslinc"
  2. #include "$ENGINE$\ForwardLighting.bslinc"
  3.  
  4. options
  5. {
  6. transparent = true;
  7. };
  8.  
  9. shader Surface
  10. {
  11. mixin BasePass;
  12. mixin ForwardLighting;
  13.  
  14. blend
  15. {
  16. target
  17. {
  18. enabled = true;
  19. color = { srcA, srcIA, add };
  20. };
  21. };
  22.  
  23. depth
  24. {
  25. write = false;
  26. };
  27.  
  28. code
  29. {
  30. [alias(gAlbedoTex)]
  31. SamplerState gAlbedoSamp;
  32.  
  33. [alias(gNormalTex)]
  34. SamplerState gNormalSamp;
  35.  
  36. [alias(gRoughnessTex)]
  37. SamplerState gRoughnessSamp;
  38.  
  39. [alias(gMetalnessTex)]
  40. SamplerState gMetalnessSamp;
  41.  
  42. [alias(gEmissiveMaskTex)]
  43. SamplerState gEmissiveMaskSamp;
  44.  
  45. Texture2D gAlbedoTex = white;
  46. Texture2D gNormalTex = normal;
  47. Texture2D gRoughnessTex = white;
  48. Texture2D gMetalnessTex = black;
  49. Texture2D gEmissiveMaskTex = black;
  50.  
  51. cbuffer MaterialParams
  52. {
  53. float gOpacity = 1.0f;
  54. [color]
  55. float3 gEmissiveColor = { 1.0f, 1.0f, 1.0f };
  56. float2 gUVOffset = { 0.0f, 0.0f };
  57. float2 gUVTile = { 1.0f, 1.0f };
  58. }
  59.  
  60. float4 fsmain(in VStoFS input) : SV_Target0
  61. {
  62. float2 uv = input.uv0 * gUVTile + gUVOffset;
  63.  
  64. float3 normal = normalize(gNormalTex.Sample(gNormalSamp, uv).xyz * 2.0f - float3(1, 1, 1));
  65. float3 worldNormal = calcWorldNormal(input, normal);
  66.  
  67. SurfaceData surfaceData;
  68. surfaceData.albedo = gAlbedoTex.Sample(gAlbedoSamp, uv);
  69. surfaceData.worldNormal.xyz = worldNormal;
  70. surfaceData.worldNormal.w = 1.0f;
  71. surfaceData.roughness = gRoughnessTex.Sample(gRoughnessSamp, uv).x;
  72. surfaceData.metalness = gMetalnessTex.Sample(gMetalnessSamp, uv).x;
  73.  
  74. float3 lighting = calcLighting(input.worldPosition.xyz, input.position, uv, surfaceData);
  75. float3 emissive = gEmissiveColor * gEmissiveMaskTex.Sample(gEmissiveMaskSamp, uv).x;
  76. return float4(emissive + lighting, surfaceData.albedo.a * gOpacity);
  77. }
  78. };
  79. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement