Render to texture always include the orthoqueue

Hello everybody,



With the new cvs version, it seems that the render to texture include nodes that are in the ortho queue mode even if it’s not attached to the same scenegraph of the camera used to render.



If you launch TestCameraMan you will see that the debug information are rendered in the little window too.



:? I don’t know if it’s normal but it was not like that before. I used this technique to zoom some object of my game and now i have all the game’s hud render with the object…



Otherwise, i’ve got a huge boost of performance since last check out, good work ! :slight_smile:



bye,



Adenthar.

Hey, this is a feature, not a bug. XD



Actually, it is because of how texture renderer now uses the renderqueue. If anything is placed in the queue prior to rendering something to texture, those items will end up in the texture and not in the scene.



You can verify this in two ways. First, you can see that it is indeed only in the texture by forcing a test (TestCameraMan for example) to update the texture on every round like so:


  protected void simpleRender() {
    lastRend += tpf;
//    if (lastRend > .03f) {
      tRenderer.render(model, fakeTex);
      lastRend = 0;
//    }
    display.getRenderer().draw(monitorNode);
  }



Another way to see this is to actually fix the problem... I've done this for you by updating SimpleGame's render method and moving the rendering of the fps text to after the call to simpleRender, thus pulling it out of the queue until after the texture render occurs. The diff is:

OLD:

      /** Draw the fps node to show the fancy information at the bottom. */
    display.getRenderer().draw(fpsNode);
      /** Call simpleRender() in any derived classes. */
    simpleRender();



NEW:

      /** Call simpleRender() in any derived classes. */
    simpleRender();
      /** Draw the fps node to show the fancy information at the bottom. */
    display.getRenderer().draw(fpsNode);



So, check your code and fix the order of the calls... Either that or call renderer.renderQueue() before you render to texture (possibly screwing up some ordering in the scene), or I'm guessing there are other possibilities too.

Hope that helps!

Thanks again Renanse,



it’s a very good explanation and i understand now my problem.

I have tried to change the order of render alas it’s not suffficient (now i render nothing on the texture ! :()

It seems to me that the solution i have made is not the good one with this new version of CVS.



Here’s what i need to do :

I want a second camera which can look at an object which is not always in the main camera field of view.

Then i want to render in a texture what this second camera sees

Finally this texture must be attached to my hud and rendered



Do you think it’s possible ?

Is there a simple solution to do this ?



bye,



Adenthar.

Hmm, yes that should be possible, it’s not all that different from the camera man test except for the part about it being off the main view. Have you tried moving the object into the main camera view just to see if your culling is being based on the main camera?

Yes, it’s one of my problem,



in fact i don’t know if the code :



monitorCam = new CameraNode("monitorcamera_node", monitorRenderer.getCamera());



will create a second camera or not... :?

I have made a very inelegant solution (which doesn't work anymore by the way ;) ) my solution was to clone the object, put the clone in another scenegraph and try to render this scenegraph on the texture but not in the main view, i know it sounds very awful solution ://

by the way, your answers are so fast that it looks like web chat instead of web forum !! :P

Adenthar.

Ok, I found a bug in the newest texture render code. When passing in an object to render that is part of a scene graph rendered elsewhere, if the object’s parent was culled elsewhere, it will also be culled in the texture rendering. This is due to how we cache frustum results for better culling performance. Here is the line we get caught up on:


        frustrumIntersects = (parent != null ? parent.frustrumIntersects
                : Camera.INTERSECTS_FRUSTUM);



In the texture renderer, we didn't render the parent, thus the frustumIntersects field is leftover from some other rendering.

I've fixed this by adding a setLastFrustumIntersection(int intersects) method and setting the parent (if exists) to INTERSECTS_FRUSTUM... which is harmless to the other renderings of the same scene.

Bottom line, you should now be able to use texture renderer to render a subpart of a scene without cloning or whatnot. I've tested this by moving the camera and monitor nodes in TestCameraMan so that the main camera can not see the man. Before the fix, the monitor showed only blackness. With the fix in place you can now see the man in the monitor. :)

your speed is amazing… 8)



ok i’m going to check from cvs and try to make it work in my game,



thanks a lot,



Adenthar.

So…



I’ve just check out from cvs and try TestCameraMan, it works perfectly well !



So i updated my code and… cullling is always tied to the main camera ! :’( I don’t know what i’m doing wrong, i have tried to be as near as possible with the TestCameraMan Code…



any clue ?



thanks,



Adenthar.

Send me a small example and I’ll debug it :slight_smile:

Ok, if i don’t find i will make this…



thanks again,



Adenthar.