java - Math Vector Matrix multiplication -


as far know opengl viewport's coordinate system 2dimensional , ranges between -1 , 1 in x , y direction.to map 3dvector's position "world space" viewport coordinates write f.e

"gl_position=umodelviewprojectionmatrix * vposition " in fragment shader.

my question how can multiply 3dvector 4d matrix , 2dvector result , - more important - there funktion on cpu side (especially libary/ class java in android)

just clarifying few terms:

  • the viewport region within window you're drawing to. it's specified in pixels.
  • the rasterizer needs coordinates in normalized device coordinates -1 1. maps these viewport area.
  • gl_position must take 4d vector in clip space. space triangles clipped in (for example , particularly if intersect near plane). separate normalized device coordinates because perspective divide hasn't happened yet. doing pos /= pos.w, loses information opengl needs clipping, depth , interpolation.

this brings me answer. you're correct, can't multiply 3d vector 4x4 matrix. it's using homogeneous coordinates , vector 4d 1 @ end. 4d result clip space. rasterizer creates fragments 2d position, w used perspective correct interpolation , z interpolated depth testing.

finally, modelviewprojection matrix implies introduction of 3 more spaces. these purely convention reasons exist. mesh vertices given in object space. can place objects in world model transformation matrix. provide camera position , rotation in world view matrix. projection matrix defines viewing volume scaling clip space. reason separate view , projection matrices operations in eye space such lighting calculations.

i won't go more detail, sets on right track.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

php - Find a regex to take part of Email -

javascript - Function overwritting -