|
@@ -13,7 +13,7 @@ import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
|
import { Loop } from '../utils/LoopNode.js';
|
|
import { Loop } from '../utils/LoopNode.js';
|
|
|
-import { viewportCoordinate } from '../display/ViewportNode.js';
|
|
|
|
|
|
|
+import { screenCoordinate } from '../display/ScreenNode.js';
|
|
|
import { HalfFloatType, LessCompare, RGFormat, VSMShadowMap, WebGPUCoordinateSystem } from '../../constants.js';
|
|
import { HalfFloatType, LessCompare, RGFormat, VSMShadowMap, WebGPUCoordinateSystem } from '../../constants.js';
|
|
|
|
|
|
|
|
const BasicShadowMap = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
const BasicShadowMap = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
@@ -141,7 +141,7 @@ const VSMShadowMapNode = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
-const VSMPassVertical = Fn( ( { samples, radius, resolution, shadowPass } ) => {
|
|
|
|
|
|
|
+const VSMPassVertical = Fn( ( { samples, radius, size, shadowPass } ) => {
|
|
|
|
|
|
|
|
const mean = float( 0 ).toVar();
|
|
const mean = float( 0 ).toVar();
|
|
|
const squaredMean = float( 0 ).toVar();
|
|
const squaredMean = float( 0 ).toVar();
|
|
@@ -153,7 +153,7 @@ const VSMPassVertical = Fn( ( { samples, radius, resolution, shadowPass } ) => {
|
|
|
|
|
|
|
|
const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
|
|
const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
|
|
|
|
|
|
|
|
- const depth = shadowPass.uv( add( viewportCoordinate.xy, vec2( 0, uvOffset ).mul( radius ) ).div( resolution ) ).x;
|
|
|
|
|
|
|
+ const depth = shadowPass.uv( add( screenCoordinate.xy, vec2( 0, uvOffset ).mul( radius ) ).div( size ) ).x;
|
|
|
mean.addAssign( depth );
|
|
mean.addAssign( depth );
|
|
|
squaredMean.addAssign( depth.mul( depth ) );
|
|
squaredMean.addAssign( depth.mul( depth ) );
|
|
|
|
|
|
|
@@ -167,7 +167,7 @@ const VSMPassVertical = Fn( ( { samples, radius, resolution, shadowPass } ) => {
|
|
|
|
|
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
-const VSMPassHorizontal = Fn( ( { samples, radius, resolution, shadowPass } ) => {
|
|
|
|
|
|
|
+const VSMPassHorizontal = Fn( ( { samples, radius, size, shadowPass } ) => {
|
|
|
|
|
|
|
|
const mean = float( 0 ).toVar();
|
|
const mean = float( 0 ).toVar();
|
|
|
const squaredMean = float( 0 ).toVar();
|
|
const squaredMean = float( 0 ).toVar();
|
|
@@ -179,7 +179,7 @@ const VSMPassHorizontal = Fn( ( { samples, radius, resolution, shadowPass } ) =>
|
|
|
|
|
|
|
|
const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
|
|
const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
|
|
|
|
|
|
|
|
- const distribution = shadowPass.uv( add( viewportCoordinate.xy, vec2( uvOffset, 0 ).mul( radius ) ).div( resolution ) );
|
|
|
|
|
|
|
+ const distribution = shadowPass.uv( add( screenCoordinate.xy, vec2( uvOffset, 0 ).mul( radius ) ).div( size ) );
|
|
|
mean.addAssign( distribution.x );
|
|
mean.addAssign( distribution.x );
|
|
|
squaredMean.addAssign( add( distribution.y.mul( distribution.y ), distribution.x.mul( distribution.x ) ) );
|
|
squaredMean.addAssign( add( distribution.y.mul( distribution.y ), distribution.x.mul( distribution.x ) ) );
|
|
|
|
|
|
|
@@ -289,14 +289,14 @@ class AnalyticLightNode extends LightingNode {
|
|
|
|
|
|
|
|
const samples = reference( 'blurSamples', 'float', shadow );
|
|
const samples = reference( 'blurSamples', 'float', shadow );
|
|
|
const radius = reference( 'radius', 'float', shadow );
|
|
const radius = reference( 'radius', 'float', shadow );
|
|
|
- const resolution = reference( 'mapSize', 'vec2', shadow );
|
|
|
|
|
|
|
+ const size = reference( 'mapSize', 'vec2', shadow );
|
|
|
|
|
|
|
|
let material = this.vsmMaterialVertical || ( this.vsmMaterialVertical = new NodeMaterial() );
|
|
let material = this.vsmMaterialVertical || ( this.vsmMaterialVertical = new NodeMaterial() );
|
|
|
- material.fragmentNode = VSMPassVertical( { samples, radius, resolution, shadowPass: shadowPassVertical } ).context( builder.getSharedContext() );
|
|
|
|
|
|
|
+ material.fragmentNode = VSMPassVertical( { samples, radius, size, shadowPass: shadowPassVertical } ).context( builder.getSharedContext() );
|
|
|
material.name = 'VSMVertical';
|
|
material.name = 'VSMVertical';
|
|
|
|
|
|
|
|
material = this.vsmMaterialHorizontal || ( this.vsmMaterialHorizontal = new NodeMaterial() );
|
|
material = this.vsmMaterialHorizontal || ( this.vsmMaterialHorizontal = new NodeMaterial() );
|
|
|
- material.fragmentNode = VSMPassHorizontal( { samples, radius, resolution, shadowPass: shadowPassHorizontal } ).context( builder.getSharedContext() );
|
|
|
|
|
|
|
+ material.fragmentNode = VSMPassHorizontal( { samples, radius, size, shadowPass: shadowPassHorizontal } ).context( builder.getSharedContext() );
|
|
|
material.name = 'VSMHorizontal';
|
|
material.name = 'VSMHorizontal';
|
|
|
|
|
|
|
|
}
|
|
}
|