Diffuse.bsl 1022 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "$ENGINE$\BasePass.bslinc"
  2. #include "$ENGINE$\Surface.bslinc"
  3. mixin Surface
  4. {
  5. code
  6. {
  7. SamplerState gAlbedoSamp;
  8. SamplerState gNormalSamp;
  9. SamplerState gRoughnessSamp;
  10. SamplerState gMetalnessSamp;
  11. Texture2D gAlbedoTex;
  12. Texture2D gNormalTex;
  13. Texture2D gRoughnessTex;
  14. Texture2D gMetalnessTex;
  15. void fsmain(
  16. in VStoFS input,
  17. out float4 OutGBufferA : SV_Target0,
  18. out float4 OutGBufferB : SV_Target1,
  19. out float2 OutGBufferC : SV_Target2)
  20. {
  21. float3 normal = normalize(gNormalTex.Sample(gNormalSamp, input.uv0) * 2.0f - float3(1, 1, 1));
  22. float3 worldNormal = calcWorldNormal(input, normal);
  23. SurfaceData surfaceData;
  24. surfaceData.albedo = gAlbedoTex.Sample(gAlbedoSamp, input.uv0);
  25. surfaceData.worldNormal.xyz = worldNormal;
  26. surfaceData.roughness = gRoughnessTex.Sample(gRoughnessSamp, input.uv0).x;
  27. surfaceData.metalness = gMetalnessTex.Sample(gMetalnessSamp, input.uv0).x;
  28. encodeGBuffer(surfaceData, OutGBufferA, OutGBufferB, OutGBufferC);
  29. }
  30. };
  31. };