Transform to NDC, calculate and transform back to worldspace
问题 I have a problem moving world coordinates to ndc coordinates than calculate something with it and move it back inside the shader. The Code looks like that: vec3 testFunc(vec3 pos, vec3 dir){ //pos and dir are in worldspace, convert to NDC vec4 NDC_dir = MVP * vec4(dir,0); vec4 NDC_pos = MVP * vec4(pos,1); NDC_dir /= NDC_dir.w; NDC_pos /= NDC_pos.w; //... do some caclulations => get newPos in NDC //Transform newPos back to worldspace vec4 WS_newPos = inverse(MVP) * vec4(newPos,1); return WS