Example.bsl 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "$ENGINE$\DeferredBasePass.bslinc"
  2. Parameters =
  3. {
  4. Sampler2D samp : alias("tex");
  5. Texture2D tex;
  6. };
  7. Technique : base("Surface") =
  8. {
  9. Language = "HLSL11";
  10. Pass =
  11. {
  12. Fragment =
  13. {
  14. SamplerState samp : register(s0);
  15. Texture2D tex : register(t0);
  16. float4 main(
  17. in VStoFS input,
  18. out float4 OutGBufferA : SV_Target1,
  19. out float4 OutGBufferB : SV_Target2) : SV_Target0
  20. {
  21. GBufferData gbufferData;
  22. gbufferData.albedo = float4(tex.Sample(samp, input.uv0).xyz, 1.0f);
  23. gbufferData.worldNormal.xyz = input.tangentToWorldZ;
  24. encodeGBuffer(gbufferData, OutGBufferA, OutGBufferB);
  25. // TODO - Just returning a simple ambient term, use better environment lighting later
  26. return float4(gbufferData.albedo.rgb, 1.0f) * 0.2f;
  27. }
  28. };
  29. };
  30. };
  31. Technique : base("Surface") =
  32. {
  33. Language = "GLSL";
  34. Pass =
  35. {
  36. Fragment =
  37. {
  38. layout(location = 0) in vec2 uv0;
  39. layout(location = 1) in vec3 tangentToWorldZ;
  40. layout(location = 2) in vec4 tangentToWorldX;
  41. layout(binding = 4) uniform sampler2D tex;
  42. layout(location = 0) out vec4 fragColor[3];
  43. void main()
  44. {
  45. GBufferData gbufferData;
  46. gbufferData.albedo = texture(tex, uv0);
  47. gbufferData.worldNormal.xyz = tangentToWorldZ;
  48. encodeGBuffer(gbufferData, fragColor[1], fragColor[2]);
  49. // TODO - Just returning a simple ambient term, use better environment lighting later
  50. fragColor[0] = vec4(gbufferData.albedo.rgb, 1.0f) * 0.2f;
  51. }
  52. };
  53. };
  54. };
  55. #include "$ENGINE$\Surface.bslinc"