MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / Process

Method Process

src/Nazara/Graphics/DeferredGeometryPass.cpp:50–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 */
49
50 bool DeferredGeometryPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned int secondWorkTexture) const
51 {
52 NazaraAssert(sceneData.viewer, "Invalid viewer");
53 NazaraUnused(firstWorkTexture);
54 NazaraUnused(secondWorkTexture);
55
56 bool instancingEnabled = m_deferredTechnique->IsInstancingEnabled();
57
58 m_GBufferRTT->SetColorTargets({0, 1, 2}); // G-Buffer
59 Renderer::SetTarget(m_GBufferRTT);
60 Renderer::SetViewport(Recti(0, 0, m_dimensions.x, m_dimensions.y));
61
62 Renderer::SetRenderStates(m_clearStates);
63 Renderer::SetShader(m_clearShader);
64 Renderer::DrawFullscreenQuad();
65
66
67 Renderer::SetMatrix(MatrixType_Projection, sceneData.viewer->GetProjectionMatrix());
68 Renderer::SetMatrix(MatrixType_View, sceneData.viewer->GetViewMatrix());
69
70 const Shader* lastShader = nullptr;
71 const ShaderUniforms* shaderUniforms = nullptr;
72
73 for (auto& layerPair : m_renderQueue->layers)
74 {
75 for (auto& pipelinePair : layerPair.second.opaqueModels)
76 {
77 const MaterialPipeline* pipeline = pipelinePair.first;
78 auto& pipelineEntry = pipelinePair.second;
79
80 if (pipelineEntry.maxInstanceCount > 0)
81 {
82 bool instancing = instancingEnabled && (pipelineEntry.maxInstanceCount > NAZARA_GRAPHICS_INSTANCING_MIN_INSTANCES_COUNT);
83
84 UInt32 flags = ShaderFlags_Deferred;
85 if (instancing)
86 flags |= ShaderFlags_Instancing;
87
88 const MaterialPipeline::Instance& pipelineInstance = pipeline->Apply(flags);
89
90 const Shader* shader = pipelineInstance.uberInstance->GetShader();
91
92 // Uniforms are conserved in our program, there's no point to send them back until they change
93 if (shader != lastShader)
94 {
95 // Index of uniforms in the shader
96 shaderUniforms = GetShaderUniforms(shader);
97
98 // Ambiant color of the scene
99 shader->SendColor(shaderUniforms->sceneAmbient, sceneData.ambientColor);
100 // Position of the camera
101 shader->SendVector(shaderUniforms->eyePosition, sceneData.viewer->GetEyePosition());
102
103 lastShader = shader;
104 }
105
106 for (auto& materialPair : pipelineEntry.materialMap)
107 {

Callers

nothing calls this directly

Calls 11

IsInstancingEnabledMethod · 0.80
SetColorTargetsMethod · 0.80
SendColorMethod · 0.80
SendVectorMethod · 0.80
GetEyePositionMethod · 0.80
GetIndexCountMethod · 0.80
SetVertexDeclarationMethod · 0.80
ApplyMethod · 0.45
GetShaderMethod · 0.45
GetVertexCountMethod · 0.45
FillMethod · 0.45

Tested by

no test coverage detected