Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPURenderer: Auto-MRT #28833

Merged
merged 25 commits into from
Jul 10, 2024
Merged

WebGPURenderer: Auto-MRT #28833

merged 25 commits into from
Jul 10, 2024

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jul 8, 2024

Related issue: #28749

Description

This PR starts the implementation of Auto-MRT, this will allow any RenderObject to be rendered as output (beauty), keeping the original code with extra outputs customized in the same draw.

Below shows how simple the process is to create automatic MRT, it is also possible to add more complex operations such as tslFn within the mrt() inputs.

renderTarget = new THREE.RenderTarget(
	window.innerWidth * window.devicePixelRatio,
	window.innerHeight * window.devicePixelRatio,
	{ count: 2, minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter }
);

renderTarget.textures[ 0 ].name = 'output';
renderTarget.textures[ 1 ].name = 'normal';
	
renderer.setMRT( mrt( {
	'output': output,
	'normal': directionToColor( normalWorld )
} ) );

Examples of approach

  1. Approach using names
renderer.setMRT( mrt( {
	'output': output,
	'normal': directionToColor( normalWorld )
} ) );
  1. Approach using indexes
renderer.setMRT( mrt( [
	output,
	directionToColor( normalWorld )
] ) );

Copy link

github-actions bot commented Jul 8, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
683.5 kB (169.2 kB) 683.5 kB (169.2 kB) +0 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
460.7 kB (111.1 kB) 460.7 kB (111.1 kB) +0 B

@sunag
Copy link
Collaborator Author

sunag commented Jul 9, 2024

Added a MRT example

Live example

image

src/nodes/display/PassNode.js Fixed Show fixed Hide fixed
src/nodes/display/PassNode.js Fixed Show fixed Hide fixed
src/nodes/display/PassNode.js Fixed Show fixed Hide fixed
src/nodes/display/PassNode.js Fixed Show fixed Hide fixed
@sunag sunag added this to the r167 milestone Jul 9, 2024
@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 9, 2024

The new example is awesome!

@sunag
Copy link
Collaborator Author

sunag commented Jul 9, 2024

Added mask example for material.mrtNode demonstration.

image

@sunag sunag marked this pull request as ready for review July 9, 2024 20:13
@sunag sunag merged commit 0edacaa into mrdoob:dev Jul 10, 2024
12 checks passed
@sunag sunag deleted the dev-mrt branch July 10, 2024 00:03
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.

2 participants