Skip to content

Commit 6706902

Browse files
Critsium-xyclaude
andcommitted
Path tracing: emission no longer requires an emission texture
The standard material hit group gated the entire emissive term on the has-emission-texture flag, so a material with emission enabled but no emission texture contributed nothing: the colour and strength were uploaded to the material buffer and then never read. Emission colour and strength now stand on their own and the texture, when present, modulates them. Measured on a box with emission (1.0, 0.3, 0.1) at strength 4 and no texture, mean colour over the box: path traced (0.3153, 0.3271, 0.3472) before, a cool cast from sky lighting alone, versus (0.5283, 0.4370, 0.3811) after, matching the (0.5052, 0.4251, 0.3670) the raster path produces for the same scene. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0157aNVZVYS69abA9d8xEQbb
1 parent ef18d06 commit 6706902

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

servers/rendering/renderer_rd/shaders/raytracing/scene_raytracing_raygen.glsl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,14 @@ void main() {
426426
float roughness = saturate(orm.g * mat.roughness);
427427
float metalness = saturate(orm.b * mat.metallic);
428428

429-
vec3 emissive = vec3(0.0);
429+
// The emission colour and strength stand on their own; an emission texture, when
430+
// present, modulates them. Gating the whole term on the texture flag would drop
431+
// emission entirely for any material that has it enabled but uses no texture.
432+
vec3 emissive = mat.emission_color * mat.emission_strength;
430433
if ((mat.flags & 2u) != 0u) {
431-
emissive = sample_material_texture(mat.emission_texture_idx, uv, mat.flags).rgb * mat.emission_color * mat.emission_strength;
432-
emissive *= scene_data_block.data.emissive_exposure_normalization;
434+
emissive *= sample_material_texture(mat.emission_texture_idx, uv, mat.flags).rgb;
433435
}
436+
emissive *= scene_data_block.data.emissive_exposure_normalization;
434437

435438
// Build MaterialResult.
436439
MaterialResult m;

0 commit comments

Comments
 (0)