2014년 4월 25일 금요일

Vertex Shader problem in Galaxy S Mali GPU


Google document 의 문제인가.
Galaxy S Mali GPU 의 문제인가.


http://developer.android.com/training/graphics/opengl/index.html


http://stackoverflow.com/questions/22384272/android-opengl-es-not-rasterizing-matrix-multiplication-switched




------- EDIT : SOLUTION FOUND -------
Okay, I found the error. The google document shows a "wrong" the multiplication of the matrices in the vertex shader:
uniform mat4 uMVPMatrix;
attribute vec4 vPosition;
void main() {
   gl_Position = uMVPMatrix * vPosition;
}
This doesn't seem to be a problem for my old Galaxy S1 but somehow the S3 (or the Mali GPU) is picky about this. I changed the order of multiplication to this:
uniform mat4 uMVPMatrix;
attribute vec4 vPosition;
void main() {
   gl_Position = vPosition * uMVPMatrix;
}
And it works (also on the S1). Still not sure why the S1 works fine with both versions but this solves the problem.




--------------------------------------------------------
Google document 는 문제가 없고,
Galaxy S Mali GPU 도 문제가 없다.


translate 까지 정확히 동작하려면 matrix 가 앞에오는 코드가 맞다.

uniform mat4 uMVPMatrix;
attribute vec4 vPosition;
void main() {
   gl_Position = uMVPMatrix * vPosition;
}



model matrix 에서 rotation, translation 까지 정상적으로 동작하게하려면,
 matrix 가 앞에오는 다음 코드가 맞다.


gl_Position = uMVPMatrix * vPosition;



viewport 설정.
view matrix 설정.
projection matrix 설정.
model matrix 설정.


gl_Position = vPosition * uMVPMatrix;

Samsung Galaxy note 8.0 SHW-M500W 에서 위 코드만 정상적으로 출력되고,  matrix 가 앞에 오는 맞는 코드는 출력되지 않는것처럼 보이는 현상은 projection matrix 가 잘못 설정되어 있거나, matrix 를 곱하는 순서가 잘못되었거나, 같은 matrix 를 입출력에 같이사용하거나 할때 나타난다.

matrix 가 뒤에 오는 위 코드를 사용하면 translate 가 되지 않는다.


model matrix 에서 rotation, translation 까지 정상적으로 동작하게하려면,
 matrix 가 앞에오는 다음 코드가 맞다.


gl_Position = uMVPMatrix * vPosition;



댓글 없음:

댓글 쓰기

Eclipse hangs at the Android SDK Content Loader

eclipse -clean