Transparent.bsl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "$ENGINE$\BasePass.bslinc"
  2. #include "$ENGINE$\ForwardLighting.bslinc"
  3. options
  4. {
  5. transparent = true;
  6. };
  7. technique Surface
  8. {
  9. mixin BasePass;
  10. mixin ForwardLighting;
  11. blend
  12. {
  13. target
  14. {
  15. enabled = true;
  16. color = { srcA, srcIA, add };
  17. };
  18. };
  19. depth
  20. {
  21. write = false;
  22. };
  23. code
  24. {
  25. SamplerState gAlbedoSamp;
  26. SamplerState gNormalSamp;
  27. SamplerState gRoughnessSamp;
  28. SamplerState gMetalnessSamp;
  29. Texture2D gAlbedoTex;
  30. Texture2D gNormalTex;
  31. Texture2D gRoughnessTex;
  32. Texture2D gMetalnessTex;
  33. cbuffer MaterialParams
  34. {
  35. float gOpacity = 1.0f;
  36. }
  37. float4 fsmain(in VStoFS input) : SV_Target0
  38. {
  39. float3 normal = normalize(gNormalTex.Sample(gNormalSamp, input.uv0).xyz * 2.0f - float3(1, 1, 1));
  40. float3 worldNormal = calcWorldNormal(input, normal);
  41. SurfaceData surfaceData;
  42. surfaceData.albedo = gAlbedoTex.Sample(gAlbedoSamp, input.uv0);
  43. surfaceData.worldNormal.xyz = worldNormal;
  44. surfaceData.worldNormal.w = 1.0f;
  45. surfaceData.roughness = gRoughnessTex.Sample(gRoughnessSamp, input.uv0).x;
  46. surfaceData.metalness = gMetalnessTex.Sample(gMetalnessSamp, input.uv0).x;
  47. float3 lighting = calcLighting(input.worldPosition.xyz, input.position, input.uv0, surfaceData);
  48. return float4(lighting, surfaceData.albedo.a * gOpacity);
  49. }
  50. };
  51. };