jpct-ae noob question

Started by octav_ro, August 10, 2012, 10:26:10 AM

Previous topic - Next topic

octav_ro

hi, i am very new to 3d and jpct, can you tell me how do i change the default render order for my scene objects ?

EgonOlsen

You can't. It's up to the engine to decide about the render order. That's one major point in using it. Why would you want to?

octav_ro

i have some baked shadows that do not  appear correct when the objects are stacked one over another, this could be solved by rendering the objects above first.

EgonOlsen

Do you have a screen shot of this?

octav_ro

see attached

[attachment deleted by admin]

EgonOlsen

And that shadow is...what? A plane with an alpha blended shadow texture on it?

octav_ro

yes is a plane, with transparent texture, i have used

gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

probably im doing smth wrong but because of my limited knowledge i donno where to look.

EgonOlsen

I'm confused now...you are using jPCT-AE for this? Then why are you fiddling around with gl commands directly? You are not supposed to do that and if you want or have to do that, why are you using a 3d engine in the first place?

octav_ro

i would do it without gl commands if i knew how, anyway the only gl commands i have are these:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
      gl.glEnable(GL10.GL_DITHER);
      gl.glEnable(GL10.GL_BLEND);
      gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
      Config.glIgnoreNearPlane = false;
      gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
      gl.glClearColor(m_backColor.getRed(), m_backColor.getGreen(), m_backColor.getBlue(), m_backColor.getAlpha());
      gl.glColorMask(true, true, true, true);
      gl.glDisable(GL10.GL_CULL_FACE);
      gl.glDisable(GL10.GL_DEPTH_TEST);
      gl.glDepthMask(true);
   }

i use jpct to load, place and move objects around, set up the world, lights and camera + all the rendering, the only gl direct stuff is over there.

EgonOlsen

None of these makes any sense in the context of the engine. Scratch off all this gl related code.

Is the drop shadow a single plane with a texture with alpha applied to it? If not, make it one, i.e. separate it from the lamp.
If it is, enable transparency by using <shadowPlane>.setTranspareny(0...) and maybe adjusting transparency mode. You might have to offset it from the ground a little to prevent depth buffer issues.

octav_ro

tx for your responses, but removing blending makes things even worse, so if i remove:

//gl.glEnable(GL10.GL_BLEND);
//gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

i get the stuff attached, the objects create holes inside other object.

the shadow plane is part of the mesh and cant be separated there are hundreds of models like it, so modifying transparency will cause a the whole object to loose transparency so i cant use setTransparency on the whole object.

[attachment deleted by admin]

EgonOlsen

That's because the alpha channel of the texture gets written into the frame buffer, which is normal behaviour...but obviously unwanted in this particular case. Which OpenGL ES version are you using 1.x or 2.0?

octav_ro


EgonOlsen

Stupid me...i should gave guessed it from the gl calls...anyway, you have to disable writing into the alpha channel to fix this. This is one of the very seldom occasions where i suggest to call gl directly, but it has to be done in a way that doesn't interfere with the engine's pipeline.

To do this, implement IRenderHook and do


gl.glColorMask(true,true,true,false);


in the beforeRendering()-method and


gl.glColorMask(true,true,true,true);


in the afterRendering()-method. Then add this hook to the objects that have this problem.

octav_ro

adding the hook causes another problem without fixing the previous, if i cant help with more details or more code let me know, im not sure what is wrong here and for sure i can't figure out for myself.

ty very much for your time.

[attachment deleted by admin]