Confirming 32bit color output via jPCT

Started by K24A3, October 05, 2012, 05:15:44 PM

Previous topic - Next topic

K24A3

Here's the log:

10-12 09:39:39.422: E/AndroidRuntime(1567): java.lang.RuntimeException: [ 1350034779427 ] - ERROR: Failed to load and compile fragment shaders!
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.Logger.log(Logger.java:189)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.GLSLShader.loadProgram(GLSLShader.java:764)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.GLSLShader.preInit(GLSLShader.java:276)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.GL20.setShader(GL20.java:336)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.GLRenderer.setShader(GLRenderer.java:510)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.CompiledInstance.render(CompiledInstance.java:159)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2244)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.World.draw(World.java:1321)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.World.draw(World.java:1083)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.ES2Test.Scene.updateFrame(Scene.java:293)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.ES2Test.Scene.onDrawFrame(Scene.java:365)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at com.threed.jpct.ES2Test.HelloShader$MyRenderer.onDrawFrame(HelloShader.java:206)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
10-12 09:39:39.422: E/AndroidRuntime(1567):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


Attached are the available functions in the Light class
..by typing sun.

[attachment deleted by admin]

EgonOlsen

It's definitely there...i just checked it with the latest beta version. Check your project setup. Maybe you are referencing some old version of the library.

About the shader error: Before that part, there should be some output from the driver that tells the actual problem.

K24A3

#32
You were right, the build path was pointing to the jPCT lib in the original HelloShader, which was earlier than v1.25 (you may want to update the lib in the HelloShader folder of the zip on the website), but running the app tells me it's using v1.26 in logcat during runtime - eclipse bug I suppose.

I added sun.setDistanceOverride(10000f) but the output is totally black, which is why I tried increasing the ambientColor in the shader. Below is the additional log info, which I assume it's because ambientColor is a uniform type, not a varying type?

Edit: It's totally black on the Tegra3 as well.


01-02 12:07:46.060: I/jPCT-AE(1088): Compiling shader program!
01-02 12:07:46.070: I/jPCT-AE(1088): Could not compile shader 35632: <invalid atom 65535>(30) : error C7563: assignment to uniform ambientColor
01-02 12:07:46.070: I/jPCT-AE(1088): <invalid atom 65535>(31) : error C7563: assignment to uniform ambientColor
01-02 12:07:46.070: I/jPCT-AE(1088): <invalid atom 65535>(32) : error C7563: assignment to uniform ambientColor
01-02 12:07:46.070: I/jPCT-AE(1088): [ 946814866081 ] - ERROR: Failed to load and compile fragment shaders!

EgonOlsen

You have to use a close distance for the override like 0.001 or similar. It's about making the first light source the closest one, not the farest.

About the uniform: Just copy it into a local variable and use that one instead.

K24A3

I tried 0.001 with a light nearby and both devices are showing black textures.

Not to worry, I'll use the original shader since I need multiple light support and since it only fails on Mali.

EgonOlsen

So...finally...i had to buy K24A3's Galaxy Note to track this down... ;) The solution is, that Mali isn't very good (read: fails spectacular) on calculating the square root for higher values. Higher values mean anything larger than 655xx in this case. If you take the square root of a higher value, you'll get rubish. To fix this, you can change this line in the fragment shader:


float distSqr = dot(lightVec[0], lightVec[0]);


to this


float distSqr = min(65500.0, dot(lightVec[0], lightVec[0]));


...and it should work again. Of course, this isn't a real solution as it simply clamps the values. A better solution would be to get rid of the square root in the following line, but i can't be bothered with that right now... :)

K24A3

#36
Thanks Egon the shader looks normal now.

However the lighting direction on the objects seems to be in reverse or incorrect.  Can you replicate this on the Note?

Blue dot is the light source.

[attachment deleted by admin]

EgonOlsen

Only on Mali or on all devices? Can you send me a current version of the test case? I've modified mine in the process to an extend that i can't use it anymore to test this particular thing... ::)

K24A3

I'll send the test case via email now.

Seems I misplaced the charging cable for the Tegra3, I'll need a moment to find it.

K24A3

The Tegra3 is terribly flat needing a good hour to get up and running. But I'm seeing the same effect in the Emulator.

Perhaps you can try it on your tablet?

K24A3

Emulator with four spheres 300 units respectively away from the light at 0,0,0

Tegra3 is still afraid of booting google's robot

[attachment deleted by admin]

EgonOlsen

It's your globe model. It seems to have clockwise order in it's polygon definitions, i.e. jPCT culls the front faces and what you see are the lit back faces. Just add

oClonedSphere.invert();

and it will look fine again.

K24A3

Hmm where did that sphere come from.. not to worry it works fine using invert.

Thanks for all your help I can finally continue with this project :)