I’m making a project with stylized graphics, materials are made only using base colors and no textures. My problem is that I want to be able to use pure single color channel lights such as “R=1.0, G=0.0, B=0.0” and have those cast light on materials even if the base color does not have any value for that channel, such as a material with base color “R=0.0, G=1.0, B=1.0”.
The LightAccumulator code looks like this:
void LightAccumulator_AddSplit(inout FLightAccumulator In, float3 DiffuseTotalLight, float3 SpecularTotalLight, float3 ScatterableLight, float3 CommonMultiplier, const bool bNeedsSeparateSubsurfaceLightAccumulation)
{
...
In.TotalLightDiffuse += DiffuseTotalLight * CommonMultiplier;
...
}
Where the DiffuseTotalLight
is the “material base color” and the CommonMultiplier
is the “light color multiplied by intensity”. Currently the light with “R=1.0, G=0.0, B=0.0” would not affect the material without any R value since the shader calculation is done through multiplication.
I would like to change it to something like this instead:
In.TotalLightDiffuse += (DiffuseTotalLight + LightColor) * LightIntensity
That way the light color would be applied no matter what, like adding a hue to the material based on light color. However like I mentioned this is not possible since the LightColor
and LightIntensity
does not exist separately at this stage but are instead both baked into the CommonMultiplier
value. The CommonMultiplier
values are huge so just adding them to the DiffuseTotalLight
does not work.
I’ve tried looking through the code but I can’t figure out how the CommonMultiplier is calculated. If I knew how, I might be able to separate them in the LightAccumulator or modify the code so they are passed as two different fields instead.
I can see that the CommonMultiplier
is taken from the FDeferredLightData.Color
value in DeferredLightingCommon.AccumulateDynamicLighting()
, this struct is initialized using the LightDataUniforms.InitDeferredLightFromUniforms()
function and the Color
value is copied from DeferredLightUniforms.Color
. This is where my ush/c++ knowledge is lacking, I cannot figure out what the DeferredLightUniforms
even is and where its values comes from. Could anyone more knowledgeable enlighten me on this?
I would of course also be open to some other clever solution to my problem, if you have any ideas how it could be solved