@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
122 lines • 4.29 kB
JavaScript
// Do not edit.
import { ShaderStore } from "../../Engines/shaderStore.js";
const name = "pbrBlockReflectivity";
const shader = `struct reflectivityOutParams
{microSurface: f32,
roughness: f32,
surfaceReflectivityColor: vec3f,
surfaceAlbedo: vec3f,
ambientOcclusionColor: vec3f,
metallicRoughness: vec2f,
surfaceMetallicColorMap: vec4f,
metallicF0: vec3f,
surfaceReflectivityColorMap: vec4f,
};
fn reflectivityBlock(
reflectivityColor: vec4f
,surfaceAlbedo: vec3f
,metallicReflectanceFactors: vec4f
,reflectivityInfos: vec3f
,surfaceMetallicOrReflectivityColorMap: vec4f
,ambientOcclusionColorIn: vec3f
,microSurfaceTexel: vec4f
,detailColor: vec4f
,vDetailInfos: vec4f
)->reflectivityOutParams
{var outParams: reflectivityOutParams;var microSurface: f32=reflectivityColor.a;var surfaceReflectivityColor: vec3f=reflectivityColor.rgb;
var metallicRoughness: vec2f=surfaceReflectivityColor.rg;
outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
var aoStoreInMetalMap: vec3f= vec3f(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
var detailRoughness: f32=mix(0.5,detailColor.b,vDetailInfos.w);var loLerp: f32=mix(0.,metallicRoughness.g,detailRoughness*2.);var hiLerp: f32=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
metallicRoughness.g*=microSurfaceTexel.r;
outParams.metallicRoughness=metallicRoughness;
microSurface=1.0-metallicRoughness.g;var baseColor: vec3f=surfaceAlbedo;
outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
var metallicF0: vec3f=metallicReflectanceFactors.rgb;
outParams.metallicF0=metallicF0;
outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0), vec3f(0.,0.,0.),metallicRoughness.r);surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
microSurface*=microSurfaceTexel.r;
microSurface=saturate(microSurface);var roughness: f32=1.-microSurface;outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.surfaceReflectivityColor=surfaceReflectivityColor;return outParams;}
`;
// Sideeffect
if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
ShaderStore.IncludesShadersStoreWGSL[name] = shader;
}
/** @internal */
export const pbrBlockReflectivityWGSL = { name, shader };
//# sourceMappingURL=pbrBlockReflectivity.js.map