diff --git a/Assets/Shaders/ShinyHighlight_FS.glsl b/Assets/Shaders/ShinyHighlight_FS.glsl index be26f866..18f979fe 100644 --- a/Assets/Shaders/ShinyHighlight_FS.glsl +++ b/Assets/Shaders/ShinyHighlight_FS.glsl @@ -32,10 +32,11 @@ layout(location = 0) in struct vec2 uv; // location = 1 vec4 normal; // location = 2 vec4 worldPos; // location = 3 + vec3 worldNormal; // location = 4 } In; // material stuff -layout(location = 4) flat in struct +layout(location = 5) flat in struct { int materialIndex; uint eid; @@ -72,10 +73,11 @@ void main() { position = In.vertPos; normals = In.normal; - albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + albedo = vec4 (texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv).xyz, 1.0f); worldSpacePosition = In.worldPos; outEntityID = In2.eid; + lightLayerIndices = uvec4 (In2.lightLayerIndex, 0, 0, 1); // float vpHeight = float (In2.screenSpacePos.y) - MatProp.data[In2.materialIndex].highlightPosition; // bring the frame of reference to the object's screen space pos @@ -100,4 +102,6 @@ void main() } else objectVFX = vec4(0.0f, 0.0f, 0.0f, 1.0f); + + objectVFX.a = 1.0f; } \ No newline at end of file diff --git a/Assets/Shaders/ShinyHighlight_FS.shshaderb b/Assets/Shaders/ShinyHighlight_FS.shshaderb index 572f3b31..a3a6230d 100644 Binary files a/Assets/Shaders/ShinyHighlight_FS.shshaderb and b/Assets/Shaders/ShinyHighlight_FS.shshaderb differ diff --git a/Assets/Shaders/ShinyHighlight_VS.glsl b/Assets/Shaders/ShinyHighlight_VS.glsl index c0268737..483af1f0 100644 --- a/Assets/Shaders/ShinyHighlight_VS.glsl +++ b/Assets/Shaders/ShinyHighlight_VS.glsl @@ -17,6 +17,7 @@ layout(location = 0) out struct vec2 uv; // location = 1 vec4 normal; // location = 2 vec4 worldPos; // location = 3 + vec3 worldNormal; // location = 4 } Out; @@ -36,7 +37,7 @@ struct GenericData }; // material stuff -layout(location = 4) out struct +layout(location = 5) out struct { int materialIndex; uint eid; @@ -76,11 +77,13 @@ void main() // uvs for texturing in fragment shader Out.uv = aUV; - mat3 transposeInv = mat3 (transpose(inverse(modelViewMat))); + mat3 mvTransInv = mat3 (transpose(inverse(modelViewMat))); + mat3 modelTransInv = mat3 (transpose(inverse(worldTransform))); // normals are also in view space - Out.normal.rgb = transposeInv * aNormal.rgb; + Out.normal.rgb = mvTransInv * aNormal.rgb; Out.normal.rgb = normalize (Out.normal.rgb); + Out.worldNormal = normalize (modelTransInv * aNormal); // Get center of object in world position vec4 worldPos = vec4(worldTransform[3][0], worldTransform[3][1], worldTransform[3][2], 1.0f); diff --git a/Assets/Shaders/ShinyHighlight_VS.shshaderb b/Assets/Shaders/ShinyHighlight_VS.shshaderb index 98187085..95eac304 100644 Binary files a/Assets/Shaders/ShinyHighlight_VS.shshaderb and b/Assets/Shaders/ShinyHighlight_VS.shshaderb differ diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 54e5a1ff..999337ae 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -128,7 +128,7 @@ namespace SHADE SHFreetypeInstance::Init(); - //SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false); + SHAssetManager::CompileAsset("../../Assets/Shaders/DeferredComposite_CS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_FS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/ShadowMap_FS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/SSAO_CS.glsl", false); @@ -865,12 +865,13 @@ namespace SHADE // we need to wait for the device to finish using the graph first device->WaitIdle(); - auto const& EVENT_DATA = reinterpret_cast*>(eventPtr.get())->data; - auto* lightComp = SHComponentManager::GetComponent(EVENT_DATA->lightEntity); - std::string depthResourceName = "ShadowMap_Depth " + std::to_string(EVENT_DATA->lightEntity); - std::string shadowMapResourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity); + auto const& EVENT_DATA = reinterpret_cast*>(eventPtr.get())->data; + auto* lightComp = SHComponentManager::GetComponent(EVENT_DATA->lightEntity); + std::string depthResourceName = "ShadowMap_Depth " + std::to_string(EVENT_DATA->lightEntity); + std::string shadowMapResourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity); std::string shadowMapBlurredResourceName = "ShadowMap Blurred" + std::to_string(EVENT_DATA->lightEntity); - Handle companionSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS); + Handle gBufferWriteSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS); + Handle gBufferWriteVfxSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_VFX_SUBPASS); if (EVENT_DATA->generateRenderer) { @@ -929,7 +930,8 @@ namespace SHADE ); shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS, shadowMapDrawSubpass }); } - shadowMapDrawSubpass->SetCompanionSubpass(companionSubpass, shadowMapPipeline); // set companion subpass and pipeline + shadowMapDrawSubpass->AddCompanionSubpass(gBufferWriteSubpass, shadowMapPipeline); // set companion subpass and pipeline + shadowMapDrawSubpass->AddCompanionSubpass(gBufferWriteVfxSubpass, shadowMapPipeline); // set companion subpass and pipeline // add the shadow map and the blurred version to the lighting system uint32_t const NEW_SHADOW_MAP_INDEX = lightingSubSystem->AddShadowMap(renderGraph->GetRenderGraphResource(shadowMapBlurredResourceName), EVENT_DATA->lightEntity); diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp index 14a5d864..db78c5aa 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.cpp @@ -77,7 +77,7 @@ namespace SHADE , name { rhs.name } , viewport {rhs.viewport} , renderer {rhs.renderer} - , companionSubpass {rhs.companionSubpass} + , companionSubpasses {std::move (rhs.companionSubpasses)} , dummyPipelineLayout{rhs.dummyPipelineLayout} { @@ -115,7 +115,7 @@ namespace SHADE name = std::move(rhs.name); renderer = rhs.renderer; viewport = rhs.viewport; - companionSubpass = rhs.companionSubpass; + companionSubpasses = rhs.companionSubpasses; dummyPipelineLayout = rhs.dummyPipelineLayout; @@ -237,17 +237,19 @@ namespace SHADE BindInputDescriptorSets (commandBuffer, descMappings.at(SHPredefinedDescriptorTypes::RENDER_GRAPH_RESOURCE), frameIndex); - // If companion subpass is not a valid handle, render super batch normally - if (!companionSubpass.companion) + if (companionSubpasses.empty()) { // Draw all the batches superBatch->Draw(commandBuffer, frameIndex); } else { - // if not bind pipeline for companion and and execute draw command - commandBuffer->BindPipeline(companionSubpass.pipeline); - companionSubpass.companion->superBatch->Draw(commandBuffer, frameIndex, false); + for (auto& companion : companionSubpasses) + { + // if not bind pipeline for companion and and execute draw command + commandBuffer->BindPipeline(companion.pipeline); + companion.subpass->superBatch->Draw(commandBuffer, frameIndex, false); + } } } @@ -493,10 +495,11 @@ namespace SHADE subpassIndex = index; } - void SHSubpass::SetCompanionSubpass(Handle companion, Handle pipeline) noexcept + void SHSubpass::AddCompanionSubpass(Handle companion, Handle pipeline) noexcept { - companionSubpass.companion = companion; - companionSubpass.pipeline = pipeline; + companionSubpasses.push_back(CompanionSubpass{companion, pipeline}); + //companionSubpass.companion = companion; + //companionSubpass.pipeline = pipeline; } /***************************************************************************/ diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h index 1300ee2b..640ccb2d 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHSubpass.h @@ -33,7 +33,7 @@ namespace SHADE struct CompanionSubpass { // subpass whose data will be borrowed to draw - Handle companion; + Handle subpass; // Pipeline that will be used for all the draw calls from all batches of the companion subpass Handle pipeline; @@ -114,7 +114,8 @@ namespace SHADE //! Optional component to a companion subpass. If the subpass handle of this object //! is valid, the subpass will be drawn using this companion's data. - CompanionSubpass companionSubpass; + //CompanionSubpass companionSubpass; + std::vector companionSubpasses; private: /*-----------------------------------------------------------------------*/ @@ -165,7 +166,7 @@ namespace SHADE /*-----------------------------------------------------------------------*/ /* PUBLIC SETTERS AND GETTERS */ /*-----------------------------------------------------------------------*/ - void SetCompanionSubpass (Handle companion, Handle pipeline) noexcept; + void AddCompanionSubpass (Handle companion, Handle pipeline) noexcept; Handle GetParentNode(void) const noexcept; SHSubPassIndex GetIndex() const noexcept;