MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / GetEnvMapPSMain

Function GetEnvMapPSMain

Hydrogent/src/Tasks/HnRenderEnvMapTask.cpp:83–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static std::string GetEnvMapPSMain(bool WriteAllTargets)
84{
85 static_assert(HnFrameRenderTargets::GBUFFER_TARGET_COUNT == 7, "Did you change the number of G-buffer targets? You may need to update the code below.");
86
87 std::stringstream ss;
88 ss << R"(
89void main(in float4 Pos : SV_Position,
90 in float4 ClipPos : CLIP_POS,
91)";
92 ss << " out float4 Color : SV_Target" << HnFrameRenderTargets::GBUFFER_TARGET_SCENE_COLOR << ',' << std::endl
93 << " out float4 MotionVec : SV_Target" << HnFrameRenderTargets::GBUFFER_TARGET_MOTION_VECTOR;
94
95 if (WriteAllTargets)
96 {
97 ss << ',' << std::endl
98 << " out float4 MeshId : SV_Target" << HnFrameRenderTargets::GBUFFER_TARGET_MESH_ID << ',' << std::endl
99 << " out float4 Normal : SV_Target" << HnFrameRenderTargets::GBUFFER_TARGET_NORMAL << ',' << std::endl
100 << " out float4 BaseColor : SV_Target" << HnFrameRenderTargets::GBUFFER_TARGET_BASE_COLOR << ',' << std::endl
101 << " out float4 Material : SV_Target" << HnFrameRenderTargets::GBUFFER_TARGET_MATERIAL << ',' << std::endl
102 << " out float4 IBL : SV_Target" << HnFrameRenderTargets::GBUFFER_TARGET_IBL;
103 }
104
105 ss << R"()
106{
107 SampleEnvMapOutput EnvMap = SampleEnvMap(ClipPos);
108
109 Color = EnvMap.Color;
110 MotionVec = float4(EnvMap.MotionVector, 0.0, 1.0);
111)";
112
113 if (WriteAllTargets)
114 {
115 ss << R"(
116 MeshId = float4(0.0, 0.0, 0.0, 1.0);
117 Normal = float4(0.0, 0.0, 0.0, 0.0);
118 BaseColor = float4(0.0, 0.0, 0.0, 0.0);
119 Material = float4(0.0, 0.0, 0.0, 0.0);
120 IBL = float4(0.0, 0.0, 0.0, 0.0);
121)";
122 }
123
124 ss << "}\n";
125
126 return ss.str();
127}
128
129void HnRenderEnvMapTask::Prepare(pxr::HdTaskContext* TaskCtx,
130 pxr::HdRenderIndex* RenderIndex)

Callers 1

PrepareMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected