Hi folks,
Relative newbie here.
I’m working on the Android platform with GLES2.0.
I wrote my game using floating point colors specs and all was working great.
Then I decided to try to optimize speed and memory, and re-formatted my colors as bytes packed into in an integer.
My game mostly works the same, but one feature is now gone: my triangles do not respond to the gl_FrontFacing variable as before.
Here’s my fragmentShader code:
private final String mFragmentShader =
"precision mediump float;
" +
"varying vec4 vColorValue;
" +
“void main() {
" +
" if(gl_FrontFacing) {
" +
" gl_FragColor = 0.5*vColorValue;
" +
" }else {
" +
" gl_FragColor = vColorValue;
" +
" }
;”+
"}
";
Now that I have colors entering the system as bytes packed ABGR into an integer, the front facing triangles are no longer muted, as was working using floating point color specs.
But I know that gl_FrontFacing is still in effect: if I change 0.5 to 0.0, the front facing triangles disappear.
Is this just an expected result or have I done something stupid?
I’m having a devil of a time trying to unearth the answer from internet searches.
Should I use some special data type in my vertex attribute call?
GLES20.glVertexAttribPointer(maColorValueHandle, 4, GLES20.GL_UNSIGNED_BYTE, false,
TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
I’ve tried a few that I can see in the docs, but this is the only one that works at all.
Any advise would be appreciated. Thanks!
Thender