@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.
612 lines • 19.9 kB
JavaScript
// Do not edit.
import { ShaderStore } from "../Engines/shaderStore.js";
import "./ShadersInclude/prePassDeclaration.js";
import "./ShadersInclude/oitDeclaration.js";
import "./ShadersInclude/pbrUboDeclaration.js";
import "./ShadersInclude/pbrFragmentExtraDeclaration.js";
import "./ShadersInclude/lightUboDeclaration.js";
import "./ShadersInclude/pbrFragmentSamplersDeclaration.js";
import "./ShadersInclude/imageProcessingDeclaration.js";
import "./ShadersInclude/clipPlaneFragmentDeclaration.js";
import "./ShadersInclude/logDepthDeclaration.js";
import "./ShadersInclude/fogFragmentDeclaration.js";
import "./ShadersInclude/helperFunctions.js";
import "./ShadersInclude/subSurfaceScatteringFunctions.js";
import "./ShadersInclude/importanceSampling.js";
import "./ShadersInclude/pbrHelperFunctions.js";
import "./ShadersInclude/imageProcessingFunctions.js";
import "./ShadersInclude/shadowsFragmentFunctions.js";
import "./ShadersInclude/harmonicsFunctions.js";
import "./ShadersInclude/pbrDirectLightingSetupFunctions.js";
import "./ShadersInclude/pbrDirectLightingFalloffFunctions.js";
import "./ShadersInclude/pbrBRDFFunctions.js";
import "./ShadersInclude/hdrFilteringFunctions.js";
import "./ShadersInclude/pbrDirectLightingFunctions.js";
import "./ShadersInclude/pbrIBLFunctions.js";
import "./ShadersInclude/bumpFragmentMainFunctions.js";
import "./ShadersInclude/bumpFragmentFunctions.js";
import "./ShadersInclude/reflectionFunction.js";
import "./ShadersInclude/pbrBlockAlbedoOpacity.js";
import "./ShadersInclude/pbrBlockReflectivity.js";
import "./ShadersInclude/pbrBlockAmbientOcclusion.js";
import "./ShadersInclude/pbrBlockAlphaFresnel.js";
import "./ShadersInclude/pbrBlockAnisotropic.js";
import "./ShadersInclude/pbrBlockReflection.js";
import "./ShadersInclude/pbrBlockSheen.js";
import "./ShadersInclude/pbrBlockClearcoat.js";
import "./ShadersInclude/pbrBlockIridescence.js";
import "./ShadersInclude/pbrBlockSubSurface.js";
import "./ShadersInclude/clipPlaneFragment.js";
import "./ShadersInclude/pbrBlockNormalGeometric.js";
import "./ShadersInclude/bumpFragment.js";
import "./ShadersInclude/pbrBlockNormalFinal.js";
import "./ShadersInclude/depthPrePass.js";
import "./ShadersInclude/pbrBlockLightmapInit.js";
import "./ShadersInclude/pbrBlockGeometryInfo.js";
import "./ShadersInclude/pbrBlockReflectance0.js";
import "./ShadersInclude/pbrBlockReflectance.js";
import "./ShadersInclude/pbrBlockDirectLighting.js";
import "./ShadersInclude/lightFragment.js";
import "./ShadersInclude/pbrBlockFinalLitComponents.js";
import "./ShadersInclude/pbrBlockFinalUnlitComponents.js";
import "./ShadersInclude/pbrBlockFinalColorComposition.js";
import "./ShadersInclude/logDepthFragment.js";
import "./ShadersInclude/fogFragment.js";
import "./ShadersInclude/pbrBlockImageProcessing.js";
import "./ShadersInclude/pbrBlockPrePass.js";
import "./ShadersInclude/oitFragment.js";
import "./ShadersInclude/pbrDebug.js";
const name = "pbrPixelShader";
const shader = `
@fragment
fn main(input: FragmentInputs)->FragmentOutputs {
var albedoOpacityOut: albedoOpacityOutParams;
var albedoTexture: vec4f=textureSample(albedoSampler,albedoSamplerSampler,fragmentInputs.vAlbedoUV+uvOffset);
var baseWeightTexture: vec4f=textureSample(baseWeightSampler,baseWeightSamplerSampler,fragmentInputs.vBaseWeightUV+uvOffset);
var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset);
var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
albedoOpacityOut=albedoOpacityBlock(
uniforms.vAlbedoColor
,albedoTexture
,uniforms.vAlbedoInfos
,uniforms.baseWeight
,baseWeightTexture
,uniforms.vBaseWeightInfos
,opacityMap
,uniforms.vOpacityInfos
,detailColor
,uniforms.vDetailInfos
,decalColor
,uniforms.vDecalInfos
);var surfaceAlbedo: vec3f=albedoOpacityOut.surfaceAlbedo;var alpha: f32=albedoOpacityOut.alpha;
var aoOut: ambientOcclusionOutParams;
var ambientOcclusionColorMap: vec3f=textureSample(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb;
aoOut=ambientOcclusionBlock(
ambientOcclusionColorMap,
uniforms.vAmbientInfos
);
var diffuseBase: vec3f= vec3f(1.,1.,1.);
var baseColor: vec3f=surfaceAlbedo;var reflectivityOut: reflectivityOutParams;
var surfaceMetallicOrReflectivityColorMap: vec4f=textureSample(reflectivitySampler,reflectivitySamplerSampler,fragmentInputs.vReflectivityUV+uvOffset);var baseReflectivity: vec4f=surfaceMetallicOrReflectivityColorMap;
surfaceMetallicOrReflectivityColorMap=toLinearSpaceVec4(surfaceMetallicOrReflectivityColorMap);
surfaceMetallicOrReflectivityColorMap=vec4f(surfaceMetallicOrReflectivityColorMap.rgb*uniforms.vReflectivityInfos.y,surfaceMetallicOrReflectivityColorMap.a);
var microSurfaceTexel: vec4f=textureSample(microSurfaceSampler,microSurfaceSamplerSampler,fragmentInputs.vMicroSurfaceSamplerUV+uvOffset)*uniforms.vMicroSurfaceSamplerInfos.y;
var metallicReflectanceFactors: vec4f=uniforms.vMetallicReflectanceFactors;
var reflectanceFactorsMap: vec4f=textureSample(reflectanceSampler,reflectanceSamplerSampler,fragmentInputs.vReflectanceUV+uvOffset);
reflectanceFactorsMap=toLinearSpaceVec4(reflectanceFactorsMap);
metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*reflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
var metallicReflectanceFactorsMap: vec4f=textureSample(metallicReflectanceSampler,metallicReflectanceSamplerSampler,fragmentInputs.vMetallicReflectanceUV+uvOffset);
metallicReflectanceFactorsMap=toLinearSpaceVec4(metallicReflectanceFactorsMap);
metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*metallicReflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
reflectivityOut=reflectivityBlock(
uniforms.vReflectivityColor
,surfaceAlbedo
,metallicReflectanceFactors
,uniforms.vReflectivityInfos
,surfaceMetallicOrReflectivityColorMap
,aoOut.ambientOcclusionColor
,microSurfaceTexel
,detailColor
,uniforms.vDetailInfos
);var microSurface: f32=reflectivityOut.microSurface;var roughness: f32=reflectivityOut.roughness;
surfaceAlbedo=reflectivityOut.surfaceAlbedo;
aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
var alphaFresnelOut: alphaFresnelOutParams;alphaFresnelOut=alphaFresnelBlock(
normalW,
viewDirectionW,
alpha,
microSurface
);alpha=alphaFresnelOut.alpha;
var anisotropicOut: anisotropicOutParams;
var anisotropyMapData: vec3f=textureSample(anisotropySampler,anisotropySamplerSampler,fragmentInputs.vAnisotropyUV+uvOffset).rgb*uniforms.vAnisotropyInfos.y;
anisotropicOut=anisotropicBlock(
uniforms.vAnisotropy,
roughness,
anisotropyMapData,
TBN,
normalW,
viewDirectionW
);
var reflectionOut: reflectionOutParams;
reflectionOut=reflectionBlock(
fragmentInputs.vPositionW
,normalW
,alphaG
,uniforms.vReflectionMicrosurfaceInfos
,uniforms.vReflectionInfos
,uniforms.vReflectionColor
,anisotropicOut
,NdotVUnclamped
,roughness
,reflectionSampler
,reflectionSamplerSampler
,fragmentInputs.vEnvironmentIrradiance
,uniforms.reflectionMatrix
,irradianceSampler
,irradianceSamplerSampler
,reflectionLowSampler
,reflectionLowSamplerSampler
,reflectionHighSampler
,reflectionHighSamplerSampler
,uniforms.vReflectionFilteringInfo
,icdfSampler
,icdfSamplerSampler
);
var sheenOut: sheenOutParams;
var sheenMapData: vec4f=textureSample(sheenSampler,sheenSamplerSampler,fragmentInputs.vSheenUV+uvOffset);
var sheenMapRoughnessData: vec4f=textureSample(sheenRoughnessSampler,sheenRoughnessSamplerSampler,fragmentInputs.vSheenRoughnessUV+uvOffset)*uniforms.vSheenInfos.w;
sheenOut=sheenBlock(
uniforms.vSheenColor
,uniforms.vSheenRoughness
,sheenMapRoughnessData
,roughness
,sheenMapData
,uniforms.vSheenInfos.y
,reflectance
,baseColor
,surfaceAlbedo
,NdotV
,environmentBrdf
,AARoughnessFactors
,uniforms.vReflectionMicrosurfaceInfos
,uniforms.vReflectionInfos
,uniforms.vReflectionColor
,uniforms.vLightingIntensity
,reflectionSampler
,reflectionSamplerSampler
,reflectionOut.reflectionCoords
,NdotVUnclamped
,reflectionLowSampler
,reflectionLowSamplerSampler
,reflectionHighSampler
,reflectionHighSamplerSampler
,vReflectionFilteringInfo
,seo
,eho
);
surfaceAlbedo=sheenOut.surfaceAlbedo;
var clearCoatMapData: vec2f=textureSample(clearCoatSampler,clearCoatSamplerSampler,fragmentInputs.vClearCoatUV+uvOffset).rg*uniforms.vClearCoatInfos.y;
var iridescenceOut: iridescenceOutParams;
var iridescenceMapData: vec2f=textureSample(iridescenceSampler,iridescenceSamplerSampler,fragmentInputs.vIridescenceUV+uvOffset).rg*uniforms.vIridescenceInfos.y;
var iridescenceThicknessMapData: vec2f=textureSample(iridescenceThicknessSampler,iridescenceThicknessSamplerSampler,fragmentInputs.vIridescenceThicknessUV+uvOffset).rg*uniforms.vIridescenceInfos.w;
iridescenceOut=iridescenceBlock(
uniforms.vIridescenceParams
,NdotV
,specularEnvironmentR0
,iridescenceMapData
,iridescenceThicknessMapData
,NdotVUnclamped
,uniforms.vClearCoatParams
,clearCoatMapData
);var iridescenceIntensity: f32=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
var clearcoatOut: clearcoatOutParams;
var clearCoatMapRoughnessData: vec4f=textureSample(clearCoatRoughnessSampler,clearCoatRoughnessSamplerSampler,fragmentInputs.vClearCoatRoughnessUV+uvOffset)*uniforms.vClearCoatInfos.w;
var clearCoatTintMapData: vec4f=textureSample(clearCoatTintSampler,clearCoatTintSamplerSampler,fragmentInputs.vClearCoatTintUV+uvOffset);
var clearCoatBumpMapData: vec4f=textureSample(clearCoatBumpSampler,clearCoatBumpSamplerSampler,fragmentInputs.vClearCoatBumpUV+uvOffset);
clearcoatOut=clearcoatBlock(
fragmentInputs.vPositionW
,geometricNormalW
,viewDirectionW
,uniforms.vClearCoatParams
,clearCoatMapRoughnessData
,specularEnvironmentR0
,clearCoatMapData
,uniforms.vClearCoatTintParams
,uniforms.clearCoatColorAtDistance
,uniforms.vClearCoatRefractionParams
,clearCoatTintMapData
,uniforms.vClearCoatBumpInfos
,clearCoatBumpMapData
,fragmentInputs.vClearCoatBumpUV
,mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2)
,uniforms.vClearCoatTangentSpaceParams
,uniforms.normalMatrix
,faceNormal
,uniforms.vReflectionMicrosurfaceInfos
,uniforms.vReflectionInfos
,uniforms.vReflectionColor
,uniforms.vLightingIntensity
,reflectionSampler
,reflectionSamplerSampler
,reflectionLowSampler
,reflectionLowSamplerSampler
,reflectionHighSampler
,reflectionHighSamplerSampler
,uniforms.vReflectionFilteringInfo
,select(-1.,1.,fragmentInputs.frontFacing)
);
clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
var subSurfaceOut: subSurfaceOutParams;
var thicknessMap: vec4f=textureSample(thicknessSampler,thicknessSamplerSampler,fragmentInputs.vThicknessUV+uvOffset);
var refractionIntensityMap: vec4f=textureSample(refractionIntensitySampler,refractionIntensitySamplerSampler,fragmentInputs.vRefractionIntensityUV+uvOffset);
var translucencyIntensityMap: vec4f=textureSample(translucencyIntensitySampler,translucencyIntensitySamplerSampler,fragmentInputs.vTranslucencyIntensityUV+uvOffset);
var translucencyColorMap: vec4f=textureSample(translucencyColorSampler,translucencyColorSamplerSampler,fragmentInputs.vTranslucencyColorUV+uvOffset);
translucencyColorMap=toLinearSpaceVec4(translucencyColorMap);
subSurfaceOut=subSurfaceBlock(
uniforms.vSubSurfaceIntensity
,uniforms.vThicknessParam
,uniforms.vTintColor
,normalW
,specularEnvironmentReflectance
,thicknessMap
,refractionIntensityMap
,translucencyIntensityMap
,uniforms.reflectionMatrix
,reflectionOut.irradianceVector
,reflectionSampler
,reflectionSamplerSampler
,vReflectionFilteringInfo
,icdfSampler
,icdfSamplerSampler
,irradianceSampler
,irradianceSamplerSampler
,surfaceAlbedo
,fragmentInputs.vPositionW
,viewDirectionW
,scene.view
,uniforms.vRefractionInfos
,uniforms.refractionMatrix
,uniforms.vRefractionMicrosurfaceInfos
,uniforms.vLightingIntensity
,alpha
,NdotVUnclamped
,roughness
,alphaG
,refractionSampler
,refractionSamplerSampler
,refractionLowSampler
,refractionLowSamplerSampler
,refractionHighSampler
,refractionHighSamplerSampler
,anisotropicOut
,uniforms.vRefractionFilteringInfo
,uniforms.vRefractionPosition
,uniforms.vRefractionSize
,dispersion
,uniforms.vDiffusionDistance
,uniforms.vTranslucencyColor
,translucencyColorMap
);
surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
alpha=subSurfaceOut.alpha;
subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
fragmentOutputs.color=finalColor;
if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+finalColor.rgb*finalColor.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-finalColor.a));} else {fragmentOutputs.backColor+=finalColor;}
}
`;
// Sideeffect
if (!ShaderStore.ShadersStoreWGSL[name]) {
ShaderStore.ShadersStoreWGSL[name] = shader;
}
/** @internal */
export const pbrPixelShaderWGSL = { name, shader };
//# sourceMappingURL=pbr.fragment.js.map