* Add postLightingColor property to materials This property can be used to modify the color computed in the lighting passes of the materials. That color is blended with the computed color according to the postLightingBlending option (add, transparent or opaque). * Remove test * Update docs * Address code review comment * Switch postLightingColor default blend mode to transparent
31 lines
928 B
GLSL
31 lines
928 B
GLSL
#if defined(MATERIAL_HAS_POST_LIGHTING_COLOR)
|
|
void blendPostLightingColor(const MaterialInputs material, inout vec4 color) {
|
|
#if defined(POST_LIGHTING_BLEND_MODE_OPAQUE)
|
|
color = material.postLightingColor;
|
|
#elif defined(POST_LIGHTING_BLEND_MODE_TRANSPARENT)
|
|
color = material.postLightingColor + color * (1.0 - material.postLightingColor.a);
|
|
#elif defined(POST_LIGHTING_BLEND_MODE_ADD)
|
|
color += material.postLightingColor;
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
void main() {
|
|
// See shading_parameters.fs
|
|
// Computes global variables we need to evaluate material and lighting
|
|
computeShadingParams();
|
|
|
|
// Initialize the inputs to sensible default values, see common_material.fs
|
|
MaterialInputs inputs;
|
|
initMaterial(inputs);
|
|
|
|
// Invoke user code
|
|
material(inputs);
|
|
|
|
fragColor = evaluateMaterial(inputs);
|
|
|
|
#if defined(MATERIAL_HAS_POST_LIGHTING_COLOR)
|
|
blendPostLightingColor(inputs, fragColor);
|
|
#endif
|
|
}
|