From fccf8abc69b125db8de062545f8d31a2cfc04ac0 Mon Sep 17 00:00:00 2001 From: Hinageshi <2247001665@qq.com> Date: Tue, 12 Sep 2023 11:30:30 +0800 Subject: [PATCH] Separating shader compiling and loading logic in the renderer. --- Engine/Source/Editor/EditorApp.cpp | 10 +++++++- .../Source/Runtime/Rendering/AABBRenderer.cpp | 7 ++---- .../Runtime/Rendering/AnimationRenderer.cpp | 15 +++++------- .../Runtime/Rendering/BloomRenderer.cpp | 18 +++++++-------- .../Runtime/Rendering/DebugRenderer.cpp | 6 ++--- .../Runtime/Rendering/ImGuiRenderer.cpp | 2 +- .../Runtime/Rendering/PBRSkyRenderer.cpp | 23 ++++++++----------- .../Runtime/Rendering/ParticleRenderer.cpp | 3 +-- .../Runtime/Rendering/PostProcessRenderer.cpp | 6 ++--- .../Runtime/Rendering/SkeletonRenderer.cpp | 6 ++--- .../Runtime/Rendering/SkyboxRenderer.cpp | 6 ++--- .../Runtime/Rendering/TerrainRenderer.cpp | 6 ++--- .../Runtime/Rendering/WorldRenderer.cpp | 5 ++-- 13 files changed, 48 insertions(+), 65 deletions(-) diff --git a/Engine/Source/Editor/EditorApp.cpp b/Engine/Source/Editor/EditorApp.cpp index 5c111939..9e39459d 100644 --- a/Engine/Source/Editor/EditorApp.cpp +++ b/Engine/Source/Editor/EditorApp.cpp @@ -96,6 +96,8 @@ void EditorApp::Init(engine::EngineInitArgs initArgs) InitECWorld(); m_pEditorImGuiContext->SetSceneWorld(m_pSceneWorld.get()); + InitEngineRenderers(); + // Add shader build tasks and create a thread to update tasks. InitShaderPrograms(); m_pEditorImGuiContext->AddStaticLayer(std::make_unique("Splash")); @@ -499,6 +501,13 @@ bool EditorApp::Update(float deltaTime) if (!m_bInitEditor && ResourceBuilder::Get().IsIdle()) { m_bInitEditor = true; + + // Load compiled shaders. + for (std::unique_ptr& pRenderer : m_pEngineRenderers) + { + pRenderer->LoadShaders(); + } + engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetPBRMaterialType()); engine::ShaderLoader::UploadUberShader(m_pSceneWorld->GetAnimationMaterialType()); #ifdef ENABLE_DDGI @@ -522,7 +531,6 @@ bool EditorApp::Update(float deltaTime) GetMainWindow()->SetBordedLess(false); GetMainWindow()->SetResizeable(true); - InitEngineRenderers(); m_pEditorImGuiContext->ClearUILayers(); InitEditorUILayers(); diff --git a/Engine/Source/Runtime/Rendering/AABBRenderer.cpp b/Engine/Source/Runtime/Rendering/AABBRenderer.cpp index cc55c2ac..d2b3b957 100644 --- a/Engine/Source/Runtime/Rendering/AABBRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/AABBRenderer.cpp @@ -12,20 +12,17 @@ namespace engine void AABBRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_AABB"); pShaderVariantCollectionsComponent->AddShader("fs_AABB"); - - GetRenderContext()->CreateProgram("AABBProgram", "vs_AABB.bin", "fs_AABB.bin"); bgfx::setViewName(GetViewID(), "AABBRenderer"); } void AABBRenderer::LoadShaders() { - + GetRenderContext()->CreateProgram("AABBProgram", "vs_AABB.bin", "fs_AABB.bin"); } void AABBRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) diff --git a/Engine/Source/Runtime/Rendering/AnimationRenderer.cpp b/Engine/Source/Runtime/Rendering/AnimationRenderer.cpp index f4ea0c8f..9f49e6ac 100644 --- a/Engine/Source/Runtime/Rendering/AnimationRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/AnimationRenderer.cpp @@ -135,25 +135,22 @@ void CalculateBoneTransform(std::vector& boneMatrices, const cd:: void AnimationRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_animation"); pShaderVariantCollectionsComponent->AddShader("fs_animation"); + bgfx::setViewName(GetViewID(), "AnimationRenderer"); +} + +void AnimationRenderer::LoadShaders() +{ #ifdef VISUALIZE_BONE_WEIGHTS m_pRenderContext->CreateUniform("u_debugBoneIndex", bgfx::UniformType::Vec4, 1); m_pRenderContext->CreateProgram("AnimationProgram", "vs_visualize_bone_weight.bin", "fs_visualize_bone_weight.bin"); #else GetRenderContext()->CreateProgram("AnimationProgram", "vs_animation.bin", "fs_animation.bin"); #endif - - bgfx::setViewName(GetViewID(), "AnimationRenderer"); -} - -void AnimationRenderer::LoadShaders() -{ - } void AnimationRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) diff --git a/Engine/Source/Runtime/Rendering/BloomRenderer.cpp b/Engine/Source/Runtime/Rendering/BloomRenderer.cpp index 17473f6e..d91672f4 100644 --- a/Engine/Source/Runtime/Rendering/BloomRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/BloomRenderer.cpp @@ -6,8 +6,7 @@ namespace engine { void BloomRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_fullscreen"); pShaderVariantCollectionsComponent->AddShader("fs_captureBrightness"); @@ -24,13 +23,6 @@ namespace engine GetRenderContext()->CreateUniform("u_textureSize", bgfx::UniformType::Vec4); GetRenderContext()->CreateUniform("u_bloomIntensity", bgfx::UniformType::Vec4); GetRenderContext()->CreateUniform("u_luminanceThreshold", bgfx::UniformType::Vec4); - GetRenderContext()->CreateProgram("CapTureBrightnessProgram", "vs_fullscreen.bin", "fs_captureBrightness.bin"); - GetRenderContext()->CreateProgram("DownSampleProgram", "vs_fullscreen.bin", "fs_dowmsample.bin"); - GetRenderContext()->CreateProgram("BlurVerticalProgram", "vs_fullscreen.bin", "fs_blurvertical.bin"); - GetRenderContext()->CreateProgram("BlurHorizontalProgram", "vs_fullscreen.bin", "fs_blurhorizontal.bin"); - GetRenderContext()->CreateProgram("UpSampleProgram", "vs_fullscreen.bin", "fs_upsample.bin"); - GetRenderContext()->CreateProgram("KawaseBlurProgram", "vs_fullscreen.bin", "fs_kawaseblur.bin"); - GetRenderContext()->CreateProgram("CombineProgram", "vs_fullscreen.bin", "fs_bloom.bin"); bgfx::setViewName(GetViewID(), "BloomRenderer"); @@ -51,7 +43,13 @@ namespace engine void BloomRenderer::LoadShaders() { - + GetRenderContext()->CreateProgram("CapTureBrightnessProgram", "vs_fullscreen.bin", "fs_captureBrightness.bin"); + GetRenderContext()->CreateProgram("DownSampleProgram", "vs_fullscreen.bin", "fs_dowmsample.bin"); + GetRenderContext()->CreateProgram("BlurVerticalProgram", "vs_fullscreen.bin", "fs_blurvertical.bin"); + GetRenderContext()->CreateProgram("BlurHorizontalProgram", "vs_fullscreen.bin", "fs_blurhorizontal.bin"); + GetRenderContext()->CreateProgram("UpSampleProgram", "vs_fullscreen.bin", "fs_upsample.bin"); + GetRenderContext()->CreateProgram("KawaseBlurProgram", "vs_fullscreen.bin", "fs_kawaseblur.bin"); + GetRenderContext()->CreateProgram("CombineProgram", "vs_fullscreen.bin", "fs_bloom.bin"); } BloomRenderer::~BloomRenderer() diff --git a/Engine/Source/Runtime/Rendering/DebugRenderer.cpp b/Engine/Source/Runtime/Rendering/DebugRenderer.cpp index a5b0c446..5cd95e82 100644 --- a/Engine/Source/Runtime/Rendering/DebugRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/DebugRenderer.cpp @@ -12,19 +12,17 @@ namespace engine void DebugRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_debug"); pShaderVariantCollectionsComponent->AddShader("fs_debug"); - GetRenderContext()->CreateProgram("DebugProgram", "vs_debug.bin", "fs_debug.bin"); bgfx::setViewName(GetViewID(), "DebugRenderer"); } void DebugRenderer::LoadShaders() { - + GetRenderContext()->CreateProgram("DebugProgram", "vs_debug.bin", "fs_debug.bin"); } void DebugRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) diff --git a/Engine/Source/Runtime/Rendering/ImGuiRenderer.cpp b/Engine/Source/Runtime/Rendering/ImGuiRenderer.cpp index 83a39f47..c693f409 100644 --- a/Engine/Source/Runtime/Rendering/ImGuiRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/ImGuiRenderer.cpp @@ -22,13 +22,13 @@ void ImGuiRenderer::Init() } GetRenderContext()->CreateUniform("s_tex", bgfx::UniformType::Sampler); - GetRenderContext()->CreateProgram("ImGuiProgram", "vs_imgui.bin", "fs_imgui.bin"); bgfx::setViewName(GetViewID(), "ImGuiRenderer"); } void ImGuiRenderer::LoadShaders() { + GetRenderContext()->CreateProgram("ImGuiProgram", "vs_imgui.bin", "fs_imgui.bin"); } ImGuiRenderer::~ImGuiRenderer() diff --git a/Engine/Source/Runtime/Rendering/PBRSkyRenderer.cpp b/Engine/Source/Runtime/Rendering/PBRSkyRenderer.cpp index 87c3b297..55bd2802 100644 --- a/Engine/Source/Runtime/Rendering/PBRSkyRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/PBRSkyRenderer.cpp @@ -49,8 +49,7 @@ constexpr uint16_t ScatteringOrders = 6; void PBRSkyRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_atmSkyBox"); pShaderVariantCollectionsComponent->AddShader("fs_PrecomputedAtmosphericScattering_LUT"); @@ -62,18 +61,6 @@ void PBRSkyRenderer::Init() pShaderVariantCollectionsComponent->AddShader("cs_ComputeIndirectIrradiance"); pShaderVariantCollectionsComponent->AddShader("cs_ComputeMultipleScattering"); - SkyComponent* pSkyComponent = m_pCurrentSceneWorld->GetSkyComponent(m_pCurrentSceneWorld->GetSkyEntity()); - - GetRenderContext()->CreateProgram(ProgramAtmosphericScatteringLUT, "vs_atmSkyBox.bin", "fs_PrecomputedAtmosphericScattering_LUT.bin"); - GetRenderContext()->CreateProgram(ProgramSingleScatteringRayMarching, "vs_atmSkyBox.bin", "fs_SingleScattering_RayMarching.bin"); - - GetRenderContext()->CreateProgram(ProgramComputeTransmittance, "cs_ComputeTransmittance.bin"); - GetRenderContext()->CreateProgram(ProgramComputeDirectIrradiance, "cs_ComputeDirectIrradiance.bin"); - GetRenderContext()->CreateProgram(ProgramComputeSingleScattering, "cs_ComputeSingleScattering.bin"); - GetRenderContext()->CreateProgram(ProgramComputeScatteringDensity, "cs_ComputeScatteringDensity.bin"); - GetRenderContext()->CreateProgram(ProgramComputeIndirectIrradiance, "cs_ComputeIndirectIrradiance.bin"); - GetRenderContext()->CreateProgram(ProgramComputeMultipleScattering, "cs_ComputeMultipleScattering.bin"); - GetRenderContext()->CreateTexture(TextureTransmittance, TRANSMITTANCE_TEXTURE_WIDTH, TRANSMITTANCE_TEXTURE_HEIGHT, 1, bgfx::TextureFormat::RGBA32F, FlagTexture2D); GetRenderContext()->CreateTexture(TextureIrradiance, IRRADIANCE_TEXTURE_WIDTH, IRRADIANCE_TEXTURE_HEIGHT, 1, @@ -101,7 +88,15 @@ void PBRSkyRenderer::Init() void PBRSkyRenderer::LoadShaders() { + GetRenderContext()->CreateProgram(ProgramAtmosphericScatteringLUT, "vs_atmSkyBox.bin", "fs_PrecomputedAtmosphericScattering_LUT.bin"); + GetRenderContext()->CreateProgram(ProgramSingleScatteringRayMarching, "vs_atmSkyBox.bin", "fs_SingleScattering_RayMarching.bin"); + GetRenderContext()->CreateProgram(ProgramComputeTransmittance, "cs_ComputeTransmittance.bin"); + GetRenderContext()->CreateProgram(ProgramComputeDirectIrradiance, "cs_ComputeDirectIrradiance.bin"); + GetRenderContext()->CreateProgram(ProgramComputeSingleScattering, "cs_ComputeSingleScattering.bin"); + GetRenderContext()->CreateProgram(ProgramComputeScatteringDensity, "cs_ComputeScatteringDensity.bin"); + GetRenderContext()->CreateProgram(ProgramComputeIndirectIrradiance, "cs_ComputeIndirectIrradiance.bin"); + GetRenderContext()->CreateProgram(ProgramComputeMultipleScattering, "cs_ComputeMultipleScattering.bin"); } void PBRSkyRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) diff --git a/Engine/Source/Runtime/Rendering/ParticleRenderer.cpp b/Engine/Source/Runtime/Rendering/ParticleRenderer.cpp index 73c7270e..d60a1198 100644 --- a/Engine/Source/Runtime/Rendering/ParticleRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/ParticleRenderer.cpp @@ -9,8 +9,7 @@ namespace engine { void ParticleRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); // pShaderVariantCollectionsComponent->AddShader(""); // pShaderVariantCollectionsComponent->AddShader(""); diff --git a/Engine/Source/Runtime/Rendering/PostProcessRenderer.cpp b/Engine/Source/Runtime/Rendering/PostProcessRenderer.cpp index b4ebb888..70a46735 100644 --- a/Engine/Source/Runtime/Rendering/PostProcessRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/PostProcessRenderer.cpp @@ -7,22 +7,20 @@ namespace engine void PostProcessRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_fullscreen"); pShaderVariantCollectionsComponent->AddShader("fs_PBR_postProcessing"); GetRenderContext()->CreateUniform("s_lightingColor", bgfx::UniformType::Sampler); GetRenderContext()->CreateUniform("u_gamma", bgfx::UniformType::Vec4); - GetRenderContext()->CreateProgram("PostProcessProgram", "vs_fullscreen.bin", "fs_PBR_postProcessing.bin"); bgfx::setViewName(GetViewID(), "PostProcessRenderer"); } void PostProcessRenderer::LoadShaders() { - + GetRenderContext()->CreateProgram("PostProcessProgram", "vs_fullscreen.bin", "fs_PBR_postProcessing.bin"); } PostProcessRenderer::~PostProcessRenderer() diff --git a/Engine/Source/Runtime/Rendering/SkeletonRenderer.cpp b/Engine/Source/Runtime/Rendering/SkeletonRenderer.cpp index 539654e5..89623fbc 100644 --- a/Engine/Source/Runtime/Rendering/SkeletonRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/SkeletonRenderer.cpp @@ -56,19 +56,17 @@ void TraverseBone(const cd::Bone& bone, const cd::SceneDatabase* pSceneDatabase, void SkeletonRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_AABB"); pShaderVariantCollectionsComponent->AddShader("fs_AABB"); - GetRenderContext()->CreateProgram("SkeletonProgram", "vs_AABB.bin", "fs_AABB.bin"); bgfx::setViewName(GetViewID(), "SkeletonRenderer"); } void SkeletonRenderer::LoadShaders() { - + GetRenderContext()->CreateProgram("SkeletonProgram", "vs_AABB.bin", "fs_AABB.bin"); } void SkeletonRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) diff --git a/Engine/Source/Runtime/Rendering/SkyboxRenderer.cpp b/Engine/Source/Runtime/Rendering/SkyboxRenderer.cpp index 2e2809f6..23c90ccd 100644 --- a/Engine/Source/Runtime/Rendering/SkyboxRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/SkyboxRenderer.cpp @@ -21,8 +21,7 @@ constexpr uint64_t renderState = BGFX_STATE_WRITE_MASK | BGFX_STATE_CULL_CCW | B void SkyboxRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_skybox"); pShaderVariantCollectionsComponent->AddShader("fs_skybox"); @@ -31,14 +30,13 @@ void SkyboxRenderer::Init() GetRenderContext()->CreateUniform(skyboxSampler, bgfx::UniformType::Sampler); GetRenderContext()->CreateTexture(pSkyComponent->GetRadianceTexturePath().c_str(), sampleFalg); - GetRenderContext()->CreateProgram(skyboxShader, "vs_skybox.bin", "fs_skybox.bin"); bgfx::setViewName(GetViewID(), "SkyboxRenderer"); } void SkyboxRenderer::LoadShaders() { - + GetRenderContext()->CreateProgram(skyboxShader, "vs_skybox.bin", "fs_skybox.bin"); } void SkyboxRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) diff --git a/Engine/Source/Runtime/Rendering/TerrainRenderer.cpp b/Engine/Source/Runtime/Rendering/TerrainRenderer.cpp index 821c90a4..5f6ff12c 100644 --- a/Engine/Source/Runtime/Rendering/TerrainRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/TerrainRenderer.cpp @@ -54,15 +54,13 @@ constexpr uint64_t defaultRenderingState = BGFX_STATE_WRITE_MASK | BGFX_STATE_MS void TerrainRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_terrain"); pShaderVariantCollectionsComponent->AddShader("fs_terrain"); SkyComponent* pSkyComponent = m_pCurrentSceneWorld->GetSkyComponent(m_pCurrentSceneWorld->GetSkyEntity()); - GetRenderContext()->CreateProgram("TerrainProgram", "vs_terrain.bin", "fs_terrain.bin"); GetRenderContext()->CreateUniform(snowSampler, bgfx::UniformType::Sampler); GetRenderContext()->CreateUniform(rockSampler, bgfx::UniformType::Sampler); GetRenderContext()->CreateUniform(grassSampler, bgfx::UniformType::Sampler); @@ -94,7 +92,7 @@ void TerrainRenderer::Init() void TerrainRenderer::LoadShaders() { - + GetRenderContext()->CreateProgram("TerrainProgram", "vs_terrain.bin", "fs_terrain.bin"); } void TerrainRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix) diff --git a/Engine/Source/Runtime/Rendering/WorldRenderer.cpp b/Engine/Source/Runtime/Rendering/WorldRenderer.cpp index d5405630..428ee55c 100644 --- a/Engine/Source/Runtime/Rendering/WorldRenderer.cpp +++ b/Engine/Source/Runtime/Rendering/WorldRenderer.cpp @@ -47,8 +47,7 @@ constexpr uint64_t defaultRenderingState = BGFX_STATE_WRITE_MASK | BGFX_STATE_MS void WorldRenderer::Init() { - const auto& shaderVariantCollectionsEntity = m_pCurrentSceneWorld->GetShaderVariantCollectionEntity(); - auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(shaderVariantCollectionsEntity); + auto* pShaderVariantCollectionsComponent = m_pCurrentSceneWorld->GetShaderVariantCollectionsComponent(m_pCurrentSceneWorld->GetShaderVariantCollectionEntity()); pShaderVariantCollectionsComponent->AddShader("vs_PBR"); pShaderVariantCollectionsComponent->AddShader("fs_PBR"); @@ -81,7 +80,7 @@ void WorldRenderer::Init() void WorldRenderer::LoadShaders() { - + // TODO : Transfer controling of shader in material to SVC. } void WorldRenderer::UpdateView(const float* pViewMatrix, const float* pProjectionMatrix)