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

WebGLBackend #26581

Merged
merged 16 commits into from
Aug 30, 2023
Merged

WebGLBackend #26581

merged 16 commits into from
Aug 30, 2023

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Aug 14, 2023

Related issue: #26079

Description

https://raw.githack.com/mrdoob/three.js/dev/examples/webgpu_lights_selective.html

A minimal version of WebGLBackend. WIP.

image

@mrdoob
Copy link
Owner

mrdoob commented Aug 15, 2023

Amazing!

@mrdoob mrdoob added this to the r156 milestone Aug 15, 2023
@sunag
Copy link
Collaborator Author

sunag commented Aug 22, 2023

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@sunag sunag changed the title [WIP] WebGLBackend WebGLBackend [WIP] Aug 24, 2023
@sunag
Copy link
Collaborator Author

sunag commented Aug 28, 2023

Should we show this message to the fallback? For examples that are already working on both backend? @mrdoob @Mugen87

image

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 28, 2023

The project used this type of message to inform the user when WebGL/WebGL 2/WebGPU is not supported and thus the example does not work. But since the example does work (just with a different 3D API), I wonder if logging a info message to the browser console is already sufficient.

examples/jsm/renderers/webgl/WebGLBackend.js Fixed Show fixed Hide fixed
@@ -0,0 +1,199 @@
import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, UnsignedByteType, _SRGBAFormat, NoColorSpace, LinearSRGBColorSpace, SRGBColorSpace, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare } from 'three';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class

Unused imports DepthFormat, DepthStencilFormat, HalfFloatType, LinearSRGBColorSpace, NoColorSpace, RGBAFormat, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShortType.
@sunag
Copy link
Collaborator Author

sunag commented Aug 30, 2023

Now we have 3 pure output option in webgpu_tsl_editor:

WebGLBackend was based on WebGL2 - GLSL ES 3.0

image

@sunag sunag changed the title WebGLBackend [WIP] WebGLBackend Aug 30, 2023
@sunag sunag marked this pull request as ready for review August 30, 2023 05:53
@sunag
Copy link
Collaborator Author

sunag commented Aug 30, 2023

The examples below are working on both backends:

  • webgpu_cubemap_adjustment
  • webgpu_cubemap_mix
  • webgpu_equirectangular
  • webgpu_instance_uniform
  • webgpu_lights_custom
  • webgpu_lights_phong
  • webgpu_lights_selective

Example like webgpu_loader_gltf needs to be added RTT support in WebGLBackend.

There are two verifications if WebGPU or WebGL2 is available.

if ( WebGPU.isAvailable() === false && WebGL.isWebGL2Available() === false ) {

	document.body.appendChild( WebGPU.getErrorMessage() );

	throw new Error( 'No WebGPU or WebGL2 support' );

}

@sunag sunag merged commit 9272367 into mrdoob:dev Aug 30, 2023
@sunag sunag deleted the dev-backend-webgl branch August 30, 2023 06:10
@jrjdavidson
Copy link
Contributor

looks great and excited about these developments! I'm having trouble running the cubemap adjustments example , see screenshot:
image


if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {

extension = extensions.get( 'EXT_texture_filter_anisotropic' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the error is with this variable 'extension'

@WestLangley
Copy link
Collaborator

webgpu_lights_selective.html should define an env map. MeshStandardMaterial requires it -- especially for metals.

Also, the same example fails under Firefox because navigator is not defined. I expected it to fall back to WebGL.

@sunag
Copy link
Collaborator Author

sunag commented Aug 30, 2023

After this fix it's working on Firefox using WebGL2.

webgpu_lights_selective.html should define an env map. MeshStandardMaterial requires it -- especially for metals.

I think the idea of this example is just to show the Light API being used in analytical light, in this case selective lights.

image

@WestLangley
Copy link
Collaborator

I think the idea of this example is just to show the Light API being used in analytical light, in this case selective lights.

Users copy the examples. It is incorrect to use MeshStandardMaterial without an environment map to reflect.

If you refuse to add an envmap, then as a compromise, please hardwire metalness to zero in the example. Otherwise the rendering is completely wrong.

@sunag
Copy link
Collaborator Author

sunag commented Aug 30, 2023

If so, are examples like webgl_lights_physical, webgl_clipping_stencil, webgl_loader_draco and others not valid because they don't have an env map?

As far as I know the webgl_lights_physical example was created to test the light result in analytical lights and not IBL.

@LeviPesin
Copy link
Contributor

Do we need GLSL1NodeBuilder if we are already deprecating WebGL1?

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.

6 participants