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

Debug shader output functionality #5261

Merged
merged 5 commits into from
Apr 24, 2023
Merged

Debug shader output functionality #5261

merged 5 commits into from
Apr 24, 2023

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Apr 21, 2023

Functionality, allowing a name of the shader pass to be set on camera, to be used for its rendering. There are multiple shader debug passes predefined, allowing debug rendering functionality.

Custom shader pass names can also be used. Possible use cases is where for example user wants to use cheaper shaders when rendering to reflection texture. They can use the shader define to skip some processing in some shader chunks. Alternatively, they can modify StandardMaterialOptions in a callback to disable shader features.

There are two new shader chunks:

  • debug-output.js - inserted at the end of the generated shader, outputs data that are written to color render target based on the shader pass define
  • debug-process-frontend - inserted before the front end data are passed to backend, allowing those to be modified. For example to render 'Lighting', the albedo is set to mid gray color here.

New API:

Screenshot 2023-04-21 at 16 45 06
Screenshot 2023-04-21 at 16 45 22

Example:

Multi-View example updated with dropdown (not all options are visible and scrolling is needing, which is not obvious)

Screenshot 2023-04-21 at 14 42 59

debug-modes.mov

@mvaligursky mvaligursky self-assigned this Apr 21, 2023
@mvaligursky mvaligursky added the area: graphics Graphics related issue label Apr 21, 2023
@willeastcott
Copy link
Contributor

So cool. I was wondering. Maybe this feature warrants a new example. Maybe with 9 camera (3x3 grid) rendering an object with each viewport labelled with the pass being used.

@slimbuck
Copy link
Member

I'm struggling to understand how the new shaderPassName relates to the existing FORWARD, DEPTH, ETC passes.

Is SHADERTYPE_DEBUG_AO assumed to be a FORWARD pass or...?

@mvaligursky
Copy link
Contributor Author

I'm struggling to understand how the new shaderPassName relates to the existing FORWARD, DEPTH, ETC passes.

Is SHADERTYPE_DEBUG_AO assumed to be a FORWARD pass or...?

Shader pass name is converted to a number internally, and this is used as a pass that is used all over the place, for example in options.pass, or forward-renderer using pass to access shader from an array on material / mesh instance. FORWARD is 0, SHADOW is 1 .. and new passes that are created on camera are added after those. If the user wants to render shadow depth map, they could use existing DEPTH pass .. they are all the same. That is way I use the same SHADERTYPE_** constants. But I like @willeastcott 's suggestion of renaming them to SHADERPASS_**

@willeastcott
Copy link
Contributor

If you do alias to SHADERPASS_, I would suggest changing CameraComponent#setShaderPassName to simply CameraComponent#setShaderPass.

Copy link
Contributor

@willeastcott willeastcott left a comment

Choose a reason for hiding this comment

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

This API naming looks much better to me so I'll go ahead and approve. What's your take @slimbuck?

Comment on lines +30 to +31
import debugOutputPS from './lit/frag/debug-output.js';
import debugProcessFrontendPS from './lit/frag/debug-process-frontend.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, can we consider this naming too please (since once chunk names are chosen, they can be used in app code). I'm not sure about debugOutput - the _DEBUG_ naming has gone from the constants. I can think of non-debug uses for this. And also debugProcessFrontend is a bit verbose. Not sure what could be better though. Ideas, @GSterbrant and @slimbuck?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

debugOutputPS could be: postEndPS
debugProcessFrontendPS could be: postFrontEndPS or processLitArgsPS

I'd probably vote for 1st on these lists.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think they're better. Would still love for @GSterbrant and @slimbuck to chip in too...

Copy link
Member

Choose a reason for hiding this comment

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

We chatted about this offline and decided this naming isn't great and we'd like to fix it, but not in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants