Implement vertex shading - #83360
Conversation
|
mmm I guess I did vertex shadow not vertex lighting, fixing it. Edit : lol, it is actually the opposite, shadow calculation should be added in vertex. |
|
I guess I need an advice from the Rendering Team, currently I am almost duplicating functions for the vertex-shading, should I just use Preprocessor to move every thing to vertex shading, or should I keep duplicating the stuff, because we may remove features from the vertex shading ? |
|
Regarding why the second light with shadows disappear, remember that Godot 4's GLES3 performs multipass lighting if you use multiple lights with shadows. This is different from Godot 3 GLES3 (and more comparable to Godot 3 GLES2, although it used multipass for non-shadowing lights too).
Yes, real-time shadows can't be received by vertex-lit surfaces. Only baked lightmap shadows can be seen on them. In GLES3 (unlike GLES2), it should be possible to sample the shadowmap texture in |
so do you think I should remove shadows from vertex-lighting ? |
I think you can remove them for now. Support for receiving shadows in vertex-lit materials can be implemented in a future PR (if it's feasible at all) 🙂 |
|
Now Compatibilty/GLES3/OpenGL Rendering should be ready for Vertex-Lighting testing and regression testing. I will continue work on Vulkan Mobile + Vulkan Forward+ |
|
My comment on shadows for vertex lighting : I think it is possible to cast shadows using vertex_shading. But I think vertex shading is mainly useful for performance reasons, and probably realtime shadows are costly. So it doesn't make a lot of sense to have realtime shadows in vertex lighting. I may implement shadows in another PR if there is a demand for it. Personally I don't need shadows in my game for vertex lighting. |
There was a problem hiding this comment.
Tested locally, it mostly works as expected. This is a great start 🙂
Testing projects:
There are some rendering issues:
- When using Forward+, vertex lighting doesn't render unless you get very close to the light node (the objects far away use per-pixel shading for comparison):
simplescreenrecorder-2023-10-19_20.03.01_forward_plus.mp4
This may be related to the light clustering system.
- When using Mobile, vertex lighting occasionally flickers in and out on specific objects when moving the camera (this may be hard to reproduce):
simplescreenrecorder-2023-10-19_20.04.02_mobile.mp4
In the testing project, the plane is subdivided so it can receive vertex lighting correctly.
Another issue is that when using lightmaps, DirectionalLights with the Static bake mode still affect lightmapped surfaces:
| Current appearance | Expected appearance (light is hidden) |
|---|---|
![]() |
![]() |
This isn't an issue with omni or spot lights. You can hide the directional light after baking as a workaround, but then it won't affect dynamic objects.
|
@Calinou |
Recording.2023-10-20.162439.mp4It seems some polygons become unlit if they become partially out of view? EDIT: I am on Forward+ by the way. |
|
@AnalogFeelings Yes this happens to me too, I think this is light clustering in Forward+ and not a bug. Maybe calinou knows. |
|
I also noticed setting the viewport to lighting only causes HEAVY artifacts. SPOILER_20231020-1433-32.5621820.mp4 |
Interesting, I'll check it out. |
Lighting mode replaces all materials in the scene with a basic ShaderMaterial that uses per-pixel lighting (it might just be the fallback material). It can't know whether the original material used vertex shading or not. The Lighting debug draw mode's appearance will probably have to be toggled with a project setting. |
|
Just fixed some bugs that I noticed from my work. |
|
So rebased to reslove the conflicts, @clayjohn the issue was with this section https://github.com/godotengine/godot/pull/83360/files#diff-94158bc3d510819bb8d7ebd62a8890eeebad49608d9e934d148b73b6b65aeff9L1422 which you removed anyway previously so I just accepted the incoming result "the vertex shading commit changes" also for some reason your name does not show again in the commit even though I didn't change anything in the commit message ?! can this be solved ? |
That makes sense. It looks fine now
I'm not sure why that is. I wouldn't worry about it, the attribution is in the commit message anyway |
This adds support in all backends, but the Compatibility renderer works the best. Mobile and Forward+ can only support one directional light shader (the first in the tree) While the Compatibility renderer supports any number of shadows. Co-authored-by: Clay John <claynjohn@gmail.com>
068a48e to
0a9ad8f
Compare
That was because the commit description was missing a separation line between the first paragraph and the "Co-authored-by:" line. GitHub is very picky about this, that line needs to be properly separated from the rest of the commit message. I amended the description to fix it. |
|
Would be nice if more flexibility were given to this over time,, for example Toon Shading with vertex-shading. Funfact Wii is essentially a repackaged Gamecube, the big differences are.. more RAM and better GPU for the Wii but anyway what i meant is the vertex shading mode should be able to handle more than just a basic diffuse shader |
why isn't this the same on on forward+? |
The compatibility renderer is intended for older devices and the Forward+ renderer is intended for newer devices. Therefore the compatibility renderer uses a technique more suitable for older devices. |
Implement vertex shading
Implement vertex shading












Implements Vertex Shading
resolves #43093
Bugs :
Vertex Shading receives shadows from one light source in GLES3No Shadows will be casted in Vertex Lightingvaryingin gdshader, it errors outNote: This PR implements Vertex-Lighting without shadows.Note: This PR implements Vertex-Lighting with Pixel-Shadows.
Production edit: Pixel shadows are only available for the first DirectionalLight3D in the scene. Omni and spot lights cannot cast shadows on vertex-shaded materials (like in Godot 3.x), except in the Compatibility rendering method where lights with shadows are rendered with a multipass approach.