Download

Where are Conversion codes from BaseColor to SceneColor at Lighting in Engine source?

I would like to read the source code of conversion from BaseColor to SceneColor in Lingting processes.
Where are these codes in Eingine source code ?
The codes are host-side codes wirtten in C. (.cpp) or GPU-side code in shader (.usf)?

I read code from FDeferredShadingSceneRenderer::Render ,but I didn’t find the places in souce code

Thank you.

Do you mean the entire process of how pixel colors get calculated? There are many steps involved. Lighting functions are evaluated in both the base pass for static lighting and the deferred lighting shaders for dynamic lights, then there is a long chain of post processes for everything from indirect specular to tone mapping. There are many individual shaders in the engine source.

BasePassPixelShader.usf is what processes the material inputs from the material node graph and sends the proper data to the GBuffer. MaterialTemplate.usf additionally acts as a kind of layer of indirection where certain inputs are clamped or transformed depending on user settings.

ShadingModels.usf contains the shader code to render the gbuffer information using all of the data sent from the base pass the gbuffer using the deferred rendering path. This means base color, specular, roughness, normal etc all get calculated using PBR lighting terms for each light, and a color is returned at the end of each shading model path.

DeferredShadingCommon.usf contains many common functions and core lighting calculations that decided how brightness and other things are integrated as well as space conversion formulas.

Start from these three and by following the breadcrumbs you can learn quite a bit about the rendering pipeline. There are additional tone mapping steps that further alter the color that aren’t in these files and I am not sure where they are located since I haven’t looked for them yet. If anybody has some insight into those I would be interested as well.

There are also lots of additional code paths such as skylighting in both static and dynamic forms and reflection captures etc that also end up contributing, but for the most part all those paths do their best to emulate the raw behavior of the shading models in the shadingmodels.usf file so I wouldn’t say you need to understand all of the them to get a grasp of the basecolor -> scene color path.