Diffuse.bsl 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "$ENGINE$\BasePass.bslinc"
  2. #include "$ENGINE$\Surface.bslinc"
  3. Parameters =
  4. {
  5. Sampler2D gAlbedoSamp : alias("gAlbedoTex");
  6. Sampler2D gNormalSamp : alias("gNormalTex");
  7. Sampler2D gRoughnessSamp : alias("gRoughnessTex");
  8. Sampler2D gMetalnessSamp : alias("gMetalnessTex");
  9. Texture2D gAlbedoTex;
  10. Texture2D gNormalTex = "normal";
  11. Texture2D gRoughnessTex = "white";
  12. Texture2D gMetalnessTex = "black";
  13. };
  14. Technique : base("Surface") =
  15. {
  16. Pass =
  17. {
  18. Fragment =
  19. {
  20. SamplerState gAlbedoSamp : register(s0);
  21. SamplerState gNormalSamp : register(s1);
  22. SamplerState gRoughnessSamp : register(s2);
  23. SamplerState gMetalnessSamp : register(s3);
  24. Texture2D gAlbedoTex : register(t0);
  25. Texture2D gNormalTex : register(t1);
  26. Texture2D gRoughnessTex : register(t2);
  27. Texture2D gMetalnessTex : register(t3);
  28. void main(
  29. in VStoFS input,
  30. out float4 OutGBufferA : SV_Target0,
  31. out float4 OutGBufferB : SV_Target1,
  32. out float2 OutGBufferC : SV_Target2)
  33. {
  34. float3 normal = normalize(gNormalTex.Sample(gNormalSamp, input.uv0) * 2.0f - float3(1, 1, 1));
  35. float3 worldNormal = calcWorldNormal(input, normal);
  36. SurfaceData surfaceData;
  37. surfaceData.albedo = gAlbedoTex.Sample(gAlbedoSamp, input.uv0);
  38. surfaceData.worldNormal.xyz = worldNormal;
  39. surfaceData.roughness = gRoughnessTex.Sample(gRoughnessSamp, input.uv0).x;
  40. surfaceData.metalness = gMetalnessTex.Sample(gMetalnessSamp, input.uv0).x;
  41. encodeGBuffer(surfaceData, OutGBufferA, OutGBufferB, OutGBufferC);
  42. }
  43. };
  44. };
  45. };