fragmentShaderForLighting method
Selects this material's fragment shader for the frame lighting state.
The radiance-layout variant wins over the shadow one: a shadow variant in the wrong layout would be handed a texture its sampler cannot read, while dropping the no-shadow variant only costs dead shadow code.
While a surface debug view may show (Lighting.surfaceDebugViews), a
shader from baseShaderLibrary gives way to its twin built with the
views, when the bundle has one.
Implementation
@override
gpu.Shader fragmentShaderForLighting(Lighting lighting) {
final shadow = lighting.shadowMap != null;
// The layout variant wins over the shadow one: a shadow variant in the
// wrong layout would be handed a texture its sampler cannot read, while
// dropping the shadow variant only loses the shadow term.
if (usesRadianceCubeVariant(lighting)) {
return shadow
? (_cubeShadowFragmentShader ?? _cubeFragmentShader!)
: _cubeFragmentShader!;
}
return shadow ? (_shadowFragmentShader ?? fragmentShader) : fragmentShader;
}