@onerjs/addons 8.44.1 → 8.44.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.js +1 -1
  2. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.js.map +1 -1
  3. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js +7 -16
  4. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js.map +1 -1
  5. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.js +1 -1
  6. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.js.map +1 -1
  7. package/atmosphere/Shaders/compositeAerialPerspective.fragment.js +1 -1
  8. package/atmosphere/Shaders/compositeAerialPerspective.fragment.js.map +1 -1
  9. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js +1 -1
  10. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js.map +1 -1
  11. package/atmosphere/Shaders/compositeSky.fragment.js +1 -1
  12. package/atmosphere/Shaders/compositeSky.fragment.js.map +1 -1
  13. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js +2 -2
  14. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js.map +1 -1
  15. package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.js +9 -9
  16. package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.js.map +1 -1
  17. package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.js +7 -1
  18. package/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.js.map +1 -1
  19. package/atmosphere/ShadersWGSL/compositeAerialPerspective.fragment.js +1 -1
  20. package/atmosphere/ShadersWGSL/compositeAerialPerspective.fragment.js.map +1 -1
  21. package/atmosphere/ShadersWGSL/compositeGlobeAtmosphere.fragment.js +1 -1
  22. package/atmosphere/ShadersWGSL/compositeGlobeAtmosphere.fragment.js.map +1 -1
  23. package/atmosphere/ShadersWGSL/compositeSky.fragment.js +1 -1
  24. package/atmosphere/ShadersWGSL/compositeSky.fragment.js.map +1 -1
  25. package/atmosphere/ShadersWGSL/diffuseSkyIrradiance.fragment.js +2 -3
  26. package/atmosphere/ShadersWGSL/diffuseSkyIrradiance.fragment.js.map +1 -1
  27. package/atmosphere/atmosphere.js +23 -0
  28. package/atmosphere/atmosphere.js.map +1 -1
  29. package/atmosphere/diffuseSkyIrradianceLut.d.ts +6 -0
  30. package/atmosphere/diffuseSkyIrradianceLut.js +19 -6
  31. package/atmosphere/diffuseSkyIrradianceLut.js.map +1 -1
  32. package/atmosphere/transmittanceLut.d.ts +6 -0
  33. package/atmosphere/transmittanceLut.js +20 -7
  34. package/atmosphere/transmittanceLut.js.map +1 -1
  35. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"atmosphereFunctions.js","sourceRoot":"","sources":["../../../../../../dev/addons/src/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,0EAA+D;AAE/D,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwOd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/ShadersWGSL/ShadersInclude/intersectionFunctions\";\n\nconst name = \"atmosphereFunctions\";\nconst shader = `#include<intersectionFunctions>\nconst MultiScatteringLutSize=vec2f(32.,32.);const MultiScatteringLutDomainInUVSpace=(MultiScatteringLutSize-vec2f(1.))/MultiScatteringLutSize;const MultiScatteringLutHalfTexelSize=vec2f(.5)/MultiScatteringLutSize;const NumAerialPerspectiveLutLayers=32.;const AerialPerspectiveLutSize=vec3f(16.,64.,NumAerialPerspectiveLutLayers);const DiffuseSkyIrradianceLutSize=vec2f(64.,16.);const DiffuseSkyIrradianceLutDomainInUVSpace=(DiffuseSkyIrradianceLutSize-vec2f(1.))/DiffuseSkyIrradianceLutSize;const DiffuseSkyIrradianceLutHalfTexelSize=vec2f(.5)/DiffuseSkyIrradianceLutSize;const SkyViewLutSize=vec2f(128.,128.);const SkyViewLutDomainInUVSpace=(SkyViewLutSize-vec2f(1.))/SkyViewLutSize;const SkyViewLutHalfTexelSize=vec2f(.5)/SkyViewLutSize;const SkyViewLutSampleCount=30;const AerialPerspectiveLutKMPerSlice=4.;const AerialPerspectiveLutRangeKM=AerialPerspectiveLutKMPerSlice*NumAerialPerspectiveLutLayers;const TransmittanceSampleCount=128;const TransmittanceLutSize=vec2f(256.,64.);const TransmittanceLutDomainInUVSpace=(TransmittanceLutSize-vec2f(1.))/TransmittanceLutSize;const TransmittanceLutHalfTexelSize=vec2f(.5)/TransmittanceLutSize;const TransmittanceHorizonRange=2.*TransmittanceLutHalfTexelSize.x;const TransmittanceMaxUnoccludedU=1.-.5*TransmittanceHorizonRange;const TransmittanceMinOccludedU=1.+.5*TransmittanceHorizonRange;fn uvToUnit(uv: vec2f,domainInUVSpace: vec2f,halfTexelSize: vec2f)->vec2f {return (uv-halfTexelSize)/domainInUVSpace;}\nfn unitToUV(unit: vec2f,domainInUVSpace: vec2f,halfTexelSize: vec2f)->vec2f {return unit*domainInUVSpace+halfTexelSize;}\nfn sphereIntersectNearest(rayOrigin: vec3f,rayDirection: vec3f,sphereRadius: f32)->f32 {let result=sphereIntersectFromOrigin(rayOrigin,rayDirection,sphereRadius);let c=dot(rayOrigin,rayOrigin)-sphereRadius*sphereRadius;return select(result.x,result.y,c>=0.);}\nfn moveToTopAtmosphere(\ncameraPosition: vec3f,\npositionRadius: f32,\npositionGeocentricNormal: vec3f,\nrayDirection: vec3f,\nintersectsAtmosphere: ptr<function,bool>,\ncameraPositionClampedToTopOfAtmosphere: ptr<function,vec3f>\n) {*intersectsAtmosphere=true;*cameraPositionClampedToTopOfAtmosphere=cameraPosition;if (positionRadius>atmosphere.atmosphereRadius) {let tTop=sphereIntersectNearest(cameraPosition,rayDirection,atmosphere.atmosphereRadius);if (tTop>=0.) {let upOffset=-atmosphere.planetRadiusOffset*positionGeocentricNormal;*cameraPositionClampedToTopOfAtmosphere=cameraPosition+rayDirection*tTop+upOffset;} else {*intersectsAtmosphere=false;}}}\nfn getSkyViewUVFromParameters(\nintersectsGround: bool,\ncosHorizonAngleFromZenith: f32,\ncosAngleBetweenViewAndZenith: f32,\ncosAngleBetweenViewAndLightOnPlane: f32,\nuv: ptr<function,vec2f>\n) {var unit=vec2f(0.);if (intersectsGround) {var coord=(cosAngleBetweenViewAndZenith+1.)/(cosHorizonAngleFromZenith+1.);coord=sqrtClamped(coord); \nunit.y=.5*coord; } else {var coord=(cosAngleBetweenViewAndZenith-cosHorizonAngleFromZenith)/(1.-cosHorizonAngleFromZenith);coord=sqrtClamped(coord); \nunit.y=.5*coord+.5; }\nunit.x=.5-.5*cosAngleBetweenViewAndLightOnPlane;*uv=unitToUV(unit,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);}\n#if USE_SKY_VIEW_LUT && SAMPLE_SKY_VIEW_LUT\nfn sampleSkyViewLut(\nskyViewLut: texture_2d<f32>,\npositionRadius: f32,\ngeocentricNormal: vec3f,\nrayDirection: vec3f,\ndirectionToLight: vec3f,\ncosHorizonAngleFromZenith: f32,\ncosAngleBetweenViewAndZenith: ptr<function,f32>,\nisRayIntersectingGround: ptr<function,bool>\n)->vec4f {*cosAngleBetweenViewAndZenith=dot(rayDirection,geocentricNormal);if (positionRadius>atmosphere.atmosphereRadius) {let sinAngleBetweenViewAndNadir=sqrtClamped(1.-*cosAngleBetweenViewAndZenith**cosAngleBetweenViewAndZenith);if (sinAngleBetweenViewAndNadir>atmosphere.sinCameraAtmosphereHorizonAngleFromNadir) {*isRayIntersectingGround=false;return vec4f(0.);}}\nlet sideVector=normalize(cross(geocentricNormal,rayDirection));let forwardVector=normalize(cross(sideVector,geocentricNormal));let lightOnPlane=normalize(vec2f(dot(directionToLight,forwardVector),dot(directionToLight,sideVector)));let cosAngleBetweenViewAndLightOnPlane=lightOnPlane.x;let rayIntersectionScale=mix(.95,1.,saturate((positionRadius-atmosphere.planetRadius)/atmosphere.atmosphereThickness));*isRayIntersectingGround =\npositionRadius>atmosphere.planetRadius &&\n(rayIntersectionScale**cosAngleBetweenViewAndZenith)<=cosHorizonAngleFromZenith;var uv: vec2f;getSkyViewUVFromParameters(\n*isRayIntersectingGround,\ncosHorizonAngleFromZenith,\n*cosAngleBetweenViewAndZenith,\ncosAngleBetweenViewAndLightOnPlane,\n&uv);return textureSampleLevel(skyViewLut,skyViewLutSampler,uv,0.);}\n#endif\nfn computeRayleighPhase(onePlusCosThetaSq: f32)->f32 {return 0.0596831037*onePlusCosThetaSq;}\nfn computeMiePhaseCornetteShanks(cosTheta: f32,onePlusCosThetaSq: f32)->f32 {const g=.8;const gSquared=g*g;const oneMinusGSquared=1.-gSquared;const onePlusGSquared=1.+gSquared;const twoPlusGSquared=2.+gSquared;const twoG=2.*g;const threeOverEightPi=3./(8.*PI);return threeOverEightPi*oneMinusGSquared*onePlusCosThetaSq/(twoPlusGSquared*pow(onePlusGSquared-twoG*cosTheta,1.5));}\nfn computeOzoneDensity(normalizedViewHeight: f32)->f32 {const MinOzoneDensity=.135;const OneMinusMinOzoneDensity=1.-MinOzoneDensity;const OzoneStartHeight=.15; \nconst PeakOzoneHeight=.25;const MaxOzoneHeight=.6;const InverseRampupDistance=1./(PeakOzoneHeight-OzoneStartHeight);const InverseRampdownDistance=1./(MaxOzoneHeight-PeakOzoneHeight);let lowerAtmosphereDensity=MinOzoneDensity+OneMinusMinOzoneDensity*max(0.,normalizedViewHeight-OzoneStartHeight)*InverseRampupDistance;let sqrtUpperAtmosphereDensity=max(0.,1.-(normalizedViewHeight-PeakOzoneHeight)*InverseRampdownDistance);let upperAtmosphereDensity=sqrtUpperAtmosphereDensity*sqrtUpperAtmosphereDensity;let densityOzone=select(upperAtmosphereDensity,lowerAtmosphereDensity,normalizedViewHeight<PeakOzoneHeight);return densityOzone;}\nfn sampleMediumRGB(\nviewHeight: f32,\nscatteringRayleigh: ptr<function,vec3f>,\nscatteringMie: ptr<function,vec3f>,\nextinction: ptr<function,vec3f>,\nscattering: ptr<function,vec3f>\n) {let normalizedViewHeight=saturate(viewHeight*atmosphere.inverseAtmosphereThickness);let densityMie=exp(-83.333*normalizedViewHeight);let densityRayleigh=exp(-12.5*normalizedViewHeight);let densityOzone=computeOzoneDensity(normalizedViewHeight);*scatteringRayleigh=densityRayleigh*atmosphere.peakRayleighScattering;*scatteringMie=densityMie*atmosphere.peakMieScattering;*scattering=*scatteringMie+*scatteringRayleigh;let extinctionRayleigh=*scatteringRayleigh;let extinctionMie=densityMie*atmosphere.peakMieExtinction;let extinctionOzone=densityOzone*atmosphere.peakOzoneAbsorption;*extinction=extinctionRayleigh+extinctionMie+extinctionOzone;}\nfn computeTransmittance(rayOriginGlobal: vec3f,rayDirection: vec3f,tMax: f32,sampleCount: i32)->vec3f {var opticalDepth=vec3f(0.);var t=0.;let sampleSegmentWeight=tMax/f32(sampleCount);const sampleSegmentT=.3;for (var s=0; s<sampleCount; s+=1) {let newT=sampleSegmentWeight*(f32(s)+sampleSegmentT);let dt=newT-t;t=newT;var scatteringRayleigh: vec3f;var scatteringMie: vec3f;var extinction: vec3f;var scattering: vec3f;let samplePositionGlobal=rayOriginGlobal+t*rayDirection;sampleMediumRGB(length(samplePositionGlobal)-atmosphere.planetRadius,&scatteringRayleigh,&scatteringMie,&extinction,&scattering);opticalDepth+=extinction*dt;}\nreturn exp(-opticalDepth);}\n#if defined(SAMPLE_TRANSMITTANCE_LUT) || !defined(EXCLUDE_RAY_MARCHING_FUNCTIONS)\nfn getTransmittanceUV(radius: f32,cosAngleLightToZenith: f32,distanceToHorizon: ptr<function,f32>)->vec2f {let radiusSquared=radius*radius;let horizonDistance=sqrtClamped(radiusSquared-atmosphere.planetRadiusSquared);*distanceToHorizon=horizonDistance;let cosAngleLightToZenithSquared=cosAngleLightToZenith*cosAngleLightToZenith;let discriminant=radiusSquared*(cosAngleLightToZenithSquared-1.)+atmosphere.atmosphereRadiusSquared;let distanceToAtmosphereEdge=max(0.,-radius*cosAngleLightToZenith+sqrtClamped(discriminant));let minDistanceToAtmosphereEdge=max(0.,atmosphere.atmosphereRadius-radius);let maxDistanceToAtmosphereEdge=horizonDistance+atmosphere.horizonDistanceToAtmosphereEdge;let cosAngleLightToZenithCoordinate=(distanceToAtmosphereEdge-minDistanceToAtmosphereEdge)/max(.000001,maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);let distanceToHorizonCoordinate=horizonDistance/max(.000001,atmosphere.horizonDistanceToAtmosphereEdge);let unit=vec2f(cosAngleLightToZenithCoordinate,distanceToHorizonCoordinate);return unit*TransmittanceLutDomainInUVSpace+TransmittanceLutHalfTexelSize; }\nfn sampleTransmittanceLut(transmittanceLut: texture_2d<f32>,positionRadius: f32,cosAngleLightToZenith: f32)->vec4f {var distanceToHorizon=0.;let uv=getTransmittanceUV(positionRadius,cosAngleLightToZenith,&distanceToHorizon);let weight=smoothstep(TransmittanceMinOccludedU,TransmittanceMaxUnoccludedU,uv.x);return weight*textureSampleLevel(transmittanceLut,transmittanceLutSampler,uv,0.);}\n#endif\n#ifndef EXCLUDE_RAY_MARCHING_FUNCTIONS\n#ifndef COMPUTE_MULTI_SCATTERING\nfn sampleMultiScatteringLut(multiScatteringLut: texture_2d<f32>,radius: f32,cosAngleLightToZenith: f32)->vec3f {let unit=vec2f(.5+.5*cosAngleLightToZenith,(radius-atmosphere.planetRadius)/atmosphere.atmosphereThickness);let uv=unitToUV(unit,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);let multiScattering=textureSampleLevel(multiScatteringLut,multiScatteringLutSampler,uv,0.).rgb;return max(atmosphere.minMultiScattering,multiScattering);}\n#endif\nconst uniformPhase=RECIPROCAL_PI4;fn integrateScatteredRadiance(\nisAerialPerspectiveLut: bool,\nlightIntensityParam: f32,\ntransmittanceLut: texture_2d<f32>,\n#ifndef COMPUTE_MULTI_SCATTERING\nmultiScatteringLut: texture_2d<f32>,\nmultiScatteringIntensityParam: f32,\n#endif\nrayOriginGlobal: vec3f,\nrayDirection: vec3f,\ndirectionToLightParam: vec3f,\ntMaxMax: f32,\nsampleCount: i32,\ndistanceToSurface: f32,\ntransmittance: ptr<function,vec3f>\n#if COMPUTE_MULTI_SCATTERING\n,multiScattering: ptr<function,vec3f>\n#endif\n)->vec3f {var radiance=vec3f(0.);*transmittance=vec3f(1.);\n#if COMPUTE_MULTI_SCATTERING\n*multiScattering=vec3f(0.);\n#endif\nlet tBottom=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphere.planetRadius);let tTop=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphere.atmosphereRadius);var tMax=0.;if (tBottom<0.) {if (tTop<0.) {return radiance;} else {tMax=tTop;}} else {if (tTop>0.) {if (isAerialPerspectiveLut) {tMax=tTop;} else {tMax=min(tBottom,tTop);}}}\nif (distanceToSurface>0. && distanceToSurface<tMax) {tMax=distanceToSurface;}\ntMax=min(tMax,tMaxMax);\n#ifndef COMPUTE_MULTI_SCATTERING\nlet cosTheta=dot(rayDirection,directionToLightParam);let onePlusCosThetaSq=1.+cosTheta*cosTheta;let rayleighPhase=computeRayleighPhase(onePlusCosThetaSq);let miePhase=computeMiePhaseCornetteShanks(cosTheta,onePlusCosThetaSq);\n#endif\nlet transmittanceScale=select(1.,atmosphere.aerialPerspectiveTransmittanceScale,isAerialPerspectiveLut);var t=0.;let sampleSegmentWeight=tMax/f32(sampleCount);const sampleSegmentT=.3;for (var s=0; s<sampleCount; s+=1) {let newT=sampleSegmentWeight*(f32(s)+sampleSegmentT);let dt=newT-t;t=newT;let samplePositionGlobal=rayOriginGlobal+t*rayDirection;let sampleRadiusGlobal=length(samplePositionGlobal);let sampleGeocentricNormal=samplePositionGlobal/sampleRadiusGlobal;let sampleCosAngleLightToZenith=dot(directionToLightParam,sampleGeocentricNormal);var scatteringRayleigh: vec3f;var scatteringMie: vec3f;var extinction: vec3f;var scattering: vec3f;sampleMediumRGB(sampleRadiusGlobal-atmosphere.planetRadius,&scatteringRayleigh,&scatteringMie,&extinction,&scattering);let transmittanceToLight=sampleTransmittanceLut(transmittanceLut,sampleRadiusGlobal,sampleCosAngleLightToZenith).rgb;\n#if COMPUTE_MULTI_SCATTERING\nlet phaseTimesScattering=uniformPhase*scattering;let S=transmittanceToLight*phaseTimesScattering;\n#else\nlet phaseTimesScattering=scatteringMie*miePhase+scatteringRayleigh*rayleighPhase;let multiScatteredRadiance=sampleMultiScatteringLut(multiScatteringLut,sampleRadiusGlobal,sampleCosAngleLightToZenith);let S=transmittanceScale*transmittanceToLight*phaseTimesScattering+multiScatteringIntensityParam*multiScatteredRadiance*scattering;\n#endif\nlet sampleOpticalDepth=extinction*dt;let sampleTransmittanceVal=exp(-sampleOpticalDepth);let clampedExtinction=max(vec3f(.0000001),extinction);let SInt=(S-S*sampleTransmittanceVal)/clampedExtinction;radiance+=*transmittance*SInt;\n#if COMPUTE_MULTI_SCATTERING\nlet MSInt=(scattering-scattering*sampleTransmittanceVal)/clampedExtinction;*multiScattering+=*transmittance*MSInt;\n#endif\n*transmittance*=sampleTransmittanceVal;}\n#if USE_GROUND_ALBEDO\nif (tMax==tBottom && tBottom>0.) {let planetPos=rayOriginGlobal+tBottom*rayDirection;let planetPosRadius=length(planetPos);let planetPosGeocentricNormal=planetPos/planetPosRadius;let nDotL=dot(directionToLightParam,planetPosGeocentricNormal);let lightTransmittance=sampleTransmittanceLut(transmittanceLut,planetPosRadius,nDotL).rgb;const diffuseBrdf=RECIPROCAL_PI;radiance+=lightTransmittance**transmittance*atmosphere.groundAlbedo*(nDotL*diffuseBrdf);}\n#endif\nradiance*=lightIntensityParam;return radiance;}\n#endif\nfn layerIdxToAerialPerspectiveLayer(layerIdx: f32)->f32 {var layer=(layerIdx+1.)/NumAerialPerspectiveLutLayers;layer*=layer; \nlayer*=NumAerialPerspectiveLutLayers;return layer;}\nfn toAerialPerspectiveDepth(layer: f32)->f32 {return layer*AerialPerspectiveLutKMPerSlice;}\nfn toAerialPerspectiveLayer(distance: f32,aerialPerspectiveLutDistancePerSlice: f32)->f32 {return distance/aerialPerspectiveLutDistancePerSlice;}\nfn applyAerialPerspectiveSaturation(aerialPerspective: vec4f)->vec4f {let previousRadiance=getLuminanceUnclamped(aerialPerspective.rgb);let mixed=mix(vec3f(previousRadiance),aerialPerspective.rgb,atmosphere.aerialPerspectiveSaturation);return vec4f(mixed,aerialPerspective.a);}\nfn applyAerialPerspectiveIntensity(aerialPerspective: vec4f)->vec4f {var result=aerialPerspective;\n#if APPLY_AERIAL_PERSPECTIVE_INTENSITY\nif (atmosphere.aerialPerspectiveIntensity==0.) {result=vec4f(0.);} else {let previousAlpha=result.a;result=result/max(.00001,previousAlpha);result=result*pow(previousAlpha,1./atmosphere.aerialPerspectiveIntensity);}\n#endif\nreturn result;}\nfn applyAerialPerspectiveRadianceBias(aerialPerspective: vec4f)->vec4f {var result=aerialPerspective;\n#if APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\nlet originalRadiance=dot(result.rgb,LuminanceEncodeApprox);let targetRadiance=originalRadiance+atmosphere.aerialPerspectiveRadianceBias;if (originalRadiance>0.) {result=result*max(0.,targetRadiance/originalRadiance);} else {result=max(vec4f(0.),vec4f(atmosphere.aerialPerspectiveRadianceBias));}\nresult.a=min(result.a,1.);\n#endif\nreturn result;}\nfn sampleAerialPerspectiveLut(\nscreenUV: vec2f,\nclampToLutRange: bool,\ndistanceFromCamera: f32,\nnumAerialPerspectiveLutLayers: f32,\naerialPerspectiveLutKMPerSlice: f32,\naerialPerspectiveLutRangeKM: f32,\naerialPerspective: ptr<function,vec4f>\n)->bool {*aerialPerspective=vec4f(0.);\n#if USE_AERIAL_PERSPECTIVE_LUT\nif (distanceFromCamera>0. &&\n(clampToLutRange || distanceFromCamera<aerialPerspectiveLutRangeKM) &&\natmosphere.clampedCameraRadius<=atmosphere.atmosphereRadius) {var layer=toAerialPerspectiveLayer(distanceFromCamera,aerialPerspectiveLutKMPerSlice);let normalizedLayer=sqrt(layer/numAerialPerspectiveLutLayers); \nlayer=min(normalizedLayer*numAerialPerspectiveLutLayers,numAerialPerspectiveLutLayers);let weight=min(layer,1.);let layerIdx=max(0.,layer-1.);let floorLayerIdx=floor(layerIdx);let aerialPerspectiveLayer0=textureSampleLevel(aerialPerspectiveLut,aerialPerspectiveLutSampler,screenUV,i32(floorLayerIdx),0.);let aerialPerspectiveLayer1=textureSampleLevel(aerialPerspectiveLut,aerialPerspectiveLutSampler,screenUV,i32(floorLayerIdx+1.),0.);var interpolated=mix(aerialPerspectiveLayer0,aerialPerspectiveLayer1,layerIdx-floorLayerIdx);interpolated=vec4f(interpolated.rgb*atmosphere.atmosphereExposure,interpolated.a);interpolated=applyAerialPerspectiveSaturation(interpolated);interpolated=weight*applyAerialPerspectiveIntensity(interpolated);interpolated=applyAerialPerspectiveRadianceBias(interpolated);*aerialPerspective=interpolated;return true;}\n#endif\nreturn false;}\n#if RENDER_TRANSMITTANCE\nfn getTransmittanceParameters(uv: vec2f,radius: ptr<function,f32>,cosAngleLightToZenith: ptr<function,f32>,distanceToAtmosphereEdge: ptr<function,f32>) {let unit=uvToUnit(uv,TransmittanceLutDomainInUVSpace,TransmittanceLutHalfTexelSize);let distanceToHorizon=unit.y*atmosphere.horizonDistanceToAtmosphereEdge;let distanceToHorizonSquared=distanceToHorizon*distanceToHorizon;*radius=sqrtClamped(distanceToHorizonSquared+atmosphere.planetRadiusSquared);let minDistanceToAtmosphereEdge=atmosphere.atmosphereRadius-*radius;let maxDistanceToAtmosphereEdge=distanceToHorizon+atmosphere.horizonDistanceToAtmosphereEdge;*distanceToAtmosphereEdge=minDistanceToAtmosphereEdge+unit.x*(maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);let distanceToAtmosphereEdgeSquared=*distanceToAtmosphereEdge**distanceToAtmosphereEdge;*cosAngleLightToZenith=select(\n(atmosphere.horizonDistanceToAtmosphereEdgeSquared-distanceToAtmosphereEdgeSquared-distanceToHorizonSquared)/(2.**radius**distanceToAtmosphereEdge),\n1.,\n*distanceToAtmosphereEdge<=0.\n);*cosAngleLightToZenith=clamp(*cosAngleLightToZenith,-1.,1.);}\nfn renderTransmittance(uv: vec2f)->vec4f {var radius: f32;var cosAngleLightToZenith: f32;var distanceToAtmosphereEdgeAlongAngle: f32;getTransmittanceParameters(uv,&radius,&cosAngleLightToZenith,&distanceToAtmosphereEdgeAlongAngle);let sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);let directionToLight=normalize(vec3f(0.,cosAngleLightToZenith,sinAngleLightToZenith));let transmittance=computeTransmittance(vec3f(0.,radius,0.),directionToLight,distanceToAtmosphereEdgeAlongAngle,TransmittanceSampleCount);return vec4f(transmittance,avg(transmittance));}\n#endif\n#if RENDER_MULTI_SCATTERING\nfn getSphereSample(azimuth: f32,inclination: f32,sinInclination: ptr<function,f32>)->vec3f {*sinInclination=sin(inclination);return vec3f(*sinInclination*sin(azimuth),cos(inclination),*sinInclination*cos(azimuth));}\nconst MultiScatteringInclinationSampleCount=8.;const MultiScatteringAzimuthSampleCount=2.*MultiScatteringInclinationSampleCount;const MultiScatteringSampleCount=64;const MultiScatteringAzimuthIterationAngle=TWO_PI/MultiScatteringAzimuthSampleCount;const MultiScatteringInclinationIterationAngle=PI/MultiScatteringInclinationSampleCount;const MultiScatteringAngleStepProduct=MultiScatteringAzimuthIterationAngle*MultiScatteringInclinationIterationAngle;fn renderMultiScattering(uv: vec2f,transmittanceLut: texture_2d<f32>)->vec4f {let unit=uvToUnit(uv,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);let cosAngleLightToZenith=2.*unit.x-1.;let sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);let directionToLightLocal=normalize(vec3f(0.,cosAngleLightToZenith,sinAngleLightToZenith));let rayOriginRadius=atmosphere.planetRadius+max(unit.y,.001)*atmosphere.atmosphereThickness;let rayOrigin=vec3f(0.,rayOriginRadius,0.);var inscattered=vec3f(0.);var multiScatteringTotal=vec3f(0.);for (var i=.5; i<MultiScatteringAzimuthSampleCount; i+=1.) {let azimuth=MultiScatteringAzimuthIterationAngle*i;for (var j=.5; j<MultiScatteringInclinationSampleCount; j+=1.) {let inclination=MultiScatteringInclinationIterationAngle*j;var sinInclination: f32;let rayDirection=getSphereSample(azimuth,inclination,&sinInclination);var transmittanceVal: vec3f;var multiScatteringVal: vec3f;let radianceVal=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nrayOrigin,\nrayDirection,\ndirectionToLightLocal,\n100000000.,\nMultiScatteringSampleCount,\n-1.,\n&transmittanceVal,\n&multiScatteringVal);let weight=RECIPROCAL_PI4*abs(sinInclination)*MultiScatteringAngleStepProduct;multiScatteringTotal+=multiScatteringVal*weight;inscattered+=radianceVal*weight;}}\nlet multiScatteringResult=inscattered/max(vec3f(.000001),vec3f(1.)-multiScatteringTotal);return vec4f(multiScatteringResult,1.);}\n#endif\nfn computeCosHorizonAngleFromZenith(radius: f32)->f32 {let sinAngleBetweenHorizonAndNadir=min(1.,atmosphere.planetRadius/radius);let cosHorizonAngleFromNadir=sqrt(1.-sinAngleBetweenHorizonAndNadir*sinAngleBetweenHorizonAndNadir);let cosHorizonAngleFromZenith=-cosHorizonAngleFromNadir;return cosHorizonAngleFromZenith;}\n#if RENDER_SKY_VIEW\nfn getSkyViewParametersFromUV(\nradius: f32,\nuv: vec2f,\ncosAngleBetweenViewAndZenith: ptr<function,f32>,\ncosAngleBetweenViewAndLightOnPlane: ptr<function,f32>\n) {let unit=uvToUnit(uv,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);let cosHorizonAngleFromZenith=computeCosHorizonAngleFromZenith(radius);if (unit.y<.5) {var coord=2.*unit.y; \ncoord*=coord; \n*cosAngleBetweenViewAndZenith=mix(-1.,cosHorizonAngleFromZenith,coord); } else {var coord=2.*unit.y-1.; \ncoord*=coord; \n*cosAngleBetweenViewAndZenith=mix(cosHorizonAngleFromZenith,1.,coord); }\n*cosAngleBetweenViewAndLightOnPlane=1.-2.*unit.x;}\nfn renderSkyView(uv: vec2f,transmittanceLut: texture_2d<f32>,multiScatteringLut: texture_2d<f32>)->vec4f {var cosAngleBetweenViewAndZenith: f32;var cosAngleBetweenViewAndLightOnPlane: f32;getSkyViewParametersFromUV(atmosphere.clampedCameraRadius,uv,&cosAngleBetweenViewAndZenith,&cosAngleBetweenViewAndLightOnPlane);let sinAngleBetweenViewAndZenith=sqrtClamped(1.-cosAngleBetweenViewAndZenith*cosAngleBetweenViewAndZenith);let sinAngleBetweenViewAndLightOnPlane=sqrtClamped(1.-cosAngleBetweenViewAndLightOnPlane*cosAngleBetweenViewAndLightOnPlane);let rayDirection =\nvec3f(\nsinAngleBetweenViewAndZenith*cosAngleBetweenViewAndLightOnPlane,\ncosAngleBetweenViewAndZenith,\nsinAngleBetweenViewAndZenith*sinAngleBetweenViewAndLightOnPlane);var intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\nvec3f(0.,atmosphere.clampedCameraRadius,0.),\natmosphere.clampedCameraRadius,\nvec3f(0.,1.,0.),\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere\n);if (!intersectsAtmosphere) {return vec4f(0.);}\nvar transmittanceVal: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLightRelativeToCameraGeocentricNormal,\n100000000.,\nSkyViewLutSampleCount,\n-1.,\n&transmittanceVal\n);let transparency=1.-avg(transmittanceVal);return vec4f(radiance,transparency);}\n#endif\n#if RENDER_CAMERA_VOLUME\nfn renderCameraVolume(\npositionOnNearPlane: vec3f,\nlayerIdx: f32,\ntransmittanceLut: texture_2d<f32>,\nmultiScatteringLut: texture_2d<f32>\n)->vec4f {var result=vec4f(0.);let rayDirection=normalize(positionOnNearPlane);let layer=layerIdxToAerialPerspectiveLayer(layerIdx);let tMax=toAerialPerspectiveDepth(layer);var tMaxMax=tMax;var cameraPositionGlobalClampedToTopOfAtmosphere=atmosphere.clampedCameraPositionGlobal;if (atmosphere.clampedCameraRadius>=atmosphere.atmosphereRadius) {var intersectsAtmosphere=false;moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return result;}\nlet distanceToAtmosphere=distance(atmosphere.clampedCameraPositionGlobal,cameraPositionGlobalClampedToTopOfAtmosphere);if (tMaxMax<distanceToAtmosphere) {return result;}\ntMaxMax=max(0.,tMaxMax-distanceToAtmosphere);}\nlet sampleCount=i32(min(SkyViewLutSampleCount,2.*layer+2.));var transmittance: vec3f;let radiance=integrateScatteredRadiance(\ntrue,\natmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\ntMaxMax,\nsampleCount,\n-1.,\n&transmittance);let transparency=1.-avg(transmittance);result=vec4f(radiance,transparency);return result;}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const atmosphereFunctionsWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"atmosphereFunctions.js","sourceRoot":"","sources":["../../../../../../dev/addons/src/atmosphere/ShadersWGSL/ShadersInclude/atmosphereFunctions.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,0EAA+D;AAE/D,MAAM,IAAI,GAAG,qBAAqB,CAAC;AACnC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwOd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"core/ShadersWGSL/ShadersInclude/intersectionFunctions\";\n\nconst name = \"atmosphereFunctions\";\nconst shader = `#include<intersectionFunctions>\nconst MultiScatteringLutSize=vec2f(32.,32.);const MultiScatteringLutDomainInUVSpace=(MultiScatteringLutSize-vec2f(1.))/MultiScatteringLutSize;const MultiScatteringLutHalfTexelSize=vec2f(.5)/MultiScatteringLutSize;const NumAerialPerspectiveLutLayers=32.;const AerialPerspectiveLutSize=vec3f(16.,64.,NumAerialPerspectiveLutLayers);const DiffuseSkyIrradianceLutSize=vec2f(64.,16.);const DiffuseSkyIrradianceLutDomainInUVSpace=(DiffuseSkyIrradianceLutSize-vec2f(1.))/DiffuseSkyIrradianceLutSize;const DiffuseSkyIrradianceLutHalfTexelSize=vec2f(.5)/DiffuseSkyIrradianceLutSize;const SkyViewLutSize=vec2f(128.,128.);const SkyViewLutDomainInUVSpace=(SkyViewLutSize-vec2f(1.))/SkyViewLutSize;const SkyViewLutHalfTexelSize=vec2f(.5)/SkyViewLutSize;const AerialPerspectiveLutKMPerSlice=4.;const AerialPerspectiveLutRangeKM=AerialPerspectiveLutKMPerSlice*NumAerialPerspectiveLutLayers;const TransmittanceLutSize=vec2f(256.,64.);const TransmittanceLutDomainInUVSpace=(TransmittanceLutSize-vec2f(1.))/TransmittanceLutSize;const TransmittanceLutHalfTexelSize=vec2f(.5)/TransmittanceLutSize;const TransmittanceHorizonRange=2.*TransmittanceLutHalfTexelSize.x;const TransmittanceMaxUnoccludedU=1.-.5*TransmittanceHorizonRange;const TransmittanceMinOccludedU=1.+.5*TransmittanceHorizonRange;fn uvToUnit(uv: vec2f,domainInUVSpace: vec2f,halfTexelSize: vec2f)->vec2f {return (uv-halfTexelSize)/domainInUVSpace;}\nfn unitToUV(unit: vec2f,domainInUVSpace: vec2f,halfTexelSize: vec2f)->vec2f {return unit*domainInUVSpace+halfTexelSize;}\nfn sphereIntersectNearest(rayOrigin: vec3f,rayDirection: vec3f,sphereRadius: f32)->f32 {let result=sphereIntersectFromOrigin(rayOrigin,rayDirection,sphereRadius);let c=dot(rayOrigin,rayOrigin)-sphereRadius*sphereRadius;return select(result.x,result.y,c>=0.);}\nfn moveToTopAtmosphere(\ncameraPosition: vec3f,\npositionRadius: f32,\npositionGeocentricNormal: vec3f,\nrayDirection: vec3f,\nintersectsAtmosphere: ptr<function,bool>,\ncameraPositionClampedToTopOfAtmosphere: ptr<function,vec3f>\n) {*intersectsAtmosphere=true;*cameraPositionClampedToTopOfAtmosphere=cameraPosition;if (positionRadius>atmosphere.atmosphereRadius) {let tTop=sphereIntersectNearest(cameraPosition,rayDirection,atmosphere.atmosphereRadius);if (tTop>=0.) {let upOffset=-atmosphere.planetRadiusOffset*positionGeocentricNormal;*cameraPositionClampedToTopOfAtmosphere=cameraPosition+rayDirection*tTop+upOffset;} else {*intersectsAtmosphere=false;}}}\nfn getSkyViewUVFromParameters(\nintersectsGround: bool,\ncosHorizonAngleFromZenith: f32,\ncosAngleBetweenViewAndZenith: f32,\ncosAngleBetweenViewAndLightOnPlane: f32,\nuv: ptr<function,vec2f>\n) {var unit=vec2f(0.);if (intersectsGround) {var coord=(cosAngleBetweenViewAndZenith+1.)/(cosHorizonAngleFromZenith+1.);coord=sqrtClamped(coord); \nunit.y=.5*coord; } else {var coord=(cosAngleBetweenViewAndZenith-cosHorizonAngleFromZenith)/(1.-cosHorizonAngleFromZenith);coord=sqrtClamped(coord); \nunit.y=.5*coord+.5; }\nunit.x=.5-.5*cosAngleBetweenViewAndLightOnPlane;*uv=unitToUV(unit,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);}\n#if USE_SKY_VIEW_LUT && SAMPLE_SKY_VIEW_LUT\nfn sampleSkyViewLut(\nskyViewLut: texture_2d<f32>,\npositionRadius: f32,\ngeocentricNormal: vec3f,\nrayDirection: vec3f,\ndirectionToLight: vec3f,\ncosHorizonAngleFromZenith: f32,\ncosAngleBetweenViewAndZenith: ptr<function,f32>,\nisRayIntersectingGround: ptr<function,bool>\n)->vec4f {*cosAngleBetweenViewAndZenith=dot(rayDirection,geocentricNormal);if (positionRadius>atmosphere.atmosphereRadius) {let sinAngleBetweenViewAndNadir=sqrtClamped(1.-*cosAngleBetweenViewAndZenith**cosAngleBetweenViewAndZenith);if (sinAngleBetweenViewAndNadir>atmosphere.sinCameraAtmosphereHorizonAngleFromNadir) {*isRayIntersectingGround=false;return vec4f(0.);}}\nlet sideVector=normalize(cross(geocentricNormal,rayDirection));let forwardVector=normalize(cross(sideVector,geocentricNormal));let lightOnPlane=normalize(vec2f(dot(directionToLight,forwardVector),dot(directionToLight,sideVector)));let cosAngleBetweenViewAndLightOnPlane=lightOnPlane.x;let rayIntersectionScale=mix(.95,1.,saturate((positionRadius-atmosphere.planetRadius)/atmosphere.atmosphereThickness));*isRayIntersectingGround =\npositionRadius>atmosphere.planetRadius &&\n(rayIntersectionScale**cosAngleBetweenViewAndZenith)<=cosHorizonAngleFromZenith;var uv: vec2f;getSkyViewUVFromParameters(\n*isRayIntersectingGround,\ncosHorizonAngleFromZenith,\n*cosAngleBetweenViewAndZenith,\ncosAngleBetweenViewAndLightOnPlane,\n&uv);return textureSampleLevel(skyViewLut,skyViewLutSampler,uv,0.);}\n#endif\nfn computeRayleighPhase(onePlusCosThetaSq: f32)->f32 {return 0.0596831037*onePlusCosThetaSq;}\nfn computeMiePhaseCornetteShanks(cosTheta: f32,onePlusCosThetaSq: f32)->f32 {const g=.8;const gSquared=g*g;const oneMinusGSquared=1.-gSquared;const onePlusGSquared=1.+gSquared;const twoPlusGSquared=2.+gSquared;const twoG=2.*g;const threeOverEightPi=3./(8.*PI);return threeOverEightPi*oneMinusGSquared*onePlusCosThetaSq/(twoPlusGSquared*pow(onePlusGSquared-twoG*cosTheta,1.5));}\nfn computeOzoneDensity(normalizedViewHeight: f32)->f32 {const MinOzoneDensity=.135;const OneMinusMinOzoneDensity=1.-MinOzoneDensity;const OzoneStartHeight=.15; \nconst PeakOzoneHeight=.25;const MaxOzoneHeight=.6;const InverseRampupDistance=1./(PeakOzoneHeight-OzoneStartHeight);const InverseRampdownDistance=1./(MaxOzoneHeight-PeakOzoneHeight);let lowerAtmosphereDensity=MinOzoneDensity+OneMinusMinOzoneDensity*max(0.,normalizedViewHeight-OzoneStartHeight)*InverseRampupDistance;let sqrtUpperAtmosphereDensity=max(0.,1.-(normalizedViewHeight-PeakOzoneHeight)*InverseRampdownDistance);let upperAtmosphereDensity=sqrtUpperAtmosphereDensity*sqrtUpperAtmosphereDensity;let densityOzone=select(upperAtmosphereDensity,lowerAtmosphereDensity,normalizedViewHeight<PeakOzoneHeight);return densityOzone;}\nfn sampleMediumRGB(\nviewHeight: f32,\nscatteringRayleigh: ptr<function,vec3f>,\nscatteringMie: ptr<function,vec3f>,\nextinction: ptr<function,vec3f>,\nscattering: ptr<function,vec3f>\n) {let normalizedViewHeight=saturate(viewHeight*atmosphere.inverseAtmosphereThickness);let densityMie=exp(-83.333*normalizedViewHeight);let densityRayleigh=exp(-12.5*normalizedViewHeight);let densityOzone=computeOzoneDensity(normalizedViewHeight);*scatteringRayleigh=densityRayleigh*atmosphere.peakRayleighScattering;*scatteringMie=densityMie*atmosphere.peakMieScattering;*scattering=*scatteringMie+*scatteringRayleigh;let extinctionRayleigh=*scatteringRayleigh;let extinctionMie=densityMie*atmosphere.peakMieExtinction;let extinctionOzone=densityOzone*atmosphere.peakOzoneAbsorption;*extinction=extinctionRayleigh+extinctionMie+extinctionOzone;}\nfn computeTransmittance(rayOriginGlobal: vec3f,rayDirection: vec3f,tMax: f32,sampleCount: f32)->vec3f {var opticalDepth=vec3f(0.);var t=0.;let sampleSegmentWeight=tMax/sampleCount;const sampleSegmentT=.3;for (var s=0.; s<sampleCount; s+=1.) {let newT=sampleSegmentWeight*(s+sampleSegmentT);let dt=newT-t;t=newT;var scatteringRayleigh: vec3f;var scatteringMie: vec3f;var extinction: vec3f;var scattering: vec3f;let samplePositionGlobal=rayOriginGlobal+t*rayDirection;sampleMediumRGB(length(samplePositionGlobal)-atmosphere.planetRadius,&scatteringRayleigh,&scatteringMie,&extinction,&scattering);opticalDepth+=extinction*dt;}\nreturn exp(-opticalDepth);}\n#if defined(SAMPLE_TRANSMITTANCE_LUT) || !defined(EXCLUDE_RAY_MARCHING_FUNCTIONS)\nfn getTransmittanceUV(radius: f32,cosAngleLightToZenith: f32,distanceToHorizon: ptr<function,f32>)->vec2f {let radiusSquared=radius*radius;let horizonDistance=sqrtClamped(radiusSquared-atmosphere.planetRadiusSquared);*distanceToHorizon=horizonDistance;let cosAngleLightToZenithSquared=cosAngleLightToZenith*cosAngleLightToZenith;let discriminant=radiusSquared*(cosAngleLightToZenithSquared-1.)+atmosphere.atmosphereRadiusSquared;let distanceToAtmosphereEdge=max(0.,-radius*cosAngleLightToZenith+sqrtClamped(discriminant));let minDistanceToAtmosphereEdge=max(0.,atmosphere.atmosphereRadius-radius);let maxDistanceToAtmosphereEdge=horizonDistance+atmosphere.horizonDistanceToAtmosphereEdge;let cosAngleLightToZenithCoordinate=(distanceToAtmosphereEdge-minDistanceToAtmosphereEdge)/max(.000001,maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);let distanceToHorizonCoordinate=horizonDistance/max(.000001,atmosphere.horizonDistanceToAtmosphereEdge);let unit=vec2f(cosAngleLightToZenithCoordinate,distanceToHorizonCoordinate);return unit*TransmittanceLutDomainInUVSpace+TransmittanceLutHalfTexelSize; }\nfn sampleTransmittanceLut(transmittanceLut: texture_2d<f32>,positionRadius: f32,cosAngleLightToZenith: f32)->vec4f {var distanceToHorizon=0.;let uv=getTransmittanceUV(positionRadius,cosAngleLightToZenith,&distanceToHorizon);let weight=smoothstep(TransmittanceMinOccludedU,TransmittanceMaxUnoccludedU,uv.x);return weight*textureSampleLevel(transmittanceLut,transmittanceLutSampler,uv,0.);}\n#endif\n#ifndef EXCLUDE_RAY_MARCHING_FUNCTIONS\n#ifndef COMPUTE_MULTI_SCATTERING\nfn sampleMultiScatteringLut(multiScatteringLut: texture_2d<f32>,radius: f32,cosAngleLightToZenith: f32)->vec3f {let unit=vec2f(.5+.5*cosAngleLightToZenith,(radius-atmosphere.planetRadius)/atmosphere.atmosphereThickness);let uv=unitToUV(unit,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);let multiScattering=textureSampleLevel(multiScatteringLut,multiScatteringLutSampler,uv,0.).rgb;return max(atmosphere.minMultiScattering,multiScattering);}\n#endif\nconst uniformPhase=RECIPROCAL_PI4;fn integrateScatteredRadiance(\nisAerialPerspectiveLut: bool,\nlightIntensityParam: f32,\ntransmittanceLut: texture_2d<f32>,\n#ifndef COMPUTE_MULTI_SCATTERING\nmultiScatteringLut: texture_2d<f32>,\nmultiScatteringIntensityParam: f32,\n#endif\nrayOriginGlobal: vec3f,\nrayDirection: vec3f,\ndirectionToLightParam: vec3f,\ntMaxMax: f32,\nsampleCount: f32,\ndistanceToSurface: f32,\ntransmittance: ptr<function,vec3f>\n#if COMPUTE_MULTI_SCATTERING\n,multiScattering: ptr<function,vec3f>\n#endif\n)->vec3f {var radiance=vec3f(0.);*transmittance=vec3f(1.);\n#if COMPUTE_MULTI_SCATTERING\n*multiScattering=vec3f(0.);\n#endif\nlet tBottom=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphere.planetRadius);let tTop=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphere.atmosphereRadius);var tMax=0.;if (tBottom<0.) {if (tTop<0.) {return radiance;} else {tMax=tTop;}} else {if (tTop>0.) {if (isAerialPerspectiveLut) {tMax=tTop;} else {tMax=min(tBottom,tTop);}}}\nif (distanceToSurface>0. && distanceToSurface<tMax) {tMax=distanceToSurface;}\ntMax=min(tMax,tMaxMax);\n#ifndef COMPUTE_MULTI_SCATTERING\nlet cosTheta=dot(rayDirection,directionToLightParam);let onePlusCosThetaSq=1.+cosTheta*cosTheta;let rayleighPhase=computeRayleighPhase(onePlusCosThetaSq);let miePhase=computeMiePhaseCornetteShanks(cosTheta,onePlusCosThetaSq);\n#endif\nlet transmittanceScale=select(1.,atmosphere.aerialPerspectiveTransmittanceScale,isAerialPerspectiveLut);var t=0.;let sampleSegmentWeight=tMax/sampleCount;const sampleSegmentT=.3;for (var s=0.; s<sampleCount; s+=1.) {let newT=sampleSegmentWeight*(s+sampleSegmentT);let dt=newT-t;t=newT;let samplePositionGlobal=rayOriginGlobal+t*rayDirection;let sampleRadiusGlobal=length(samplePositionGlobal);let sampleGeocentricNormal=samplePositionGlobal/sampleRadiusGlobal;let sampleCosAngleLightToZenith=dot(directionToLightParam,sampleGeocentricNormal);var scatteringRayleigh: vec3f;var scatteringMie: vec3f;var extinction: vec3f;var scattering: vec3f;sampleMediumRGB(sampleRadiusGlobal-atmosphere.planetRadius,&scatteringRayleigh,&scatteringMie,&extinction,&scattering);let transmittanceToLight=sampleTransmittanceLut(transmittanceLut,sampleRadiusGlobal,sampleCosAngleLightToZenith).rgb;\n#if COMPUTE_MULTI_SCATTERING\nlet phaseTimesScattering=uniformPhase*scattering;let S=transmittanceToLight*phaseTimesScattering;\n#else\nlet phaseTimesScattering=scatteringMie*miePhase+scatteringRayleigh*rayleighPhase;let multiScatteredRadiance=sampleMultiScatteringLut(multiScatteringLut,sampleRadiusGlobal,sampleCosAngleLightToZenith);let S=transmittanceScale*transmittanceToLight*phaseTimesScattering+multiScatteringIntensityParam*multiScatteredRadiance*scattering;\n#endif\nlet sampleOpticalDepth=extinction*dt;let sampleTransmittanceVal=exp(-sampleOpticalDepth);let clampedExtinction=max(vec3f(.0000001),extinction);let SInt=(S-S*sampleTransmittanceVal)/clampedExtinction;radiance+=*transmittance*SInt;\n#if COMPUTE_MULTI_SCATTERING\nlet MSInt=(scattering-scattering*sampleTransmittanceVal)/clampedExtinction;*multiScattering+=*transmittance*MSInt;\n#endif\n*transmittance*=sampleTransmittanceVal;}\n#if USE_GROUND_ALBEDO\nif (tMax==tBottom && tBottom>0.) {let planetPos=rayOriginGlobal+tBottom*rayDirection;let planetPosRadius=length(planetPos);let planetPosGeocentricNormal=planetPos/planetPosRadius;let nDotL=dot(directionToLightParam,planetPosGeocentricNormal);let lightTransmittance=sampleTransmittanceLut(transmittanceLut,planetPosRadius,nDotL).rgb;const diffuseBrdf=RECIPROCAL_PI;radiance+=lightTransmittance**transmittance*atmosphere.groundAlbedo*(nDotL*diffuseBrdf);}\n#endif\nradiance*=lightIntensityParam;return radiance;}\n#endif\nfn layerIdxToAerialPerspectiveLayer(layerIdx: f32)->f32 {var layer=(layerIdx+1.)/NumAerialPerspectiveLutLayers;layer*=layer; \nlayer*=NumAerialPerspectiveLutLayers;return layer;}\nfn toAerialPerspectiveDepth(layer: f32)->f32 {return layer*AerialPerspectiveLutKMPerSlice;}\nfn toAerialPerspectiveLayer(distance: f32,aerialPerspectiveLutDistancePerSlice: f32)->f32 {return distance/aerialPerspectiveLutDistancePerSlice;}\nfn applyAerialPerspectiveSaturation(aerialPerspective: vec4f)->vec4f {let previousRadiance=getLuminanceUnclamped(aerialPerspective.rgb);let mixed=mix(vec3f(previousRadiance),aerialPerspective.rgb,atmosphere.aerialPerspectiveSaturation);return vec4f(mixed,aerialPerspective.a);}\nfn applyAerialPerspectiveIntensity(aerialPerspective: vec4f)->vec4f {var result=aerialPerspective;\n#if APPLY_AERIAL_PERSPECTIVE_INTENSITY\nif (atmosphere.aerialPerspectiveIntensity==0.) {result=vec4f(0.);} else {let previousAlpha=result.a;result=result/max(.00001,previousAlpha);result=result*pow(previousAlpha,1./atmosphere.aerialPerspectiveIntensity);}\n#endif\nreturn result;}\nfn applyAerialPerspectiveRadianceBias(aerialPerspective: vec4f)->vec4f {var result=aerialPerspective;\n#if APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\nlet originalRadiance=dot(result.rgb,LuminanceEncodeApprox);let targetRadiance=originalRadiance+atmosphere.aerialPerspectiveRadianceBias;if (originalRadiance>0.) {result=result*max(0.,targetRadiance/originalRadiance);} else {result=max(vec4f(0.),vec4f(atmosphere.aerialPerspectiveRadianceBias));}\nresult.a=min(result.a,1.);\n#endif\nreturn result;}\nfn sampleAerialPerspectiveLut(\nscreenUV: vec2f,\nclampToLutRange: bool,\ndistanceFromCamera: f32,\nnumAerialPerspectiveLutLayers: f32,\naerialPerspectiveLutKMPerSlice: f32,\naerialPerspectiveLutRangeKM: f32,\naerialPerspective: ptr<function,vec4f>\n)->bool {*aerialPerspective=vec4f(0.);\n#if USE_AERIAL_PERSPECTIVE_LUT\nif (distanceFromCamera>0. &&\n(clampToLutRange || distanceFromCamera<aerialPerspectiveLutRangeKM) &&\natmosphere.clampedCameraRadius<=atmosphere.atmosphereRadius) {var layer=toAerialPerspectiveLayer(distanceFromCamera,aerialPerspectiveLutKMPerSlice);let normalizedLayer=sqrt(layer/numAerialPerspectiveLutLayers); \nlayer=min(normalizedLayer*numAerialPerspectiveLutLayers,numAerialPerspectiveLutLayers);let weight=min(layer,1.);let layerIdx=max(0.,layer-1.);let floorLayerIdx=floor(layerIdx);let aerialPerspectiveLayer0=textureSampleLevel(aerialPerspectiveLut,aerialPerspectiveLutSampler,screenUV,i32(floorLayerIdx),0.);let aerialPerspectiveLayer1=textureSampleLevel(aerialPerspectiveLut,aerialPerspectiveLutSampler,screenUV,i32(floorLayerIdx+1.),0.);var interpolated=mix(aerialPerspectiveLayer0,aerialPerspectiveLayer1,layerIdx-floorLayerIdx);interpolated=vec4f(interpolated.rgb*atmosphere.atmosphereExposure,interpolated.a);interpolated=applyAerialPerspectiveSaturation(interpolated);interpolated=weight*applyAerialPerspectiveIntensity(interpolated);interpolated=applyAerialPerspectiveRadianceBias(interpolated);*aerialPerspective=interpolated;return true;}\n#endif\nreturn false;}\n#if RENDER_TRANSMITTANCE\nfn getTransmittanceParameters(uv: vec2f,radius: ptr<function,f32>,cosAngleLightToZenith: ptr<function,f32>,distanceToAtmosphereEdge: ptr<function,f32>) {let unit=uvToUnit(uv,TransmittanceLutDomainInUVSpace,TransmittanceLutHalfTexelSize);let distanceToHorizon=unit.y*atmosphere.horizonDistanceToAtmosphereEdge;let distanceToHorizonSquared=distanceToHorizon*distanceToHorizon;*radius=sqrtClamped(distanceToHorizonSquared+atmosphere.planetRadiusSquared);let minDistanceToAtmosphereEdge=atmosphere.atmosphereRadius-*radius;let maxDistanceToAtmosphereEdge=distanceToHorizon+atmosphere.horizonDistanceToAtmosphereEdge;*distanceToAtmosphereEdge=minDistanceToAtmosphereEdge+unit.x*(maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);let distanceToAtmosphereEdgeSquared=*distanceToAtmosphereEdge**distanceToAtmosphereEdge;*cosAngleLightToZenith=select(\n(atmosphere.horizonDistanceToAtmosphereEdgeSquared-distanceToAtmosphereEdgeSquared-distanceToHorizonSquared)/(2.**radius**distanceToAtmosphereEdge),\n1.,\n*distanceToAtmosphereEdge<=0.\n);*cosAngleLightToZenith=clamp(*cosAngleLightToZenith,-1.,1.);}\nfn renderTransmittance(uv: vec2f)->vec4f {var radius: f32;var cosAngleLightToZenith: f32;var distanceToAtmosphereEdgeAlongAngle: f32;getTransmittanceParameters(uv,&radius,&cosAngleLightToZenith,&distanceToAtmosphereEdgeAlongAngle);let sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);let directionToLight=normalize(vec3f(0.,cosAngleLightToZenith,sinAngleLightToZenith));let transmittance=computeTransmittance(vec3f(0.,radius,0.),directionToLight,distanceToAtmosphereEdgeAlongAngle,atmosphere.transmittanceSampleCount);return vec4f(transmittance,avg(transmittance));}\n#endif\n#if RENDER_MULTI_SCATTERING\nfn getSphereSample(azimuth: f32,inclination: f32,sinInclination: ptr<function,f32>)->vec3f {*sinInclination=sin(inclination);return vec3f(*sinInclination*sin(azimuth),cos(inclination),*sinInclination*cos(azimuth));}\nfn renderMultiScattering(uv: vec2f,transmittanceLut: texture_2d<f32>)->vec4f {let MultiScatteringAzimuthIterationAngle=TWO_PI/atmosphere.multiScatteringAzimuthSampleCount;let MultiScatteringInclinationIterationAngle=PI/atmosphere.multiScatteringInclinationSampleCount;let MultiScatteringAngleStepProduct=MultiScatteringAzimuthIterationAngle*MultiScatteringInclinationIterationAngle;let unit=uvToUnit(uv,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);let cosAngleLightToZenith=2.*unit.x-1.;let sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);let directionToLightLocal=normalize(vec3f(0.,cosAngleLightToZenith,sinAngleLightToZenith));let rayOriginRadius=atmosphere.planetRadius+max(unit.y,.001)*atmosphere.atmosphereThickness;let rayOrigin=vec3f(0.,rayOriginRadius,0.);var inscattered=vec3f(0.);var multiScatteringTotal=vec3f(0.);for (var i=.5; i<atmosphere.multiScatteringAzimuthSampleCount; i+=1.) {let azimuth=MultiScatteringAzimuthIterationAngle*i;for (var j=.5; j<atmosphere.multiScatteringInclinationSampleCount; j+=1.) {let inclination=MultiScatteringInclinationIterationAngle*j;var sinInclination: f32;let rayDirection=getSphereSample(azimuth,inclination,&sinInclination);var transmittanceVal: vec3f;var multiScatteringVal: vec3f;let radianceVal=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nrayOrigin,\nrayDirection,\ndirectionToLightLocal,\n100000000.,\natmosphere.multiScatteringLutSampleCount,\n-1.,\n&transmittanceVal,\n&multiScatteringVal);let weight=RECIPROCAL_PI4*abs(sinInclination)*MultiScatteringAngleStepProduct;multiScatteringTotal+=multiScatteringVal*weight;inscattered+=radianceVal*weight;}}\nlet multiScatteringResult=inscattered/max(vec3f(.000001),vec3f(1.)-multiScatteringTotal);return vec4f(multiScatteringResult,1.);}\n#endif\nfn computeCosHorizonAngleFromZenith(radius: f32)->f32 {let sinAngleBetweenHorizonAndNadir=min(1.,atmosphere.planetRadius/radius);let cosHorizonAngleFromNadir=sqrt(1.-sinAngleBetweenHorizonAndNadir*sinAngleBetweenHorizonAndNadir);let cosHorizonAngleFromZenith=-cosHorizonAngleFromNadir;return cosHorizonAngleFromZenith;}\n#if RENDER_SKY_VIEW\nfn getSkyViewParametersFromUV(\nradius: f32,\nuv: vec2f,\ncosAngleBetweenViewAndZenith: ptr<function,f32>,\ncosAngleBetweenViewAndLightOnPlane: ptr<function,f32>\n) {let unit=uvToUnit(uv,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);let cosHorizonAngleFromZenith=computeCosHorizonAngleFromZenith(radius);if (unit.y<.5) {var coord=2.*unit.y; \ncoord*=coord; \n*cosAngleBetweenViewAndZenith=mix(-1.,cosHorizonAngleFromZenith,coord); } else {var coord=2.*unit.y-1.; \ncoord*=coord; \n*cosAngleBetweenViewAndZenith=mix(cosHorizonAngleFromZenith,1.,coord); }\n*cosAngleBetweenViewAndLightOnPlane=1.-2.*unit.x;}\nfn renderSkyView(uv: vec2f,transmittanceLut: texture_2d<f32>,multiScatteringLut: texture_2d<f32>)->vec4f {var cosAngleBetweenViewAndZenith: f32;var cosAngleBetweenViewAndLightOnPlane: f32;getSkyViewParametersFromUV(atmosphere.clampedCameraRadius,uv,&cosAngleBetweenViewAndZenith,&cosAngleBetweenViewAndLightOnPlane);let sinAngleBetweenViewAndZenith=sqrtClamped(1.-cosAngleBetweenViewAndZenith*cosAngleBetweenViewAndZenith);let sinAngleBetweenViewAndLightOnPlane=sqrtClamped(1.-cosAngleBetweenViewAndLightOnPlane*cosAngleBetweenViewAndLightOnPlane);let rayDirection =\nvec3f(\nsinAngleBetweenViewAndZenith*cosAngleBetweenViewAndLightOnPlane,\ncosAngleBetweenViewAndZenith,\nsinAngleBetweenViewAndZenith*sinAngleBetweenViewAndLightOnPlane);var intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\nvec3f(0.,atmosphere.clampedCameraRadius,0.),\natmosphere.clampedCameraRadius,\nvec3f(0.,1.,0.),\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere\n);if (!intersectsAtmosphere) {return vec4f(0.);}\nvar transmittanceVal: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLightRelativeToCameraGeocentricNormal,\n100000000.,\natmosphere.skyViewLutSampleCount,\n-1.,\n&transmittanceVal\n);let transparency=1.-avg(transmittanceVal);return vec4f(radiance,transparency);}\n#endif\n#if RENDER_CAMERA_VOLUME\nfn renderCameraVolume(\npositionOnNearPlane: vec3f,\nlayerIdx: f32,\ntransmittanceLut: texture_2d<f32>,\nmultiScatteringLut: texture_2d<f32>\n)->vec4f {var result=vec4f(0.);let rayDirection=normalize(positionOnNearPlane);let layer=layerIdxToAerialPerspectiveLayer(layerIdx);let tMax=toAerialPerspectiveDepth(layer);var tMaxMax=tMax;var cameraPositionGlobalClampedToTopOfAtmosphere=atmosphere.clampedCameraPositionGlobal;if (atmosphere.clampedCameraRadius>=atmosphere.atmosphereRadius) {var intersectsAtmosphere=false;moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return result;}\nlet distanceToAtmosphere=distance(atmosphere.clampedCameraPositionGlobal,cameraPositionGlobalClampedToTopOfAtmosphere);if (tMaxMax<distanceToAtmosphere) {return result;}\ntMaxMax=max(0.,tMaxMax-distanceToAtmosphere);}\nlet sampleCount=min(atmosphere.skyViewLutSampleCount,2.*layer+2.);var transmittance: vec3f;let radiance=integrateScatteredRadiance(\ntrue,\natmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\ntMaxMax,\nsampleCount,\n-1.,\n&transmittance);let transparency=1.-avg(transmittance);result=vec4f(radiance,transparency);return result;}\n#endif\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const atmosphereFunctionsWGSL = { name, shader };\n"]}
@@ -45,7 +45,13 @@ additionalDiffuseSkyIrradiance: vec3<f32>,
45
45
  cameraHeight: f32,
46
46
  cameraNearPlane: f32,
47
47
  originHeight: f32,
48
- sinCameraAtmosphereHorizonAngleFromNadir: f32};var<uniform> atmosphere : Atmosphere;
48
+ sinCameraAtmosphereHorizonAngleFromNadir: f32,
49
+ transmittanceSampleCount: f32,
50
+ skyViewLutSampleCount: f32,
51
+ multiScatteringLutSampleCount: f32,
52
+ multiScatteringAzimuthSampleCount: f32,
53
+ multiScatteringInclinationSampleCount: f32,
54
+ diffuseSkyIrradianceLutSampleCount: f32};var<uniform> atmosphere : Atmosphere;
49
55
  `;
50
56
  // Sideeffect
51
57
  if (!ShaderStore.IncludesShadersStoreWGSL[name]) {
@@ -1 +1 @@
1
- {"version":3,"file":"atmosphereUboDeclaration.js","sourceRoot":"","sources":["../../../../../../dev/addons/src/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,0BAA0B,CAAC;AACxC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Cd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"atmosphereUboDeclaration\";\nconst shader = `struct Atmosphere {peakRayleighScattering: vec3<f32>,\nplanetRadius: f32,\npeakMieScattering: vec3<f32>,\natmosphereThickness: f32,\npeakMieAbsorption: vec3<f32>,\nplanetRadiusSquared: f32,\npeakMieExtinction: vec3<f32>,\natmosphereRadius: f32,\npeakOzoneAbsorption: vec3<f32>,\natmosphereRadiusSquared: f32,\nhorizonDistanceToAtmosphereEdge: f32,\nhorizonDistanceToAtmosphereEdgeSquared: f32,\nplanetRadiusWithOffset: f32,\nplanetRadiusOffset: f32,\natmosphereExposure: f32,\naerialPerspectiveRadianceBias: f32,\ninverseAtmosphereThickness: f32,\naerialPerspectiveTransmittanceScale: f32,\ninverseViewProjectionWithoutTranslation: mat4x4<f32>,\ndirectionToLight: vec3<f32>,\nmultiScatteringIntensity: f32,\ndirectionToLightRelativeToCameraGeocentricNormal: vec3<f32>,\ncameraRadius: f32,\nlightRadianceAtCamera: vec3<f32>,\ndiffuseSkyIrradianceDesaturationFactor: f32,\ngroundAlbedo: vec3<f32>,\naerialPerspectiveSaturation: f32,\nminMultiScattering: vec3<f32>,\ndiffuseSkyIrradianceIntensity: f32,\ncameraPositionGlobal: vec3<f32>,\nlightIntensity: f32,\nclampedCameraPositionGlobal: vec3<f32>,\naerialPerspectiveIntensity: f32,\ncameraGeocentricNormal: vec3<f32>,\nclampedCameraRadius: f32,\ncameraForward: vec3<f32>,\nclampedCameraHeight: f32,\ncameraPosition: vec3<f32>,\ncosCameraHorizonAngleFromZenith: f32,\nviewport: vec4<f32>,\nadditionalDiffuseSkyIrradiance: vec3<f32>,\ncameraHeight: f32,\ncameraNearPlane: f32,\noriginHeight: f32,\nsinCameraAtmosphereHorizonAngleFromNadir: f32};var<uniform> atmosphere : Atmosphere;\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const atmosphereUboDeclarationWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"atmosphereUboDeclaration.js","sourceRoot":"","sources":["../../../../../../dev/addons/src/atmosphere/ShadersWGSL/ShadersInclude/atmosphereUboDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AAEvD,MAAM,IAAI,GAAG,0BAA0B,CAAC;AACxC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9C,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\n\nconst name = \"atmosphereUboDeclaration\";\nconst shader = `struct Atmosphere {peakRayleighScattering: vec3<f32>,\nplanetRadius: f32,\npeakMieScattering: vec3<f32>,\natmosphereThickness: f32,\npeakMieAbsorption: vec3<f32>,\nplanetRadiusSquared: f32,\npeakMieExtinction: vec3<f32>,\natmosphereRadius: f32,\npeakOzoneAbsorption: vec3<f32>,\natmosphereRadiusSquared: f32,\nhorizonDistanceToAtmosphereEdge: f32,\nhorizonDistanceToAtmosphereEdgeSquared: f32,\nplanetRadiusWithOffset: f32,\nplanetRadiusOffset: f32,\natmosphereExposure: f32,\naerialPerspectiveRadianceBias: f32,\ninverseAtmosphereThickness: f32,\naerialPerspectiveTransmittanceScale: f32,\ninverseViewProjectionWithoutTranslation: mat4x4<f32>,\ndirectionToLight: vec3<f32>,\nmultiScatteringIntensity: f32,\ndirectionToLightRelativeToCameraGeocentricNormal: vec3<f32>,\ncameraRadius: f32,\nlightRadianceAtCamera: vec3<f32>,\ndiffuseSkyIrradianceDesaturationFactor: f32,\ngroundAlbedo: vec3<f32>,\naerialPerspectiveSaturation: f32,\nminMultiScattering: vec3<f32>,\ndiffuseSkyIrradianceIntensity: f32,\ncameraPositionGlobal: vec3<f32>,\nlightIntensity: f32,\nclampedCameraPositionGlobal: vec3<f32>,\naerialPerspectiveIntensity: f32,\ncameraGeocentricNormal: vec3<f32>,\nclampedCameraRadius: f32,\ncameraForward: vec3<f32>,\nclampedCameraHeight: f32,\ncameraPosition: vec3<f32>,\ncosCameraHorizonAngleFromZenith: f32,\nviewport: vec4<f32>,\nadditionalDiffuseSkyIrradiance: vec3<f32>,\ncameraHeight: f32,\ncameraNearPlane: f32,\noriginHeight: f32,\nsinCameraAtmosphereHorizonAngleFromNadir: f32,\ntransmittanceSampleCount: f32,\nskyViewLutSampleCount: f32,\nmultiScatteringLutSampleCount: f32,\nmultiScatteringAzimuthSampleCount: f32,\nmultiScatteringInclinationSampleCount: f32,\ndiffuseSkyIrradianceLutSampleCount: f32};var<uniform> atmosphere : Atmosphere;\n`;\n// Sideeffect\nif (!ShaderStore.IncludesShadersStoreWGSL[name]) {\n ShaderStore.IncludesShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const atmosphereUboDeclarationWGSL = { name, shader };\n"]}
@@ -48,7 +48,7 @@ cameraPositionGlobalClampedToTopOfAtmosphere,
48
48
  rayDirection,
49
49
  atmosphere.directionToLight,
50
50
  100000000.,
51
- SkyViewLutSampleCount,
51
+ atmosphere.skyViewLutSampleCount,
52
52
  distanceToSurface,
53
53
  &transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color =
54
54
  applyAerialPerspectiveRadianceBias(
@@ -1 +1 @@
1
- {"version":3,"file":"compositeAerialPerspective.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/compositeAerialPerspective.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,8CAA8C,CAAC;AACtD,OAAO,mDAAmD,CAAC;AAE3D,MAAM,IAAI,GAAG,uCAAuC,CAAC;AACrD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,yCAAyC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/depthFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeAerialPerspectivePixelShader\";\nconst shader = `#include<atmosphereUboDeclaration>\n#if USE_AERIAL_PERSPECTIVE_LUT\nvar aerialPerspectiveLutSampler: sampler;var aerialPerspectiveLut: texture_2d_array<f32>;\n#endif\nvar depthTextureSampler: sampler;var depthTexture: texture_2d<f32>;var transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);let depth=textureSampleLevel(depthTexture,depthTextureSampler,input.vUV,0.).r;if (depth>=1.) {discard;}\nlet rayDirection=normalize(input.positionOnNearPlane);let distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\natmosphere.cameraForward,\natmosphere.cameraNearPlane);let distanceToSurface=distanceFromCamera/1000.;var aerialPerspective=vec4f(0.);if (sampleAerialPerspectiveLut(\ninput.vUV,\nfalse,\ndistanceToSurface,\nNumAerialPerspectiveLutLayers,\nAerialPerspectiveLutKMPerSlice,\nAerialPerspectiveLutRangeKM,\n&aerialPerspective)) {\n#ifndef APPLY_TRANSMITTANCE_BLENDING\naerialPerspective=vec4f(aerialPerspective.rgb,0.);\n#endif\nfragmentOutputs.color=aerialPerspective;} else {var intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {fragmentOutputs.color=vec4f(0.);return fragmentOutputs;}\nlet isAerialPerspectiveLut=atmosphere.clampedCameraRadius<atmosphere.atmosphereRadius;var transmittance: vec3f;let radiance=integrateScatteredRadiance(\nisAerialPerspectiveLut,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\nSkyViewLutSampleCount,\ndistanceToSurface,\n&transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(vec4f(radiance,transparency))));\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,0.);\n#endif\n}\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const compositeAerialPerspectivePixelShaderWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"compositeAerialPerspective.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/compositeAerialPerspective.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,8CAA8C,CAAC;AACtD,OAAO,mDAAmD,CAAC;AAE3D,MAAM,IAAI,GAAG,uCAAuC,CAAC;AACrD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,yCAAyC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/depthFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeAerialPerspectivePixelShader\";\nconst shader = `#include<atmosphereUboDeclaration>\n#if USE_AERIAL_PERSPECTIVE_LUT\nvar aerialPerspectiveLutSampler: sampler;var aerialPerspectiveLut: texture_2d_array<f32>;\n#endif\nvar depthTextureSampler: sampler;var depthTexture: texture_2d<f32>;var transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);let depth=textureSampleLevel(depthTexture,depthTextureSampler,input.vUV,0.).r;if (depth>=1.) {discard;}\nlet rayDirection=normalize(input.positionOnNearPlane);let distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\natmosphere.cameraForward,\natmosphere.cameraNearPlane);let distanceToSurface=distanceFromCamera/1000.;var aerialPerspective=vec4f(0.);if (sampleAerialPerspectiveLut(\ninput.vUV,\nfalse,\ndistanceToSurface,\nNumAerialPerspectiveLutLayers,\nAerialPerspectiveLutKMPerSlice,\nAerialPerspectiveLutRangeKM,\n&aerialPerspective)) {\n#ifndef APPLY_TRANSMITTANCE_BLENDING\naerialPerspective=vec4f(aerialPerspective.rgb,0.);\n#endif\nfragmentOutputs.color=aerialPerspective;} else {var intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {fragmentOutputs.color=vec4f(0.);return fragmentOutputs;}\nlet isAerialPerspectiveLut=atmosphere.clampedCameraRadius<atmosphere.atmosphereRadius;var transmittance: vec3f;let radiance=integrateScatteredRadiance(\nisAerialPerspectiveLut,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\natmosphere.skyViewLutSampleCount,\ndistanceToSurface,\n&transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(vec4f(radiance,transparency))));\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,0.);\n#endif\n}\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const compositeAerialPerspectivePixelShaderWGSL = { name, shader };\n"]}
@@ -72,7 +72,7 @@ cameraPositionGlobalClampedToTopOfAtmosphere,
72
72
  rayDirection,
73
73
  atmosphere.directionToLight,
74
74
  100000000.,
75
- SkyViewLutSampleCount,
75
+ atmosphere.skyViewLutSampleCount,
76
76
  distanceToSurface,
77
77
  &transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color=vec4f(radiance,transparency);if (distanceToSurface>0.) {fragmentOutputs.color =
78
78
  applyAerialPerspectiveRadianceBias(
@@ -1 +1 @@
1
- {"version":3,"file":"compositeGlobeAtmosphere.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/compositeGlobeAtmosphere.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,8CAA8C,CAAC;AACtD,OAAO,mDAAmD,CAAC;AAE3D,MAAM,IAAI,GAAG,qCAAqC,CAAC;AACnD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uCAAuC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/depthFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeGlobeAtmospherePixelShader\";\nconst shader = `#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\n#include<atmosphereUboDeclaration>\n#if HAS_DEPTH_TEXTURE\nvar depthTextureSampler: sampler;var depthTexture: texture_2d<f32>;\n#endif\n#if USE_SKY_VIEW_LUT\nvar skyViewLutSampler: sampler;var skyViewLut: texture_2d<f32>;\n#else\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#endif\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);\n#if HAS_DEPTH_TEXTURE\nlet depth=textureSampleLevel(depthTexture,depthTextureSampler,input.vUV,0.).r;\n#endif\nlet rayDirection=normalize(input.positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nvar cosAngleBetweenViewAndZenith: f32;var isRayIntersectingGround: bool;var skyColor=sampleSkyViewLut(\nskyViewLut,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\natmosphere.directionToLight,\natmosphere.cosCameraHorizonAngleFromZenith,\n&cosAngleBetweenViewAndZenith,\n&isRayIntersectingGround);fragmentOutputs.color=skyColor;if (isRayIntersectingGround) {fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(fragmentOutputs.color)));\n#if HAS_DEPTH_TEXTURE\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,depth>=1.));\n#endif\n}\n#else\nvar intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return fragmentOutputs;}\n#if HAS_DEPTH_TEXTURE\nlet distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\natmosphere.cameraForward,\natmosphere.cameraNearPlane);let distanceToSurface=distanceFromCamera/1000.;\n#else\nlet distanceToSurface=0.;\n#endif\nvar transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\nSkyViewLutSampleCount,\ndistanceToSurface,\n&transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color=vec4f(radiance,transparency);if (distanceToSurface>0.) {fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(fragmentOutputs.color)));\n#if HAS_DEPTH_TEXTURE\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,depth>=1.));\n#endif\n}\n#endif\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const compositeGlobeAtmospherePixelShaderWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"compositeGlobeAtmosphere.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/compositeGlobeAtmosphere.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,8CAA8C,CAAC;AACtD,OAAO,mDAAmD,CAAC;AAE3D,MAAM,IAAI,GAAG,qCAAqC,CAAC;AACnD,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,uCAAuC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/depthFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeGlobeAtmospherePixelShader\";\nconst shader = `#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\n#include<atmosphereUboDeclaration>\n#if HAS_DEPTH_TEXTURE\nvar depthTextureSampler: sampler;var depthTexture: texture_2d<f32>;\n#endif\n#if USE_SKY_VIEW_LUT\nvar skyViewLutSampler: sampler;var skyViewLut: texture_2d<f32>;\n#else\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#endif\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);\n#if HAS_DEPTH_TEXTURE\nlet depth=textureSampleLevel(depthTexture,depthTextureSampler,input.vUV,0.).r;\n#endif\nlet rayDirection=normalize(input.positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nvar cosAngleBetweenViewAndZenith: f32;var isRayIntersectingGround: bool;var skyColor=sampleSkyViewLut(\nskyViewLut,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\natmosphere.directionToLight,\natmosphere.cosCameraHorizonAngleFromZenith,\n&cosAngleBetweenViewAndZenith,\n&isRayIntersectingGround);fragmentOutputs.color=skyColor;if (isRayIntersectingGround) {fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(fragmentOutputs.color)));\n#if HAS_DEPTH_TEXTURE\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,depth>=1.));\n#endif\n}\n#else\nvar intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return fragmentOutputs;}\n#if HAS_DEPTH_TEXTURE\nlet distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\natmosphere.cameraForward,\natmosphere.cameraNearPlane);let distanceToSurface=distanceFromCamera/1000.;\n#else\nlet distanceToSurface=0.;\n#endif\nvar transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\natmosphere.skyViewLutSampleCount,\ndistanceToSurface,\n&transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color=vec4f(radiance,transparency);if (distanceToSurface>0.) {fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(fragmentOutputs.color)));\n#if HAS_DEPTH_TEXTURE\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,depth>=1.));\n#endif\n}\n#endif\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const compositeGlobeAtmospherePixelShaderWGSL = { name, shader };\n"]}
@@ -50,7 +50,7 @@ cameraPositionGlobalClampedToTopOfAtmosphere,
50
50
  rayDirection,
51
51
  atmosphere.directionToLight,
52
52
  100000000.,
53
- SkyViewLutSampleCount,
53
+ atmosphere.skyViewLutSampleCount,
54
54
  -1.,
55
55
  &transmittance);
56
56
  #if APPLY_TRANSMITTANCE_BLENDING
@@ -1 +1 @@
1
- {"version":3,"file":"compositeSky.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/compositeSky.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,mDAAmD,CAAC;AAE3D,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Dd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeSkyPixelShader\";\nconst shader = `#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\n#include<atmosphereUboDeclaration>\n#if USE_SKY_VIEW_LUT\nvar skyViewLutSampler: sampler;var skyViewLut: texture_2d<f32>;\n#else\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#endif\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);let rayDirection=normalize(input.positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nvar cosAngleBetweenViewAndZenith: f32;var isRayIntersectingGround: bool;var skyColor=sampleSkyViewLut(\nskyViewLut,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\natmosphere.directionToLight,\natmosphere.cosCameraHorizonAngleFromZenith,\n&cosAngleBetweenViewAndZenith,\n&isRayIntersectingGround);\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nskyColor=vec4f(skyColor.rgb,0.);\n#endif\nfragmentOutputs.color=skyColor;fragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,isRayIntersectingGround));\n#else\nvar intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return fragmentOutputs;}\nvar transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\nSkyViewLutSampleCount,\n-1.,\n&transmittance);\n#if APPLY_TRANSMITTANCE_BLENDING\nlet transparency=1.-avg(transmittance);\n#else\nlet transparency=0.;\n#endif\nfragmentOutputs.color=vec4f(radiance,transparency);\n#endif\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const compositeSkyPixelShaderWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"compositeSky.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/compositeSky.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,mDAAmD,CAAC;AAE3D,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Dd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\n\nconst name = \"compositeSkyPixelShader\";\nconst shader = `#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\n#include<atmosphereUboDeclaration>\n#if USE_SKY_VIEW_LUT\nvar skyViewLutSampler: sampler;var skyViewLut: texture_2d<f32>;\n#else\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#endif\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);let rayDirection=normalize(input.positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nvar cosAngleBetweenViewAndZenith: f32;var isRayIntersectingGround: bool;var skyColor=sampleSkyViewLut(\nskyViewLut,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\natmosphere.directionToLight,\natmosphere.cosCameraHorizonAngleFromZenith,\n&cosAngleBetweenViewAndZenith,\n&isRayIntersectingGround);\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nskyColor=vec4f(skyColor.rgb,0.);\n#endif\nfragmentOutputs.color=skyColor;fragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,isRayIntersectingGround));\n#else\nvar intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return fragmentOutputs;}\nvar transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\natmosphere.skyViewLutSampleCount,\n-1.,\n&transmittance);\n#if APPLY_TRANSMITTANCE_BLENDING\nlet transparency=1.-avg(transmittance);\n#else\nlet transparency=0.;\n#endif\nfragmentOutputs.color=vec4f(radiance,transparency);\n#endif\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const compositeSkyPixelShaderWGSL = { name, shader };\n"]}
@@ -7,8 +7,7 @@ import "@onerjs/core/ShadersWGSL/ShadersInclude/importanceSampling.js";
7
7
  import "@onerjs/core/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js";
8
8
  import "@onerjs/core/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js";
9
9
  const name = "diffuseSkyIrradiancePixelShader";
10
- const shader = `const DiffuseSkyIrradianceLutSampleCount=32;
11
- #include<atmosphereUboDeclaration>
10
+ const shader = `#include<atmosphereUboDeclaration>
12
11
  var transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;
13
12
  #include<helperFunctions>
14
13
  #include<atmosphereFunctions>
@@ -22,7 +21,7 @@ rayOrigin,
22
21
  rayDirection.xzy,
23
22
  directionToLightParam.xzy,
24
23
  100000000.,
25
- DiffuseSkyIrradianceLutSampleCount,
24
+ atmosphere.diffuseSkyIrradianceLutSampleCount,
26
25
  -1.,
27
26
  &transmittance);return radiance;}
28
27
  #include<importanceSampling>
@@ -1 +1 @@
1
- {"version":3,"file":"diffuseSkyIrradiance.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/diffuseSkyIrradiance.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,mDAAmD,CAAC;AAC3D,uEAA4D;AAC5D,qEAA0D;AAC1D,0EAA+D;AAE/D,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAC/C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Bd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\nimport \"core/ShadersWGSL/ShadersInclude/importanceSampling\";\nimport \"core/ShadersWGSL/ShadersInclude/pbrBRDFFunctions\";\nimport \"core/ShadersWGSL/ShadersInclude/hdrFilteringFunctions\";\n\nconst name = \"diffuseSkyIrradiancePixelShader\";\nconst shader = `const DiffuseSkyIrradianceLutSampleCount=32;\n#include<atmosphereUboDeclaration>\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nfn integrateForIrradiance(directionToLightParam: vec3f,rayDirection: vec3f,rayOrigin: vec3f)->vec3f {var transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\nrayOrigin,\nrayDirection.xzy,\ndirectionToLightParam.xzy,\n100000000.,\nDiffuseSkyIrradianceLutSampleCount,\n-1.,\n&transmittance);return radiance;}\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nvarying vUV: vec2f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let unit=uvToUnit(input.vUV,DiffuseSkyIrradianceLutDomainInUVSpace,DiffuseSkyIrradianceLutHalfTexelSize);let cosLightInclination=2.*unit.x-1.;let sinLightInclination=sqrtClamped(1.-cosLightInclination*cosLightInclination);let directionToLight=normalize(vec3f(0.,cosLightInclination,sinLightInclination));let radius=max(atmosphere.planetRadiusWithOffset,unit.y*atmosphere.atmosphereThickness+atmosphere.planetRadius);let swappedDirectionToLight=vec3f(directionToLight.x,directionToLight.z,directionToLight.y); \nvar irradianceResult=PI*irradiance(\nswappedDirectionToLight,\nvec2f(radius,0.),\n1.,\nvec3f(1.),\nvec3f(1.));let averageIrradiance=getLuminanceUnclamped(irradianceResult);let newIrradiance=mix(irradianceResult,vec3f(averageIrradiance),atmosphere.diffuseSkyIrradianceDesaturationFactor);let newIrradianceScale=getLuminanceUnclamped(newIrradiance);let rescaling=averageIrradiance/max(0.000001,newIrradianceScale);irradianceResult=newIrradiance*rescaling;fragmentOutputs.color=vec4f(irradianceResult,1.);}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const diffuseSkyIrradiancePixelShaderWGSL = { name, shader };\n"]}
1
+ {"version":3,"file":"diffuseSkyIrradiance.fragment.js","sourceRoot":"","sources":["../../../../../dev/addons/src/atmosphere/ShadersWGSL/diffuseSkyIrradiance.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,4CAAiC;AACvD,OAAO,wDAAwD,CAAC;AAChE,oEAAyD;AACzD,OAAO,mDAAmD,CAAC;AAC3D,uEAA4D;AAC5D,qEAA0D;AAC1D,0EAA+D;AAE/D,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAC/C,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bd,CAAC;AACF,aAAa;AACb,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;IACtC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,CAAC;AACD,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"core/Engines/shaderStore\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereUboDeclaration\";\nimport \"core/ShadersWGSL/ShadersInclude/helperFunctions\";\nimport \"../ShadersWGSL/ShadersInclude/atmosphereFunctions\";\nimport \"core/ShadersWGSL/ShadersInclude/importanceSampling\";\nimport \"core/ShadersWGSL/ShadersInclude/pbrBRDFFunctions\";\nimport \"core/ShadersWGSL/ShadersInclude/hdrFilteringFunctions\";\n\nconst name = \"diffuseSkyIrradiancePixelShader\";\nconst shader = `#include<atmosphereUboDeclaration>\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nfn integrateForIrradiance(directionToLightParam: vec3f,rayDirection: vec3f,rayOrigin: vec3f)->vec3f {var transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\nrayOrigin,\nrayDirection.xzy,\ndirectionToLightParam.xzy,\n100000000.,\natmosphere.diffuseSkyIrradianceLutSampleCount,\n-1.,\n&transmittance);return radiance;}\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nvarying vUV: vec2f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let unit=uvToUnit(input.vUV,DiffuseSkyIrradianceLutDomainInUVSpace,DiffuseSkyIrradianceLutHalfTexelSize);let cosLightInclination=2.*unit.x-1.;let sinLightInclination=sqrtClamped(1.-cosLightInclination*cosLightInclination);let directionToLight=normalize(vec3f(0.,cosLightInclination,sinLightInclination));let radius=max(atmosphere.planetRadiusWithOffset,unit.y*atmosphere.atmosphereThickness+atmosphere.planetRadius);let swappedDirectionToLight=vec3f(directionToLight.x,directionToLight.z,directionToLight.y); \nvar irradianceResult=PI*irradiance(\nswappedDirectionToLight,\nvec2f(radius,0.),\n1.,\nvec3f(1.),\nvec3f(1.));let averageIrradiance=getLuminanceUnclamped(irradianceResult);let newIrradiance=mix(irradianceResult,vec3f(averageIrradiance),atmosphere.diffuseSkyIrradianceDesaturationFactor);let newIrradianceScale=getLuminanceUnclamped(newIrradiance);let rescaling=averageIrradiance/max(0.000001,newIrradianceScale);irradianceResult=newIrradiance*rescaling;fragmentOutputs.color=vec4f(irradianceResult,1.);}\n`;\n// Sideeffect\nif (!ShaderStore.ShadersStoreWGSL[name]) {\n ShaderStore.ShadersStoreWGSL[name] = shader;\n}\n/** @internal */\nexport const diffuseSkyIrradiancePixelShaderWGSL = { name, shader };\n"]}
@@ -15,6 +15,12 @@ import { UniformBuffer } from "@onerjs/core/Materials/uniformBuffer.js";
15
15
  import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
16
16
  const MaterialPlugin = "atmo-pbr";
17
17
  const AerialPerspectiveLutLayers = 32;
18
+ const TransmittanceSampleCount = 128;
19
+ const SkyViewLutSampleCount = 30;
20
+ const MultiScatteringLutSampleCount = 64;
21
+ const MultiScatteringAzimuthSampleCount = 16;
22
+ const MultiScatteringInclinationSampleCount = 8;
23
+ const DiffuseSkyIrradianceLutSampleCount = 32;
18
24
  let UniqueId = 0;
19
25
  /**
20
26
  * Renders a physically based atmosphere.
@@ -456,6 +462,14 @@ export class Atmosphere {
456
462
  atmosphereUbo.addUniform("cameraNearPlane", 1);
457
463
  atmosphereUbo.addUniform("originHeight", 1);
458
464
  atmosphereUbo.addUniform("sinCameraAtmosphereHorizonAngleFromNadir", 1);
465
+ atmosphereUbo.addUniform("transmittanceSampleCount", 1);
466
+ // 16-byte boundary
467
+ atmosphereUbo.addUniform("skyViewLutSampleCount", 1);
468
+ atmosphereUbo.addUniform("multiScatteringLutSampleCount", 1);
469
+ atmosphereUbo.addUniform("multiScatteringAzimuthSampleCount", 1);
470
+ atmosphereUbo.addUniform("multiScatteringInclinationSampleCount", 1);
471
+ // 16-byte boundary
472
+ atmosphereUbo.addUniform("diffuseSkyIrradianceLutSampleCount", 1);
459
473
  atmosphereUbo.create();
460
474
  }
461
475
  return this._atmosphereUbo;
@@ -774,6 +788,9 @@ export class Atmosphere {
774
788
  if (depthTexture !== null) {
775
789
  this._aerialPerspectiveCompositorEffectWrapper ?? (this._aerialPerspectiveCompositorEffectWrapper = CreateAerialPerspectiveCompositorEffectWrapper(engine, uniformBuffer, this._isAerialPerspectiveLutEnabled, isSkyViewLutEnabled, isLinearSpaceComposition, applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias));
776
790
  }
791
+ // Read back LUT data from the GPU if a readback is pending (deferred from a previous render call).
792
+ void this._transmittanceLut?.readPixelsAsync();
793
+ void this._diffuseSkyIrradianceLut?.readPixelsAsync();
777
794
  this.renderGlobalLuts(); // Start rendering of global LUTs during readiness polling.
778
795
  if (!this._transmittanceLut?.hasLutData || (this._isDiffuseSkyIrradianceLutEnabled && !this._diffuseSkyIrradianceLut?.hasLutData)) {
779
796
  return false;
@@ -1130,6 +1147,12 @@ export class Atmosphere {
1130
1147
  ubo.updateFloat("cameraNearPlane", cameraAtmosphereVariables.cameraNearPlane);
1131
1148
  ubo.updateFloat("originHeight", this._originHeight);
1132
1149
  ubo.updateFloat("sinCameraAtmosphereHorizonAngleFromNadir", cameraAtmosphereVariables.sinCameraAtmosphereHorizonAngleFromNadir);
1150
+ ubo.updateFloat("transmittanceSampleCount", TransmittanceSampleCount);
1151
+ ubo.updateFloat("skyViewLutSampleCount", SkyViewLutSampleCount);
1152
+ ubo.updateFloat("multiScatteringLutSampleCount", MultiScatteringLutSampleCount);
1153
+ ubo.updateFloat("multiScatteringAzimuthSampleCount", MultiScatteringAzimuthSampleCount);
1154
+ ubo.updateFloat("multiScatteringInclinationSampleCount", MultiScatteringInclinationSampleCount);
1155
+ ubo.updateFloat("diffuseSkyIrradianceLutSampleCount", DiffuseSkyIrradianceLutSampleCount);
1133
1156
  ubo.updateFloat("atmosphereExposure", this._exposure);
1134
1157
  }
1135
1158
  /**