Loading files
// 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 : pbr_reflect,
shadingModel : lit,
postLightingBlending : add,
flipUV: false,
parameters : [
{ type : sampler2d, name : BaseColor },
{ type : sampler2d, name : Normal },
{ type : sampler2d, name : Occlusion },
{ type : sampler2d, name : Roughness },
{ type : sampler2d, name : Metallic },
{ type : sampler2d, name : Emissive },
{ type : float4, name : BaseColorFactor },
{ type : float, name : MetallicFactor },
{ type : float, name : RoughnessFactor },
{ type : float, name : EmissiveFactor },
{ type : float, name : Reflectance },
{ type : sampler2d, name : Reflection }
],
requires : [
uv0
]
}
fragment {
void material(inout MaterialInputs material) {
vec2 uv = getUV0();
vec2 screen_uv = gl_FragCoord.xy * getResolution().zw;
material.normal = texture(materialParams_Normal, uv).xyz * 2.0 - 1.0;
prepareMaterial(material);
material.baseColor = materialParams.BaseColorFactor;
material.baseColor *= texture(materialParams_BaseColor, uv);
material.ambientOcclusion = texture(materialParams_Occlusion, uv).r;
material.roughness = materialParams.RoughnessFactor;
material.roughness *= texture(materialParams_Roughness, uv).r;
material.metallic = materialParams.MetallicFactor;
material.metallic *= texture(materialParams_Metallic, uv).r;
material.emissive = texture(materialParams_Emissive, uv);
material.emissive.rgb *= materialParams.EmissiveFactor;
material.emissive.a = (1.0 - material.emissive.a) *
materialParams.EmissiveFactor;
// Planar reflection: radiance from the mirror direction, weighted by the
// Fresnel term and added after lighting. F0 is the material reflectance for
// dielectrics and the base color for metals, which reflect their own tint.
vec4 reflection = texture(materialParams_Reflection, screen_uv);
vec3 f0 = mix(vec3(materialParams.Reflectance), material.baseColor.rgb,
material.metallic);
vec3 fresnel = f0 + (1.0 - f0) * pow(1.0 - getNdotV(), 5.0);
material.postLightingColor = vec4(reflection.rgb * fresnel, 0.0);
}
}
a219e2fd9This file is pinned to the selected release. Download the original to open it in your design tool.