How to do I make a shader a billboard? (Face the player)

:bust_in_silhouette: Reply From: mrdunk

Hi, i was just playing with exactly this.
Here’s what i came up with:

void vertex() {
    mat4 modified_model_view = VIEW_MATRIX * mat4(
        INV_VIEW_MATRIX[0],
        INV_VIEW_MATRIX[1],
        INV_VIEW_MATRIX[2],
        MODEL_MATRIX[3]
    );
    MODELVIEW_MATRIX = modified_model_view;
}

[EDIT]
I mean the billboard part.
Add it to your existing shader and you should be good.

So playing with shaders some more,
i’ve found out in Godot 4.0, if you create a “New StandardMaterial3D” with the parameters you are interested in, you can then “Convert to ShaderMaterial” and see the raw shader code.

I presume there are similar options available for V3.X as well.

I’ve just used this to work out how to retrieve part of a texture. I think you’ll be able to see the raw billboard implementation this way too.

mrdunk | 2023-05-02 01:05

Converting it did the trick! Thank you brother

Scorch | 2023-05-02 08:22

1 Like