-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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 post light function for forward pipelines (useful in toon shading) #102708
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Out of curiosity , does this come with a notable performance cost when not being used? |
Great work! The trick with this has always been what to do for the compatibility renderer. We have discussed it a few times and never agreed on something that we are happy with. When using additive lighting, a "post light" function would stop working correctly. But we can't add a built-in shader function that only works on 2 of the 3 backends. Do you have any thoughts on how the compatibility renderer could be supported? |
Nope, it has no effect on the generated shader source if
I did made it work on my local machine when I was testing. The only problem is that the compatibility shader uses two-stage tonemapping/gamma-correction. It tonemaps the base |
9b8d52c
to
c712226
Compare
I added the support for compatibility at of cost of potential tiny visual changes of existing shader code. Original logic:
New logic:
The exposure step is a linear transform so no difference will be introduced, but since tonemapping is non-linear, this change might have introduced tiny visual changes on color. |
@HydrogenC I think you have mistaken how additive lighting works. Only the first shadowed light is included in the base pass. After that the mesh is redrawn with the blend mode set to additive and only the lighting is output to screen. This blends multiple lights in several passes. |
Oh, I've mistaken it, thanks for your explanation. This makes the problem difficult, that we would need another additional pass after all lights are calculated to implement |
c712226
to
cec0c93
Compare
I made a primitive implementation for compatibility which look quite consistent with other pipelines in my test case (and doesn't break support for fog and tonemapping). However there's technical limitations in multi-pass light, that users will not be able to access the accumulated |
cec0c93
to
9ade68b
Compare
Added a post light function, allowing the user to calculate the final color from lighting data with custom logic, useful for NPR like cel shading. Passing varyings from
light
topost_light
is allowed. Closes godotengine/godot-proposals#10527 and closes godotengine/godot-proposals#484.Render pipeline compatibility:
The following test shader produces the result in the image, notice that the ramp is be applied after all lights are accumulated:
P.S. : I am new to Godot source code, so I may have misunderstood how the code framework works.
Besides, the current implementation is quite casual, maybe a better design could be came up with as for where in the shader to put the post light at and which built-ins to expose to the post light function.