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

Add effect lighting to shader database #32

Open
ThatNintendoNerd opened this issue Mar 4, 2023 · 3 comments
Open

Add effect lighting to shader database #32

ThatNintendoNerd opened this issue Mar 4, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@ThatNintendoNerd
Copy link
Contributor

Some shaders have a unique attribute to disable receival of effect lighting. The following two shader labels are emission only, but only the latter shader label disables receival of effect lighting:

SFX_PBS_0000000000000100
SFX_PBS_0000000000004100

The following picture demonstrates when this attribute is enabled and when it is disabled. The stage's uppermost pink surface is a separate mesh from the rest of the stage, and as a result is what is affected by the changes.
NoReceiveEffectLighting

@ScanMountGoat
Copy link
Owner

This would require checking the decompiled shaders to see if there is a specific attribute or uniform parameter used for effect lighting. The shader labels themselves are just strings. I don't have any rendering for effect lighting, so this isn't a big priority for me at the moment. I've outlined the steps below if anyone wants to make an attempt at figuring it out.

  1. Find the vertex and fragment shader names by looking up the shader labels in the nufxlb JSON
  2. Find the decompiled shader and nushdb info for the vertex and fragment shaders from step 1.
  3. Compare the uniform names for both shaders and see if there are any differences.
  4. Find the code using the uniform(s) in the decompiled shaders. Convert the buffer slot and offset to an actual offset by dividing by sizeof(Vec4<f32>) or 16. You can see an example in code here. The c9_data buffer has material uniforms. Stage data is typically stored in c10_data or c11_data.
  5. The last step is to test in RenderDoc since the previous steps typically give too many parameters. Editing the shader in RenderDoc to replace usages of the uniform buffer parameter with 1s or 0s should make it clear if you've found the right one. For example, instead of fs_c9_data[offset].x write fs_c9_data[offset].x*0.0.

@ScanMountGoat
Copy link
Owner

ScanMountGoat commented Apr 13, 2023

This should be a lot easier with the dump of annotated decompiled shaders. You should be able to just diff the vertex or fragment shaders for the two shader labels in the annotated dump and check for missing parameters. Check the nufxlb JSON for which vertex and fragment shaders match up with each shader label.

@ScanMountGoat
Copy link
Owner

It looks like SFX_PBS_0000000000004100_VS doesn't have the PerFrame buffer. The only missing parameters that are actually used in SFX_PBS_0000000000000100_VS are PerFrame_effect_light_param0 , PerFrame_effect_light_param1, and PerFrame_effect_light_param2. This is probably a decent heuristic for whether a shader has effect lighting or not.

You should be able to put together a script that maps shader labels to vertex shaders using the nufx JSON and checks the annotated dump for effect lighting params. I don't plan to add effect lighting to the info JSON yet since it hasn't been researched very much and isn't part of ssbh_wgpu's rendering.

@ScanMountGoat ScanMountGoat added the enhancement New feature or request label Oct 1, 2024
@ScanMountGoat ScanMountGoat changed the title Add heuristic for disabling receival of effect lighting Add effect lighting to shader database Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants