Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MrAdam

Pages: [1] 2 3 4
1
Support / Re: framebuffer getPixels()
« on: July 03, 2012, 01:49:51 pm »
And please try to add

Code: [Select]
precision highp float;

to the fragment and the vertex shader to see if that changes anything...
Already tried that when you suggested it in the other thread ;-)
Didn't make a difference

2
Support / Re: framebuffer getPixels()
« on: July 03, 2012, 01:01:04 pm »
I'm not sure if i'm still able to follow...

  • S2 and S3 both render black cars when using the custom shader
  • S2 problem goes away if you don't use the custom shader but the default ones of jPCT-AE
  • S3 problem doesn't go away when you disable the shader (100% sure?)
  • S2 problem goes away when updating to Android x.y (which?)


It that correct?

S3 is always black, no matter what shader is used/not used.
S2 is always black, no matter what shader is used/not used, except on some versions of Android.
I haven't been able to confirm which versions though :-/

3
Support / Re: framebuffer getPixels()
« on: July 03, 2012, 11:44:08 am »
Have you tried to revert to jPCT's default shaders on these devices? Does that render correctly?
I tried that, yes. The car is still 100% black like in the video. And 100% lit up like a cone light when it gets very close to one light.

4
Support / Re: framebuffer getPixels()
« on: July 03, 2012, 11:11:52 am »
Again.. sorry for the delay. Been busy with a new project.
Anyways, I know there's problems with the scaling, and parts of the app crashes due to memory limit being reached.

But the main problem is the black car. It won't work on the Galaxy S III either.

5
Support / Re: framebuffer getPixels()
« on: June 20, 2012, 11:57:39 am »
Sorry, I forgot to enable notifications, didn't see your post until now
The app is available here: https://play.google.com/store/apps/details?id=bmw.makeityours

Although, I still haven't been able to fix the black model problem. It appears only on Galaxy S II and S III devices.
I know it's the GPU, we had the same problem with the old engine (jMonkeyEngine) but it got fixed in an update.

Got a video illustrating it: http://vimeo.com/44378417

6
Support / Re: framebuffer getPixels()
« on: June 04, 2012, 11:31:59 am »
...so it's some problem with the shader code or (more likely) the shader compiler creating stupid code...
I don't think Im gonna find a solution to this, it's most likely a crappy driver.
Updating the phone to 4.x solves the problem ^^

7
Support / Re: framebuffer getPixels()
« on: June 04, 2012, 11:05:35 am »
Disabling the shader certainly helped. Its no longer in nightrider mode ^^

8
Support / Re: framebuffer getPixels()
« on: June 02, 2012, 05:39:15 pm »
I managed to make the change a bit ealier than expected. Please try this jar: http://jpct.de/download/beta/jpct_ae.jar
Sorry for the late response :-/ Had a bit of a stressing few days lately, we just completed the project.
Anyways, we have been getting reports from users using the Galaxy SII having a completely black car:


I believe this might be due to the phones GPU having a different OpenGL implementation.
Do you have any idea what might cause this?

9
Support / Re: framebuffer getPixels()
« on: May 25, 2012, 03:17:33 pm »
Yes, or course. But i thought it might be better than nothing...
It certainly is :P

10
Support / Re: Viable engine?
« on: May 25, 2012, 03:14:49 pm »
Here's a rough port of the shader in your link:

vertex:
Code: [Select]
uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;

uniform vec3 lightPositions[8];
uniform vec3 diffuseColors[8];

attribute vec4 position;
attribute vec3 normal;
attribute vec2 texture0;

varying vec3 vnormal;
varying vec4 pos;
varying vec4 diffuseColor;
varying vec2 texCoord;

void main() {
  vnormal = normalize(modelViewMatrix * vec4(normal, 0.0)).xyz;
  pos = modelViewMatrix * position;
  diffuseColor = vec4(diffuseColors[0], 0.0);
  texCoord = texture0.xy;
  gl_Position = modelViewProjectionMatrix * position;
}

fragment:
Code: [Select]
precision highp float;

uniform sampler2D textureUnit0;
uniform vec3 lightPositions[8];

varying vec3 vnormal;
varying vec4 pos;
varying vec4 diffuseColor;
varying vec2 texCoord;

void main() {
  vec4 color = texture2D(textureUnit0, texCoord);
 
  // Adjust this...
  vec4 matspec = vec4(0.8, 0.8, 0.8, 0.0);
  vec4 lightspec = vec4(1.0, 1.0, 1.0, 0.0);
  float shininess = 0.45;
  // ...
 
  vec4 lpos = vec4(lightPositions[0], 0.0);
  vec4 s = -normalize(pos-lpos);

  vec3 light = s.xyz;
  vec3 n = normalize(vnormal);
  vec3 r = -reflect(light, n);
  r = normalize(r);
  vec3 v = -pos.xyz;
  v = normalize(v);
   
  vec4 diffuse  = color * max(0.0, dot(n, s.xyz)) * diffuseColor;
  vec4 specular = lightspec * matspec * pow(max(0.0, dot(r, v)), shininess);

  gl_FragColor = diffuse + specular;
}

To get different specular effects, adjust the settings inside the comments...especially the shininess value. Note that you can't use this shader on transparent objects as it is. You would have to write a version that takes alpha into account if that is needed.

Hope this helps...
I noticed that this shader only works with one light at a time. Is it hard to modify it to work with several lights?

11
Support / Re: framebuffer getPixels()
« on: May 25, 2012, 02:56:37 pm »
An easy hacky "fix" for now, would be to set alpha according to the background color. I.e. all black pixels are transparent, all others opaque.
True. Ill try it and see how it looks.
Looks horrible :P

12
Support / Re: framebuffer getPixels()
« on: May 25, 2012, 02:41:24 pm »
An easy hacky "fix" for now, would be to set alpha according to the background color. I.e. all black pixels are transparent, all others opaque.
True. Ill try it and see how it looks.

13
Support / Re: framebuffer getPixels()
« on: May 25, 2012, 02:17:18 pm »
...looks like i'm nulling the alpha values in the code that flips the image after grabbing it from the frame buffer. I'll upload a fixed version later today.
Not to rush you or anything, but do you know when today you might be able to look at it?

14
Support / Re: Viable engine?
« on: May 25, 2012, 11:02:46 am »
...so world is null in this case, not model. Otherwise, it would crash inside of the method and not when trying to call it.
Well yeah, but it shouldn't reach that point without having created world. "world = new World();" doesn't fail

EDIT: Never mind, fixed it by initializing the world before starting the thread:
public World world = new World();

15
Support / Re: Viable engine?
« on: May 25, 2012, 10:52:15 am »
Ok, but that doesn't make any sense...there are no threads involved. And even if there were...you can't change a returned instance afterwards, i.e. if it returns null, it will stay null forever. So this loop will never be entered if the loading goes fine and it will never terminate if null will be returned.

Maybe it's something else...are you trying to render the model while still loading/adding it? Can you post the null pointer exception you are getting?
This is happening at application launch and when user changes application language, way before the activity with the 3D part.
Here's the error:
Code: [Select]
05-25 10:46:42.650: E/AndroidRuntime(4411): FATAL EXCEPTION: Thread-949
05-25 10:46:42.650: E/AndroidRuntime(4411): java.lang.NullPointerException
05-25 10:46:42.650: E/AndroidRuntime(4411): at bmw.makeityours.BMWApplication$ModelLoaderThread.run(BMWApplication.java:81)
Here's the code:
Code: [Select]
private class ModelLoaderThread extends Thread {

        String modelName = "";

        public ModelLoaderThread(String modelName) {
            this.modelName = modelName;
        }

        @Override
        public void run() {
            isModelLoading = true;
            if (world != null) {
                world.removeAll();
                world.dispose();
                world = new World();
            }
            if (model != null) {
                model = null;
            }
            try {
                model = Loader.loadSerializedObjectArray(getAssets().open(modelName + ".png"));
            } catch (IOException e) {
                e.printStackTrace();
            }
            world.addObjects(model);
            world.buildAllObjects();
            world.compileAllObjects();
            isModelLoaded = true;
            isModelLoading = false;
        }
    }
The line causing the crash is the "world.addObjects(model);"

Pages: [1] 2 3 4