Porting Elegant shader techniques to Godot 4.0
Asked Answered
M

2

0

Hi , so i'm trying to achieve two things in godot that i think are really cool :

1/ a ribbon effect where polygons of a flat geometry always faces the camera ( , [https://forums.unrealengine.com/t/sprite-model-how-did-they-do-this/2968/13] )
2/ this technique in Doom 3 where a mesh deforms depending of the angle of the camera to fake a volumetric glow ( , [https://simonschreibt.de/gat/doom-3-volumetric-glow/] )

Many of the articles talking about these do it on procedural geometry but I'm pretty sure this is achievable with shaders on a handmade mesh ( am I wrong ? ) Despite multiple attempts , i'm nowhere near reproducing this dark magic . Any guidelines on how to achieve these in godot would be very welcome . Thanks !

Marmoset answered 27/4, 2023 at 19:1 Comment(0)
H
0

So you can do these effects with VERTEX_ID in a shader. You'd have to pass a uniform array with information about what you want to do and then process that in the vertex shader.

VERTEX_ID will be 0 for the first vertex, then 1, etc. For the first example, you know each quad has 6 vertices (2 triangles) so you can do some math to know they are the same face and then slightly alter the position to face the camera.

The second example could be done the same way, but with a cube instead of a face. But I don't know the math off-hand.

Handcuff answered 27/4, 2023 at 19:16 Comment(0)
M
0

i'm not sure i'll be able to come with the math to do it but i might need to read those article and source code more carefully. thanks for your answer ,I'll look into that !

Marmoset answered 28/4, 2023 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.