开发者

Can I somehow read/debug the gl_Position in a opengl es 2 (iOS 4.2) vertex shader?

开发者 https://www.devze.com 2023-02-02 03:28 出处:网络
I\'m trying to write a simple vertex shader that uses perspective projection and it works fine, until I set the translation component of the model view matrix. Than nothing gets drawn.

I'm trying to write a simple vertex shader that uses perspective projection and it works fine, until I set the translation component of the model view matrix. Than nothing gets drawn. Vertex shader is very simple:

...
gl_Position = u_projection_matrix * u_model_view_m开发者_JS百科atrix * a_position;
...

I did the math by hand, knowing that the homogenized vertex position should satisfy: -w <= x <= w, -w <= y <= w, -w <= z <= w and it seems correct. If I could read/debug gl_Position I may discover what the issue is, so is there any way to do it?

To summarize: if u_model_view_matrix stays identity, it works fine.


are you sure your matrix are not transposed? Try reversing the multiplication :

gl_Position = a_position * u_model_view_matrix * u_projection_matrix;

0

精彩评论

暂无评论...
验证码 换一张
取 消