Repository navigation
Conversation
When lighting is disabled on a pass (!srcPass->getLightingEnabled()) and the mesh does not provide vertex colours, FFPColour unconditionally assigned Vector4(1.0) (white) as the diffuse colour. Because FFPLighting is bypassed for unlit passes, unlit materials with non-black emissive colours rendered as constant white. Resolve ACT_SURFACE_EMISSIVE_COLOUR for unlit passes with non-black emissive colour and assign it directly in the fragment shader so unlit materials can specify flat emissive colours without requiring textures, vertex colours, or varying interpolators. Also add a unit test in RTShaderSystemTests verifying shader generation.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Use Cases
In games and real-time visualization, many self-illuminating objects must be rendered without being affected by scene lighting or shadows:
pass->setEmissive(colour)without needing to swap textures or rebuild vertex buffers.Problem
When lighting is disabled on a pass (
!srcPass->getLightingEnabled()) and the mesh does not provide vertex colours,FFPColour::addFunctionInvocationsunconditionally assignsVector4(1.0)(white) as the diffuse colour.Because
FFPLightingis bypassed for unlit passes, unlit materials with non-black emissive colours render as constant white. In RTSS there was previously no way to specify a flat unlit surface colour via pass properties without binding a texture or providing vertex colours.Solution
In
FFPColour::preAddToRenderState, check if the pass is unlit and has a non-black emissive colour:GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOURdirectly in the fragment shader when!mPSInputDiffuse(or in vertex shader only if output diffuse is required by another stage).Vector4(1.0).Lit passes and unlit passes with black emissive colour remain completely unaffected.
Tests
TEST_F(RTShaderSystem, UnlitEmissive)inTests/Components/RTShaderSystemTests.cppverifying shader generation for unlit emissive passes.