Jump to content

how can I get a object's world position in a vertex shader?


photo

Recommended Posts

I'm trying to create some new shaders, but I don't know how to get a world position of an object, I've also noticed there is a shader variable s_transform, but the shader code about it seems a little confusing.

 

so the simple question, how to get a object's world position in a vertex shader?

 

and these kind of objects might be instanced.

Link to comment

Use vertex_leaf.shader as template.

The world position is: "float3 world_vertex = mul4(s_imodelview,vertex.xyz);"

You will have rendering artefacts on big distances because of floating point errors.

Link to comment
×
×
  • Create New...