Skip to content

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Mar 13, 2025

Closes: #30685

Description

Add TSL samplerComparison function.

const shaderParams = {
	shadowDepthTexture: texture( directionalLight.shadow.map.depthTexture ),
	shadowDepthSampler: samplerComparison( directionalLight.shadow.map.depthTexture )
};
    
const fragmentShader = wgslFn(`
	fn main_fragment(
		shadowDepthSampler: sampler_comparison,
		shadowDepthTexture: texture_depth_2d
	) -> vec4<f32> {

		return vec4f( textureSampleCompare( shadowDepthTexture, shadowDepthSampler, vec2<f32>( 0.0 ), 5. ) );

	}
`);

@sunag sunag added this to the r175 milestone Mar 13, 2025
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.02
78.26
336.02
78.26
+0 B
+0 B
WebGPU 520.52
145.15
520.83
145.19
+304 B
+49 B
WebGPU Nodes 519.99
145.04
520.29
145.09
+304 B
+49 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.06
112.14
465.06
112.14
+0 B
+0 B
WebGPU 591.01
160.79
591.14
160.82
+138 B
+34 B
WebGPU Nodes 546.13
150.23
546.27
150.26
+138 B
+34 B

@sunag sunag marked this pull request as ready for review March 13, 2025 14:52
@Spiri0
Copy link
Contributor

Spiri0 commented Mar 13, 2025

I still think too rarely about new nodes. I find the solution elegant because it includes the name of the wgsl functionality. This makes its purpose immediately apparent.

@sunag sunag merged commit a42fe2f into mrdoob:dev Mar 14, 2025
12 checks passed
@sunag sunag deleted the dev-samplerComparison branch March 14, 2025 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ShadowMaps for custom wgslFn shaders
2 participants