steve3d Posted October 19, 2011 Share Posted October 19, 2011 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
frustum Posted October 19, 2011 Share Posted October 19, 2011 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
steve3d Posted October 19, 2011 Author Share Posted October 19, 2011 :) I mean world position of object not vertex. Link to comment
frustum Posted October 19, 2011 Share Posted October 19, 2011 The answer in the vertex_leaf.shader file: float3 center = mul4(s_imodelview,float3(row_0.w,row_1.w,row_2.w)); Link to comment
Recommended Posts