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

Shader Refactoring #24805

Merged
merged 6 commits into from
Oct 25, 2022
Merged

Shader Refactoring #24805

merged 6 commits into from
Oct 25, 2022

Conversation

WestLangley
Copy link
Collaborator

@WestLangley WestLangley commented Oct 16, 2022

Follow-on to #24752.

This post is intended as a basis for further discussion.

EDIT: It looks like we have agreement here. Yay!

@WestLangley
Copy link
Collaborator Author

@Mugen87 Some users may be assigning a PMREM as a background. It is fair to say that support for that is no longer needed now that blurry backgrounds are supported?

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 17, 2022

Yes, that makes sense. Users can now assign the "raw" or "unprocessed" environment map to Scene.background and let the renderer handle the background blurriness.

@mrdoob mrdoob added this to the r146 milestone Oct 19, 2022
@WestLangley WestLangley marked this pull request as ready for review October 22, 2022 03:48
@WestLangley WestLangley changed the title Draft Shader Refactoring Shader Refactoring Oct 22, 2022
@WestLangley
Copy link
Collaborator Author

@Mugen87 I am reasonably-happy with this refactoring. Please let me know what you think.

@@ -225,14 +225,27 @@ const ShaderLib = {

},

backgroundCube: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of using the term backgroundCube, what do you think about skybox instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, we can change it. How do you feel about blurredCube shader? That is the most descriptive name I can think of...

Copy link
Collaborator

Choose a reason for hiding this comment

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

True, but I have the feeling skybox is what most 3D users understand of what the shader essentially represents. It's a common term in 3D engines.

However, the name is not something that blocks the PR for me. If we can't quickly agree on a name, we can merge the refactoring first and then discuss alternatives. backgroundCube isn't wrong after all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already have a skybox shader called 'cube' shader.

  • 'cube': a skybox shader, used by post-processing, and other apps

  • 'background': used by the renderer for scene.background (flat only)

  • 'backgroundCube': used by the renderer for blurring scene.background (cube only)

The nomenclature is not a deal breaker for me, but let's revisit in a later PR. 😇

@WestLangley
Copy link
Collaborator Author

Some users may be assigning a PMREM as a background. Is it fair to say that support for that is no longer needed now that blurry backgrounds are supported?

Yes, that makes sense.

@Mugen87 FYI, with this PR, assigning a PMREM directly to scene.background is still supported. Furthermore, simultaneously setting scene.backgroundBlurriness will blur it.

I am open leaving that as-is, or removing it in a follow-on PR.

@WestLangley
Copy link
Collaborator Author

/ping @sunag just in case...

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 25, 2022

Let's merge this so we have it in r146.

@Mugen87 Mugen87 merged commit da820c4 into mrdoob:dev Oct 25, 2022
@WestLangley WestLangley deleted the dev_shader_cleanup_1 branch October 26, 2022 02:31
@WestLangley
Copy link
Collaborator Author

Some users may be assigning a PMREM as a background. Is it fair to say that support for that is no longer needed now that blurry backgrounds are supported?

I have changed my mind on this. Some users may have only a PMREM. For example,

scene.environment = pmremGenerator.fromScene( new RoomEnvironment() ).texture;

scene.background = scene.environment; // assign PMREM to background

scene.backgroundBlurriness = 0.2;

So, as long as PMREM is used for blurring scene.background, I think we should continue to support assigning a PMREM as a scene background texture.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 18, 2023

I've added a note in the migration guide for r146 about this change. There are some users directly using THREE.ShaderLib['cube'] and this PR broke their code, see:

https://stackoverflow.com/questions/75149020/property-envmap-removed-from-shader-cube-in-three-js-r146

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.

3 participants