creating a shader that gives an object custom vertex normals based off a displacement map in Godot, from world position

Godot Version

4.3

Question

` Can I transfer vertex normals from a mesh, like in blender (see video at timestamp https://youtu.be/M4kMri55rdE?t=479)

Or can I create a shader that gives an object custom vertex normals based off a displacement map in Godot, from world position?

is this possible?

That’s a pretty cool technique!

So, depends a bit how you want to do it.

The most similar way to the blender workflow would be to write a tool that creates a multimesh instance and gives it a texture, and then the grass would have a custom shader that reads from that texture. That way each “chunk” of grass has its own texture. Alternatively, you can generate a single meshinstance. Just be careful when using multimesh and a single mesh, that you don’t use a shader with alpha and without cutout: it will mess up the drawing order.

Thanks for the reply, Im still new to godot so Im not entirely sure how to go about doing that. I was able to use multimesh to spawn grass with custom colors from a texture.

I tried looking at the doc but couldnt find anything relating to transfering normals, if you have any links it would be greatly appreciated.

You can’t really transfer normals. The only info you can pass into a multimesh is

  1. transform
  2. color
  3. custom vec4

here’s the doc of the available functions

I figured so, can I do anything with the normals inside the multimesh? is there a function for that

You can manipulate normals in the shader, for example if you wanted you could pass the normals into the custom vector and in the shader assign the normals from the custom vector

1 Like

is there a doc for this, thanks again for the replies :slight_smile:

Nothing specific to this. The page i linked before has details on how to make custom data work (needs to be enabled) and then in the vertex shader you read from INSTANCE_CUSTOM and put it into NORMAL