@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.
607 lines • 17.7 kB
JavaScript
// Do not edit.
import { ShaderStore } from "../Engines/shaderStore.js";
import "./ShadersInclude/prePassDeclaration.js";
import "./ShadersInclude/oitDeclaration.js";
import "./ShadersInclude/pbrFragmentDeclaration.js";
import "./ShadersInclude/pbrUboDeclaration.js";
import "./ShadersInclude/pbrFragmentExtraDeclaration.js";
import "./ShadersInclude/lightFragmentDeclaration.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 = `
precision highp float;
void main(void) {
albedoOpacityOutParams albedoOpacityOut;
vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
vec4 baseWeightTexture=texture2D(baseWeightSampler,vBaseWeightUV+uvOffset);
vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
albedoOpacityOut=albedoOpacityBlock(
vAlbedoColor
,albedoTexture
,vAlbedoInfos
,baseWeight
,baseWeightTexture
,vBaseWeightInfos
,opacityMap
,vOpacityInfos
,detailColor
,vDetailInfos
,decalColor
,vDecalInfos
);vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha;
ambientOcclusionOutParams aoOut;
vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
aoOut=ambientOcclusionBlock(
ambientOcclusionColorMap,
vAmbientInfos
);
vec3 diffuseBase=vec3(1.,1.,1.);
vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut;
vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
reflectivityOut=reflectivityBlock(
vReflectivityColor
,surfaceAlbedo
,metallicReflectanceFactors
,vReflectivityInfos
,surfaceMetallicOrReflectivityColorMap
,aoOut.ambientOcclusionColor
,microSurfaceTexel
,detailColor
,vDetailInfos
);float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;
surfaceAlbedo=reflectivityOut.surfaceAlbedo;
aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
alphaFresnelOutParams alphaFresnelOut;alphaFresnelOut=alphaFresnelBlock(
normalW,
viewDirectionW,
alpha,
microSurface
);alpha=alphaFresnelOut.alpha;
anisotropicOutParams anisotropicOut;
vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
anisotropicOut=anisotropicBlock(
vAnisotropy,
roughness,
anisotropyMapData,
TBN,
normalW,
viewDirectionW
);
reflectionOutParams reflectionOut;
reflectionOut=reflectionBlock(
vPositionW
,normalW
,alphaG
,vReflectionMicrosurfaceInfos
,vReflectionInfos
,vReflectionColor
,anisotropicOut
,NdotVUnclamped
,roughness
,reflectionSampler
,vEnvironmentIrradiance
,reflectionMatrix
,irradianceSampler
,reflectionSamplerLow
,reflectionSamplerHigh
,vReflectionFilteringInfo
,icdfSampler
);
sheenOutParams sheenOut;
vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
sheenOut=sheenBlock(
vSheenColor
,vSheenRoughness
,sheenMapRoughnessData
,roughness
,sheenMapData
,vSheenInfos.y
,reflectance
,baseColor
,surfaceAlbedo
,NdotV
,environmentBrdf
,AARoughnessFactors
,vReflectionMicrosurfaceInfos
,vReflectionInfos
,vReflectionColor
,vLightingIntensity
,reflectionSampler
,reflectionOut.reflectionCoords
,NdotVUnclamped
,reflectionSamplerLow
,reflectionSamplerHigh
,vReflectionFilteringInfo
,seo
,eho
);
surfaceAlbedo=sheenOut.surfaceAlbedo;
vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
iridescenceOutParams iridescenceOut;
vec2 iridescenceMapData=texture2D(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
vec2 iridescenceThicknessMapData=texture2D(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
iridescenceOut=iridescenceBlock(
vIridescenceParams
,NdotV
,specularEnvironmentR0
,iridescenceMapData
,iridescenceThicknessMapData
,NdotVUnclamped
,vClearCoatParams
,clearCoatMapData
);float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
clearcoatOutParams clearcoatOut;
vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
clearcoatOut=clearcoatBlock(
vPositionW
,geometricNormalW
,viewDirectionW
,vClearCoatParams
,clearCoatMapRoughnessData
,specularEnvironmentR0
,clearCoatMapData
,vClearCoatTintParams
,clearCoatColorAtDistance
,vClearCoatRefractionParams
,clearCoatTintMapData
,vClearCoatBumpInfos
,clearCoatBumpMapData
,vClearCoatBumpUV
,vTBN
,vClearCoatTangentSpaceParams
,normalMatrix
,faceNormal
,vReflectionMicrosurfaceInfos
,vReflectionInfos
,vReflectionColor
,vLightingIntensity
,reflectionSampler
,reflectionSamplerLow
,reflectionSamplerHigh
,vReflectionFilteringInfo
,(gl_FrontFacing ? 1. : -1.)
);
clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
subSurfaceOutParams subSurfaceOut;
vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
vec4 translucencyColorMap=texture2D(translucencyColorSampler,vTranslucencyColorUV+uvOffset);
translucencyColorMap=toLinearSpace(translucencyColorMap);
subSurfaceOut=subSurfaceBlock(
vSubSurfaceIntensity
,vThicknessParam
,vTintColor
,normalW
,specularEnvironmentReflectance
,thicknessMap
,refractionIntensityMap
,translucencyIntensityMap
,reflectionMatrix
,reflectionOut.irradianceVector
,reflectionSampler
,vReflectionFilteringInfo
,icdfSampler
,irradianceSampler
,surfaceAlbedo
,vPositionW
,viewDirectionW
,view
,vRefractionInfos
,refractionMatrix
,vRefractionMicrosurfaceInfos
,vLightingIntensity
,alpha
,NdotVUnclamped
,roughness
,alphaG
,refractionSampler
,refractionSamplerLow
,refractionSamplerHigh
,anisotropicOut
,vRefractionFilteringInfo
,vRefractionPosition
,vRefractionSize
,dispersion
,vDiffusionDistance
,vTranslucencyColor
,translucencyColorMap
);
surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
alpha=subSurfaceOut.alpha;
subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
gl_FragColor=finalColor;
if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
}
`;
// Sideeffect
if (!ShaderStore.ShadersStore[name]) {
ShaderStore.ShadersStore[name] = shader;
}
/** @internal */
export const pbrPixelShader = { name, shader };
//# sourceMappingURL=pbr.fragment.js.map