From 4929f2cd998ca83471ae5ec33d20ca210e75b791 Mon Sep 17 00:00:00 2001 From: Haroon Qureshi Date: Wed, 12 Aug 2026 12:07:16 -0700 Subject: [PATCH] Disable/revert recent refection changes. PiperOrigin-RevId: 963586393 Change-Id: I65449cfcae4d50664f87296fa69d1660adf60c91 --- src/render/filament/assets/phong_2d_reflect.mat | 9 ++------- src/render/filament/assets/phong_2d_uv_reflect.mat | 9 ++------- src/render/filament/assets/phong_color_reflect.mat | 9 ++------- src/render/filament/assets/phong_cube_reflect.mat | 9 ++------- src/render/filament/core/material_manager.cc | 10 ---------- 5 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/render/filament/assets/phong_2d_reflect.mat b/src/render/filament/assets/phong_2d_reflect.mat index ab77a5fc..bbf7ba46 100644 --- a/src/render/filament/assets/phong_2d_reflect.mat +++ b/src/render/filament/assets/phong_2d_reflect.mat @@ -15,7 +15,6 @@ material { name : phong_2d_reflect, shadingModel : specularGlossiness, - postLightingBlending : add, flipUV : false, parameters : [ { type : float4, name : BaseColorFactor }, @@ -52,12 +51,8 @@ fragment { material.emissive = vec4( materialParams.BaseColorFactor.rgb * materialParams.EmissiveFactor, 0.0); - // The reflection is radiance arriving from the mirror direction, so it is - // weighted by the Fresnel term and added after lighting. Reflectance is - // the reflectivity at normal incidence; grazing angles approach a mirror. + // Apply reflection. vec4 reflection = texture(materialParams_Reflection, screen_uv); - float f0 = materialParams.Reflectance; - float fresnel = f0 + (1.0 - f0) * pow(1.0 - getNdotV(), 5.0); - material.postLightingColor = vec4(reflection.rgb * fresnel, 0.0); + material.baseColor.rgb = mix(material.baseColor.rgb, reflection.rgb, materialParams.Reflectance); } } diff --git a/src/render/filament/assets/phong_2d_uv_reflect.mat b/src/render/filament/assets/phong_2d_uv_reflect.mat index 15456c77..4160167d 100644 --- a/src/render/filament/assets/phong_2d_uv_reflect.mat +++ b/src/render/filament/assets/phong_2d_uv_reflect.mat @@ -15,7 +15,6 @@ material { name : phong_2d_uv_reflect, shadingModel : specularGlossiness, - postLightingBlending : add, flipUV : false, parameters : [ { type : float4, name : BaseColorFactor }, @@ -44,12 +43,8 @@ fragment { material.emissive = vec4( materialParams.BaseColorFactor.rgb * materialParams.EmissiveFactor, 0.0); - // The reflection is radiance arriving from the mirror direction, so it is - // weighted by the Fresnel term and added after lighting. Reflectance is - // the reflectivity at normal incidence; grazing angles approach a mirror. + // Apply reflection. vec4 reflection = texture(materialParams_Reflection, screen_uv); - float f0 = materialParams.Reflectance; - float fresnel = f0 + (1.0 - f0) * pow(1.0 - getNdotV(), 5.0); - material.postLightingColor = vec4(reflection.rgb * fresnel, 0.0); + material.baseColor.rgb = mix(material.baseColor.rgb, reflection.rgb, materialParams.Reflectance); } } diff --git a/src/render/filament/assets/phong_color_reflect.mat b/src/render/filament/assets/phong_color_reflect.mat index 81b715c4..48a9bfde 100644 --- a/src/render/filament/assets/phong_color_reflect.mat +++ b/src/render/filament/assets/phong_color_reflect.mat @@ -15,7 +15,6 @@ material { name : phong_color_reflect, shadingModel : specularGlossiness, - postLightingBlending : add, parameters : [ { type : float4, name : BaseColorFactor }, { type : float, name : SpecularFactor }, @@ -37,12 +36,8 @@ fragment { material.emissive = vec4( materialParams.BaseColorFactor.rgb * materialParams.EmissiveFactor, 0.0); - // The reflection is radiance arriving from the mirror direction, so it is - // weighted by the Fresnel term and added after lighting. Reflectance is - // the reflectivity at normal incidence; grazing angles approach a mirror. + // Apply reflection. vec4 reflection = texture(materialParams_Reflection, screen_uv); - float f0 = materialParams.Reflectance; - float fresnel = f0 + (1.0 - f0) * pow(1.0 - getNdotV(), 5.0); - material.postLightingColor = vec4(reflection.rgb * fresnel, 0.0); + material.baseColor.rgb = mix(material.baseColor.rgb, reflection.rgb, materialParams.Reflectance); } } diff --git a/src/render/filament/assets/phong_cube_reflect.mat b/src/render/filament/assets/phong_cube_reflect.mat index b4eb1100..98fe663b 100644 --- a/src/render/filament/assets/phong_cube_reflect.mat +++ b/src/render/filament/assets/phong_cube_reflect.mat @@ -15,7 +15,6 @@ material { name : phong_cube_reflect, shadingModel : specularGlossiness, - postLightingBlending : add, flipUV : false, parameters : [ { type : float4, name : BaseColorFactor }, @@ -51,12 +50,8 @@ fragment { material.emissive = vec4( materialParams.BaseColorFactor.rgb * materialParams.EmissiveFactor, 0.0); - // The reflection is radiance arriving from the mirror direction, so it is - // weighted by the Fresnel term and added after lighting. Reflectance is - // the reflectivity at normal incidence; grazing angles approach a mirror. + // Apply reflection. vec4 reflection = texture(materialParams_Reflection, screen_uv); - float f0 = materialParams.Reflectance; - float fresnel = f0 + (1.0 - f0) * pow(1.0 - getNdotV(), 5.0); - material.postLightingColor = vec4(reflection.rgb * fresnel, 0.0); + material.baseColor.rgb = mix(material.baseColor.rgb, reflection.rgb, materialParams.Reflectance); } } diff --git a/src/render/filament/core/material_manager.cc b/src/render/filament/core/material_manager.cc index e5e945cc..6d75c195 100644 --- a/src/render/filament/core/material_manager.cc +++ b/src/render/filament/core/material_manager.cc @@ -133,40 +133,30 @@ MaterialManager::MaterialType MaterialManager::GetMaterialType( } else if (material.orm_texture) { if (material.opacity_texture) { return ObjectManager::kPbrPackedTransparent; - } else if (material.reflectance > 0) { - return ObjectManager::kPbrPackedReflect; } else { return ObjectManager::kPbrPacked; } } else if (material.metallic_texture) { if (material.opacity_texture) { return ObjectManager::kPbrPackedTransparent; - } else if (material.reflectance > 0) { - return ObjectManager::kPbrReflect; } else { return ObjectManager::kPbr; } } else if (material.roughness_texture) { if (material.color[3] < 1.0f) { return ObjectManager::kPbrTransparent; - } else if (material.reflectance > 0) { - return ObjectManager::kPbrReflect; } else { return ObjectManager::kPbr; } } else if (material.metallic >= 0) { if (material.color[3] < 1.0f) { return ObjectManager::kPbrTransparent; - } else if (material.reflectance > 0) { - return ObjectManager::kPbrReflect; } else { return ObjectManager::kPbr; } } else if (material.roughness >= 0) { if (material.color[3] < 1.0f) { return ObjectManager::kPbrTransparent; - } else if (material.reflectance > 0) { - return ObjectManager::kPbrReflect; } else { return ObjectManager::kPbr; }