123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- // 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/oitFragment.js";
- import "./ShadersInclude/pbrDebug.js";
- const name = "pbrPixelShader";
- const shader = `#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
- #extension GL_OES_standard_derivatives : enable
- #endif
- #ifdef LODBASEDMICROSFURACE
- #extension GL_EXT_shader_texture_lod : enable
- #endif
- #define CUSTOM_FRAGMENT_BEGIN
- #ifdef LOGARITHMICDEPTH
- #extension GL_EXT_frag_depth : enable
- #endif
- #include<prePassDeclaration>[SCENE_MRT_COUNT]
- precision highp float;
- #include<oitDeclaration>
- #ifndef FROMLINEARSPACE
- #define FROMLINEARSPACE
- #endif
- #include<__decl__pbrFragment>
- #include<pbrFragmentExtraDeclaration>
- #include<__decl__lightFragment>[0..maxSimultaneousLights]
- #include<pbrFragmentSamplersDeclaration>
- #include<imageProcessingDeclaration>
- #include<clipPlaneFragmentDeclaration>
- #include<logDepthDeclaration>
- #include<fogFragmentDeclaration>
- #include<helperFunctions>
- #include<subSurfaceScatteringFunctions>
- #include<importanceSampling>
- #include<pbrHelperFunctions>
- #include<imageProcessingFunctions>
- #include<shadowsFragmentFunctions>
- #include<harmonicsFunctions>
- #include<pbrDirectLightingSetupFunctions>
- #include<pbrDirectLightingFalloffFunctions>
- #include<pbrBRDFFunctions>
- #include<hdrFilteringFunctions>
- #include<pbrDirectLightingFunctions>
- #include<pbrIBLFunctions>
- #include<bumpFragmentMainFunctions>
- #include<bumpFragmentFunctions>
- #ifdef REFLECTION
- #include<reflectionFunction>
- #endif
- #define CUSTOM_FRAGMENT_DEFINITIONS
- #include<pbrBlockAlbedoOpacity>
- #include<pbrBlockReflectivity>
- #include<pbrBlockAmbientOcclusion>
- #include<pbrBlockAlphaFresnel>
- #include<pbrBlockAnisotropic>
- #include<pbrBlockReflection>
- #include<pbrBlockSheen>
- #include<pbrBlockClearcoat>
- #include<pbrBlockIridescence>
- #include<pbrBlockSubSurface>
- void main(void) {
- #define CUSTOM_FRAGMENT_MAIN_BEGIN
- #include<clipPlaneFragment>
- #include<pbrBlockNormalGeometric>
- #include<bumpFragment>
- #include<pbrBlockNormalFinal>
- albedoOpacityOutParams albedoOpacityOut;
- #ifdef ALBEDO
- vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
- #endif
- #ifdef OPACITY
- vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
- #endif
- #ifdef DECAL
- vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset);
- #endif
- albedoOpacityBlock(
- vAlbedoColor,
- #ifdef ALBEDO
- albedoTexture,
- vAlbedoInfos,
- #endif
- #ifdef OPACITY
- opacityMap,
- vOpacityInfos,
- #endif
- #ifdef DETAIL
- detailColor,
- vDetailInfos,
- #endif
- #ifdef DECAL
- decalColor,
- vDecalInfos,
- #endif
- albedoOpacityOut
- );vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha;
- #define CUSTOM_FRAGMENT_UPDATE_ALPHA
- #include<depthPrePass>
- #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
- ambientOcclusionOutParams aoOut;
- #ifdef AMBIENT
- vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
- #endif
- ambientOcclusionBlock(
- #ifdef AMBIENT
- ambientOcclusionColorMap,
- vAmbientInfos,
- #endif
- aoOut
- );
- #include<pbrBlockLightmapInit>
- #ifdef UNLIT
- vec3 diffuseBase=vec3(1.,1.,1.);
- #else
- vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut;
- #if defined(REFLECTIVITY)
- vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
- #ifndef METALLICWORKFLOW
- #ifdef REFLECTIVITY_GAMMA
- surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
- #endif
- surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
- #endif
- #endif
- #if defined(MICROSURFACEMAP)
- vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
- #endif
- #ifdef METALLICWORKFLOW
- vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
- #ifdef REFLECTANCE
- vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
- #ifdef REFLECTANCE_GAMMA
- reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
- #endif
- metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
- #endif
- #ifdef METALLIC_REFLECTANCE
- vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
- #ifdef METALLIC_REFLECTANCE_GAMMA
- metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
- #endif
- #ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
- metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
- #endif
- metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
- #endif
- #endif
- reflectivityBlock(
- vReflectivityColor,
- #ifdef METALLICWORKFLOW
- surfaceAlbedo,
- metallicReflectanceFactors,
- #endif
- #ifdef REFLECTIVITY
- vReflectivityInfos,
- surfaceMetallicOrReflectivityColorMap,
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- aoOut.ambientOcclusionColor,
- #endif
- #ifdef MICROSURFACEMAP
- microSurfaceTexel,
- #endif
- #ifdef DETAIL
- detailColor,
- vDetailInfos,
- #endif
- reflectivityOut
- );float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;
- #ifdef METALLICWORKFLOW
- surfaceAlbedo=reflectivityOut.surfaceAlbedo;
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
- #endif
- #ifdef ALPHAFRESNEL
- #if defined(ALPHATEST) || defined(ALPHABLEND)
- alphaFresnelOutParams alphaFresnelOut;alphaFresnelBlock(
- normalW,
- viewDirectionW,
- alpha,
- microSurface,
- alphaFresnelOut
- );alpha=alphaFresnelOut.alpha;
- #endif
- #endif
- #include<pbrBlockGeometryInfo>
- #ifdef ANISOTROPIC
- anisotropicOutParams anisotropicOut;
- #ifdef ANISOTROPIC_TEXTURE
- vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
- #endif
- anisotropicBlock(
- vAnisotropy,
- roughness,
- #ifdef ANISOTROPIC_TEXTURE
- anisotropyMapData,
- #endif
- TBN,
- normalW,
- viewDirectionW,
- anisotropicOut
- );
- #endif
- #ifdef REFLECTION
- reflectionOutParams reflectionOut;
- #ifndef USE_CUSTOM_REFLECTION
- reflectionBlock(
- vPositionW,
- normalW,
- alphaG,
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- #ifdef ANISOTROPIC
- anisotropicOut,
- #endif
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- NdotVUnclamped,
- #endif
- #ifdef LINEARSPECULARREFLECTION
- roughness,
- #endif
- reflectionSampler,
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
- vEnvironmentIrradiance,
- #endif
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- reflectionMatrix,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- irradianceSampler,
- #endif
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- reflectionOut
- );
- #else
- #define CUSTOM_REFLECTION
- #endif
- #endif
- #include<pbrBlockReflectance0>
- #ifdef SHEEN
- sheenOutParams sheenOut;
- #ifdef SHEEN_TEXTURE
- vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
- #endif
- #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
- vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
- #endif
- sheenBlock(
- vSheenColor,
- #ifdef SHEEN_ROUGHNESS
- vSheenRoughness,
- #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
- sheenMapRoughnessData,
- #endif
- #endif
- roughness,
- #ifdef SHEEN_TEXTURE
- sheenMapData,
- vSheenInfos.y,
- #endif
- reflectance,
- #ifdef SHEEN_LINKWITHALBEDO
- baseColor,
- surfaceAlbedo,
- #endif
- #ifdef ENVIRONMENTBRDF
- NdotV,
- environmentBrdf,
- #endif
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
- AARoughnessFactors,
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- vLightingIntensity,
- reflectionSampler,
- reflectionOut.reflectionCoords,
- NdotVUnclamped,
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
- seo,
- #endif
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
- eho,
- #endif
- #endif
- sheenOut
- );
- #ifdef SHEEN_LINKWITHALBEDO
- surfaceAlbedo=sheenOut.surfaceAlbedo;
- #endif
- #endif
- #ifdef CLEARCOAT
- #ifdef CLEARCOAT_TEXTURE
- vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
- #endif
- #endif
- #ifdef IRIDESCENCE
- iridescenceOutParams iridescenceOut;
- #ifdef IRIDESCENCE_TEXTURE
- vec2 iridescenceMapData=texture2D(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
- #endif
- #ifdef IRIDESCENCE_THICKNESS_TEXTURE
- vec2 iridescenceThicknessMapData=texture2D(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
- #endif
- iridescenceBlock(
- vIridescenceParams,
- NdotV,
- specularEnvironmentR0,
- #ifdef IRIDESCENCE_TEXTURE
- iridescenceMapData,
- #endif
- #ifdef IRIDESCENCE_THICKNESS_TEXTURE
- iridescenceThicknessMapData,
- #endif
- #ifdef CLEARCOAT
- NdotVUnclamped,
- #ifdef CLEARCOAT_TEXTURE
- clearCoatMapData,
- #endif
- #endif
- iridescenceOut
- );float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
- #endif
- clearcoatOutParams clearcoatOut;
- #ifdef CLEARCOAT
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
- vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
- #endif
- #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
- vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
- #endif
- #ifdef CLEARCOAT_BUMP
- vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
- #endif
- clearcoatBlock(
- vPositionW,
- geometricNormalW,
- viewDirectionW,
- vClearCoatParams,
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
- clearCoatMapRoughnessData,
- #endif
- specularEnvironmentR0,
- #ifdef CLEARCOAT_TEXTURE
- clearCoatMapData,
- #endif
- #ifdef CLEARCOAT_TINT
- vClearCoatTintParams,
- clearCoatColorAtDistance,
- vClearCoatRefractionParams,
- #ifdef CLEARCOAT_TINT_TEXTURE
- clearCoatTintMapData,
- #endif
- #endif
- #ifdef CLEARCOAT_BUMP
- vClearCoatBumpInfos,
- clearCoatBumpMapData,
- vClearCoatBumpUV,
- #if defined(TANGENT) && defined(NORMAL)
- vTBN,
- #else
- vClearCoatTangentSpaceParams,
- #endif
- #ifdef OBJECTSPACE_NORMALMAP
- normalMatrix,
- #endif
- #endif
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
- faceNormal,
- #endif
- #ifdef REFLECTION
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- vLightingIntensity,
- reflectionSampler,
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- #endif
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- #ifdef RADIANCEOCCLUSION
- ambientMonochrome,
- #endif
- #endif
- #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
- (gl_FrontFacing ? 1. : -1.),
- #endif
- clearcoatOut
- );
- #else
- clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
- #endif
- #include<pbrBlockReflectance>
- subSurfaceOutParams subSurfaceOut;
- #ifdef SUBSURFACE
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
- #endif
- subSurfaceBlock(
- vSubSurfaceIntensity,
- vThicknessParam,
- vTintColor,
- normalW,
- specularEnvironmentReflectance,
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- thicknessMap,
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- refractionIntensityMap,
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- translucencyIntensityMap,
- #endif
- #ifdef REFLECTION
- #ifdef SS_TRANSLUCENCY
- reflectionMatrix,
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- reflectionOut.irradianceVector,
- #endif
- #if defined(REALTIME_FILTERING)
- reflectionSampler,
- vReflectionFilteringInfo,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- irradianceSampler,
- #endif
- #endif
- #endif
- #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
- surfaceAlbedo,
- #endif
- #ifdef SS_REFRACTION
- vPositionW,
- viewDirectionW,
- view,
- vRefractionInfos,
- refractionMatrix,
- vRefractionMicrosurfaceInfos,
- vLightingIntensity,
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- alpha,
- #endif
- #ifdef SS_LODINREFRACTIONALPHA
- NdotVUnclamped,
- #endif
- #ifdef SS_LINEARSPECULARREFRACTION
- roughness,
- #endif
- alphaG,
- refractionSampler,
- #ifndef LODBASEDMICROSFURACE
- refractionSamplerLow,
- refractionSamplerHigh,
- #endif
- #ifdef ANISOTROPIC
- anisotropicOut,
- #endif
- #ifdef REALTIME_FILTERING
- vRefractionFilteringInfo,
- #endif
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
- vRefractionPosition,
- vRefractionSize,
- #endif
- #ifdef SS_DISPERSION
- dispersion,
- #endif
- #endif
- #ifdef SS_TRANSLUCENCY
- vDiffusionDistance,
- #endif
- subSurfaceOut
- );
- #ifdef SS_REFRACTION
- surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- alpha=subSurfaceOut.alpha;
- #endif
- #endif
- #else
- subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
- #endif
- #include<pbrBlockDirectLighting>
- #include<lightFragment>[0..maxSimultaneousLights]
- #include<pbrBlockFinalLitComponents>
- #endif
- #include<pbrBlockFinalUnlitComponents>
- #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
- #include<pbrBlockFinalColorComposition>
- #include<logDepthFragment>
- #include<fogFragment>(color,finalColor)
- #include<pbrBlockImageProcessing>
- #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
- #ifdef PREPASS
- float writeGeometryInfo=finalColor.a>0.4 ? 1.0 : 0.0;
- #ifdef PREPASS_POSITION
- gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
- #endif
- #ifdef PREPASS_VELOCITY
- vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_ALBEDO_SQRT
- vec3 sqAlbedo=sqrt(surfaceAlbedo);
- #endif
- #ifdef PREPASS_IRRADIANCE
- vec3 irradiance=finalDiffuse;
- #ifndef UNLIT
- #ifdef REFLECTION
- irradiance+=finalIrradiance;
- #endif
- #endif
- #ifdef SS_SCATTERING
- gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);
- irradiance/=sqAlbedo;
- #else
- gl_FragData[0]=finalColor;
- float scatteringDiffusionProfile=255.;
- #endif
- gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.);
- #else
- gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
- #endif
- #ifdef PREPASS_DEPTH
- gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_NORMAL
- #ifdef PREPASS_NORMAL_WORLDSPACE
- gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
- #else
- gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
- #endif
- #endif
- #ifdef PREPASS_ALBEDO_SQRT
- gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
- #endif
- #ifdef PREPASS_REFLECTIVITY
- #ifndef UNLIT
- gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;
- #else
- gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;
- #endif
- #endif
- #endif
- #if !defined(PREPASS) || defined(WEBGL2)
- gl_FragColor=finalColor;
- #endif
- #include<oitFragment>
- #if ORDER_INDEPENDENT_TRANSPARENCY
- if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
- #endif
- #include<pbrDebug>
- #define CUSTOM_FRAGMENT_MAIN_END
- }
- `;
- // Sideeffect
- ShaderStore.ShadersStore[name] = shader;
- /** @internal */
- export const pbrPixelShader = { name, shader };
- //# sourceMappingURL=pbr.fragment.js.map
|