Remove the redundant phong_2d reflection material
PiperOrigin-RevId: 965538926 Change-Id: I02a99016d5e69130e3827e898343b656f399ddfb
This commit is contained in:
committed by
Copybara-Service
parent
68918d4f4d
commit
11fa4a5b45
@@ -228,7 +228,6 @@ limitations under the License.
|
|||||||
"pbr_packed_transparent.filamat",
|
"pbr_packed_transparent.filamat",
|
||||||
"phong_2d.filamat",
|
"phong_2d.filamat",
|
||||||
"phong_2d_fade.filamat",
|
"phong_2d_fade.filamat",
|
||||||
"phong_2d_reflect.filamat",
|
|
||||||
"phong_2d_uv.filamat",
|
"phong_2d_uv.filamat",
|
||||||
"phong_2d_uv_fade.filamat",
|
"phong_2d_uv_fade.filamat",
|
||||||
"phong_2d_uv_reflect.filamat",
|
"phong_2d_uv_reflect.filamat",
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ var Module = {
|
|||||||
"assets/pbr_packed_transparent.filamat",
|
"assets/pbr_packed_transparent.filamat",
|
||||||
"assets/phong_2d_fade.filamat",
|
"assets/phong_2d_fade.filamat",
|
||||||
"assets/phong_2d.filamat",
|
"assets/phong_2d.filamat",
|
||||||
"assets/phong_2d_reflect.filamat",
|
|
||||||
"assets/phong_2d_uv_fade.filamat",
|
"assets/phong_2d_uv_fade.filamat",
|
||||||
"assets/phong_2d_uv.filamat",
|
"assets/phong_2d_uv.filamat",
|
||||||
"assets/phong_2d_uv_reflect.filamat",
|
"assets/phong_2d_uv_reflect.filamat",
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
// Copyright 2025 DeepMind Technologies Limited
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
material {
|
|
||||||
name : phong_2d_reflect,
|
|
||||||
shadingModel : specularGlossiness,
|
|
||||||
flipUV : false,
|
|
||||||
parameters : [
|
|
||||||
{ type : float4, name : BaseColorFactor },
|
|
||||||
{ type : float, name : SpecularFactor },
|
|
||||||
{ type : float, name : GlossinessFactor },
|
|
||||||
{ type : float, name : EmissiveFactor },
|
|
||||||
{ type : float, name : Reflectance },
|
|
||||||
{ type : float3, name : UvScale },
|
|
||||||
{ type : float3, name : UvOffset },
|
|
||||||
{ type : sampler2d, name : BaseColor },
|
|
||||||
{ type : sampler2d, name : Reflection }
|
|
||||||
],
|
|
||||||
variables : [
|
|
||||||
vertex_pos
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
vertex {
|
|
||||||
void materialVertex(inout MaterialVertexInputs material) {
|
|
||||||
material.vertex_pos = getPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fragment {
|
|
||||||
void material(inout MaterialInputs material) {
|
|
||||||
// Convert centered object-space positions [-1, 1] to standard [0, 1] UVs:
|
|
||||||
// * 0.5 scales [-1, 1] to [-0.5, 0.5]
|
|
||||||
// * -0.5 on Y flips the vertical axis (top of geom = V=0)
|
|
||||||
// * - vec2(0.5, 0.5) offsets origin to match OpenGL glTexGen conventions
|
|
||||||
vec2 uv = variable_vertex_pos.xy * vec2(0.5, -0.5) * materialParams.UvScale.xy - vec2(0.5, 0.5) + materialParams.UvOffset.xy;
|
|
||||||
vec2 screen_uv = gl_FragCoord.xy * getResolution().zw;
|
|
||||||
|
|
||||||
prepareMaterial(material);
|
|
||||||
material.baseColor = materialParams.BaseColorFactor;
|
|
||||||
material.baseColor *= texture(materialParams_BaseColor, uv);
|
|
||||||
material.specularColor = vec3(materialParams.SpecularFactor);
|
|
||||||
material.glossiness = materialParams.GlossinessFactor;
|
|
||||||
material.emissive = vec4(
|
|
||||||
materialParams.BaseColorFactor.rgb * materialParams.EmissiveFactor, 0.0);
|
|
||||||
|
|
||||||
// Apply reflection.
|
|
||||||
vec4 reflection = texture(materialParams_Reflection, screen_uv);
|
|
||||||
material.baseColor.rgb = mix(material.baseColor.rgb, reflection.rgb, materialParams.Reflectance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -195,10 +195,10 @@ MaterialManager::MaterialType MaterialManager::GetMaterialType(
|
|||||||
return ObjectManager::kPhong2dUv;
|
return ObjectManager::kPhong2dUv;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Reached only by a mesh without texture coordinates. Meshes are not planar
|
||||||
|
// reflectors, so reflectance has no reflect variant here.
|
||||||
if (material.color[3] < 1.0f) {
|
if (material.color[3] < 1.0f) {
|
||||||
return ObjectManager::kPhong2dFade;
|
return ObjectManager::kPhong2dFade;
|
||||||
} else if (material.reflectance > 0) {
|
|
||||||
return ObjectManager::kPhong2dReflect;
|
|
||||||
} else {
|
} else {
|
||||||
return ObjectManager::kPhong2d;
|
return ObjectManager::kPhong2d;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ ObjectManager::ObjectManager(filament::Engine* engine) : engine_(engine) {
|
|||||||
LoadMaterial(engine, "pbr_packed_reflect.filamat");
|
LoadMaterial(engine, "pbr_packed_reflect.filamat");
|
||||||
materials_[kPhong2d] = LoadMaterial(engine, "phong_2d.filamat");
|
materials_[kPhong2d] = LoadMaterial(engine, "phong_2d.filamat");
|
||||||
materials_[kPhong2dFade] = LoadMaterial(engine, "phong_2d_fade.filamat");
|
materials_[kPhong2dFade] = LoadMaterial(engine, "phong_2d_fade.filamat");
|
||||||
materials_[kPhong2dReflect] =
|
|
||||||
LoadMaterial(engine, "phong_2d_reflect.filamat");
|
|
||||||
materials_[kPhong2dUv] = LoadMaterial(engine, "phong_2d_uv.filamat");
|
materials_[kPhong2dUv] = LoadMaterial(engine, "phong_2d_uv.filamat");
|
||||||
materials_[kPhong2dUvFade] = LoadMaterial(engine, "phong_2d_uv_fade.filamat");
|
materials_[kPhong2dUvFade] = LoadMaterial(engine, "phong_2d_uv_fade.filamat");
|
||||||
materials_[kPhong2dUvReflect] =
|
materials_[kPhong2dUvReflect] =
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ class ObjectManager {
|
|||||||
kPbrPackedReflect,
|
kPbrPackedReflect,
|
||||||
kPhong2d,
|
kPhong2d,
|
||||||
kPhong2dFade,
|
kPhong2dFade,
|
||||||
kPhong2dReflect,
|
|
||||||
kPhong2dUv,
|
kPhong2dUv,
|
||||||
kPhong2dUvFade,
|
kPhong2dUvFade,
|
||||||
kPhong2dUvReflect,
|
kPhong2dUvReflect,
|
||||||
|
|||||||
Reference in New Issue
Block a user