ParticlesLitOpaque.bsl 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #define LIGHTING_DATA
  2. #include "$ENGINE$\ParticleVertex.bslinc"
  3. #include "$ENGINE$\GBufferOutput.bslinc"
  4. shader Surface
  5. {
  6. mixin ParticleVertex;
  7. mixin GBufferOutput;
  8. code
  9. {
  10. [alias(gAlbedoTex)]
  11. SamplerState gAlbedoSamp;
  12. [alias(gNormalTex)]
  13. SamplerState gNormalSamp;
  14. [alias(gRoughnessTex)]
  15. SamplerState gRoughnessSamp;
  16. [alias(gMetalnessTex)]
  17. SamplerState gMetalnessSamp;
  18. [alias(gEmissiveMaskTex)]
  19. SamplerState gEmissiveMaskSamp;
  20. Texture2D gAlbedoTex = white;
  21. Texture2D gNormalTex = normal;
  22. Texture2D gRoughnessTex = white;
  23. Texture2D gMetalnessTex = black;
  24. Texture2D gEmissiveMaskTex = black;
  25. cbuffer MaterialParams
  26. {
  27. float2 gUVOffset = { 0.0f, 0.0f };
  28. float2 gUVTile = { 1.0f, 1.0f };
  29. [color][hdr]
  30. float3 gEmissiveColor = { 1.0f, 1.0f, 1.0f };
  31. };
  32. void fsmain(
  33. in VStoFS input,
  34. out float4 OutSceneColor : SV_Target0,
  35. out GBufferData OutGBuffer)
  36. {
  37. float2 uv = input.uv0 * gUVTile + gUVOffset;
  38. float3 normal = normalize(gNormalTex.Sample(gNormalSamp, uv) * 2.0f - float3(1, 1, 1));
  39. float3 worldNormal = calcWorldNormal(input, normal);
  40. SurfaceData surfaceData;
  41. surfaceData.albedo = gAlbedoTex.Sample(gAlbedoSamp, uv);
  42. surfaceData.worldNormal.xyz = worldNormal;
  43. surfaceData.roughness = gRoughnessTex.Sample(gRoughnessSamp, uv).x;
  44. surfaceData.metalness = gMetalnessTex.Sample(gMetalnessSamp, uv).x;
  45. surfaceData.mask = gLayer;
  46. surfaceData.velocity = 0.0f; // Note: No velocity for particles yet, but this should be added
  47. OutSceneColor = float4(gEmissiveColor * gEmissiveMaskTex.Sample(gEmissiveMaskSamp, uv).x, 1);
  48. OutGBuffer = encodeGBuffer(surfaceData);
  49. }
  50. };
  51. };