Author Topic: jpct-ae noob question  (Read 8321 times)

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
jpct-ae noob question
« on: August 10, 2012, 10:26:10 am »
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 ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: jpct-ae noob question
« Reply #1 on: August 10, 2012, 11:28:10 am »
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?

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jpct-ae noob question
« Reply #2 on: August 10, 2012, 11:49:44 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: jpct-ae noob question
« Reply #3 on: August 10, 2012, 12:12:34 pm »
Do you have a screen shot of this?

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jpct-ae noob question
« Reply #4 on: August 10, 2012, 12:20:30 pm »
see attached

[attachment deleted by admin]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: jpct-ae noob question
« Reply #5 on: August 10, 2012, 01:32:27 pm »
And that shadow is...what? A plane with an alpha blended shadow texture on it?

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jpct-ae noob question
« Reply #6 on: August 10, 2012, 01:34:34 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: jpct-ae noob question
« Reply #7 on: August 10, 2012, 02:04:45 pm »
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?

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jpct-ae noob question
« Reply #8 on: August 10, 2012, 02:07:47 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: jpct-ae noob question
« Reply #9 on: August 10, 2012, 02:14:58 pm »
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.

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jpct-ae noob question
« Reply #10 on: August 10, 2012, 03:12:21 pm »
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]

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: jpct-ae noob question
« Reply #11 on: August 10, 2012, 04:11:29 pm »
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?

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jpct-ae noob question
« Reply #12 on: August 10, 2012, 04:18:35 pm »
im using 1.x

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: jpct-ae noob question
« Reply #13 on: August 10, 2012, 05:14:23 pm »
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

Code: [Select]
gl.glColorMask(true,true,true,false);

in the beforeRendering()-method and

Code: [Select]
gl.glColorMask(true,true,true,true);

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

Offline octav_ro

  • byte
  • *
  • Posts: 13
    • View Profile
Re: jpct-ae noob question
« Reply #14 on: August 10, 2012, 06:35:53 pm »
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]