VERTEX has the position of vertices in global space but I need the position of the vertices relative to the objects origin.

This is in shaders BTW.

+1 vote

I am afraid there is no such built_in variable. What I did is create uniform vec3 size, and simply pass aabb of the object into it. Knowing maximum size I can make all kinds of relative operations on vertices.

Thanks for your answer but I already figured it out.

I was trying to get a cordinate system like blenders object cordinates where the center of the object has (0,0,0) value and the values increase as you move away from the object. My idea was to use VERTEX built-in but the values are not relative to the origin of the object. My mistake was thinking they in global cordinates but turns out they are actually in something called view space. So what I needed is to transform the VERTEX values to be in global space (which basically is global cordinates) then to local space to get my cordinate system. To do that you just multiply VERTEX with the inverse view matrix then inverse model matrix (world matrix in godot 3.4).

Anyway thanks for taking time to look at my question.

It sounds great, You actually helped me more than I helped You :).

So all I need to do is multiply VERTEX by both of these matrices ?

Do you have a source for VERTEX being in viewspace?

The docs state:

Vertex data (VERTEX, NORMAL, TANGENT, BITANGENT) are presented in local model space.

- All categories
- Engine 32,383