Smush-Material-Research
Smush-Material-Research copied to clipboard
Add effect lighting to shader database
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.
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.
- Find the vertex and fragment shader names by looking up the shader labels in the nufxlb JSON
- Find the decompiled shader and nushdb info for the vertex and fragment shaders from step 1.
- Compare the uniform names for both shaders and see if there are any differences.
- 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>)
or16
. You can see an example in code here. Thec9_data
buffer has material uniforms. Stage data is typically stored inc10_data
orc11_data
. - 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
writefs_c9_data[offset].x*0.0
.
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.
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.