Jump to content

models that always get drawn on top


Rick
 Share

Recommended Posts

Using the framework is there a way to make models always draw on top of everything? For example with doing a 3D gui or something like the red/yellow/blue axis in editors?

 

I see the transparency world which I assume is like a foreground world, but it still has depth to it.

Link to comment
Share on other sites

I'm pretty sure it can be done with another world and buffer, but I'm not 100% sure. Been playing around but not getting far. For the GUI it wouldn't look weird at all really if you parent the plane to camera like you said, but you'd still want that plane to always be on top of all other 3D stuff so no 3D things can come between you and the GUI and you don't really want to have the GUI planes really really close to the camera as that might create some scaling and artifacts.

 

There must be a way to do this. I'm pretty sure it's something with not clearing a camera to another world and maybe removing the depth buffer from that worlds buffer or something.

Link to comment
Share on other sites

I'm pretty sure it's something with not clearing a camera to another world and maybe removing the depth buffer from that worlds buffer or something.

 

But if you would succeed doing that, would the models still be pickable (being a GUI and all)?

desktop: Quad core Q6600 + 4GB + ATI HD4890 + XP

laptop: Dual core T6400 + 4 GB + NVidia 9600M GT + Vista 32

Link to comment
Share on other sites

If they were in a different world I would think/hope so because in the picking you have to give the camera and that world would have it's own camera. I think :)

 

I think you can do in a similar way as Framewerk does to draw main world over background world.

Create a world with top entities. After draw normal entities, do a

 

ClearBuffer(BUFFER_DEPTH);

 

then set top world and render it. As tou have cleared depth buffer all thing are drawn on top. (See DrawBackground function of Renderer.cpp)

Link to comment
Share on other sites

You should put 3D GUI models in the foreground world, then they are always on top of other models, and the transparency works correctly (including cascaded transparency and shadows through them).

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

You should put 3D GUI models in the foreground world, then they are always on top of other models, and the transparency works correctly (including cascaded transparency and shadows through them).

 

Is there a foreground world in framewerk? I have 2.28 version of Leadwerks, in my version only background, main, and transparency worlds exists...

Link to comment
Share on other sites

Hmm, I'll have to play around with a C example, because in C# it didn't seem to work. I assume the only thing I have to do is set the transparency world as the current world, load my models that I want to be in that world, then set the world back to main and then let framework do it's thing?

 

I also didn't think the transparency world worked that way in the framework because in the past when I've asked for wanting models to fade away I was told I would need 1 in the main world and the same model in the transparency world and that it would still have depth in the transparency world, which in this case isn't what we want.

Link to comment
Share on other sites

I think render last doesn't mean render top.

 

To render a world on top of another is necessary to clear zbuffer between renderworld calls.

 

After rendering background world zbuffer is cleared, so main world and transparency world are always on top of background.

 

But after rendering main world zbuffer is not cleared, so transparency (foreground) world is not rendered on top of main world, only is rendered later for good transparency drawing.

 

I think the better is to create a 4th top world that renders after transparency world, and clear zbuffer before rendering it. This will be a topmain world. We can also create a 5th toptransparent world to render top transparent objects after top objects...

Link to comment
Share on other sites

Hey isidisi, have you done this before? Do you know how to get it working along side the framework?

 

 

I have done some time ago but outside framewerk in a simpler way, hidding top objects and rendering others, clearing zbuffer, and then hiding normal objects and rendering top objects... but is the same idea, clear zbuffer and then all thing you render is on top.

 

I checked my code, I used this to draw on top coordinate axis... I rendered main world, lights, then cleared zbuffer and draw axis... but the axis was drawn with only ambient light... that was ok for me... is ok for you too? I'm not sure how to add other kind of light to top objects, but for me was ok only ambient...

Link to comment
Share on other sites

I have done some time ago but outside framewerk in a simpler way, hidding top objects and rendering others, clearing zbuffer, and then hiding normal objects and rendering top objects... but is the same idea, clear zbuffer and then all thing you render is on top.

 

I checked my code, I used this to draw on top coordinate axis... I rendered main world, lights, then cleared zbuffer and draw axis... but the axis was drawn with only ambient light... that was ok for me... is ok for you too? I'm not sure how to add other kind of light to top objects, but for me was ok only ambient...

 

Look I modified framewerk, add some object (as axis) to new TopWorld and it will be rendered on top of all (with ambient light) hope it helps al little at least...

Top.zip

Link to comment
Share on other sites

That works great! I'll play around to get something working with C#. Would be cool if the framework could be more flexible to allow us to define our own layers on the fly and decide in what order they are processed.

 

 

This doesn't seem like you are doing anything with the depth buffer like you were talking about though?

Link to comment
Share on other sites

That works great! I'll play around to get something working with C#. Would be cool if the framework could be more flexible to allow us to define worlds on the fly and decide in what order the worlds work without editing the framework source.

 

Yes look at DrawTop new function(). Is a copy of the other for other layers.

 

But it has

ClearBuffer(BUFFER_DEPTH);

 

line :-)

 

And it would be nice to be possible to tweak the new Framework embedded in the engine... the one we have modified is de 2.28 version code and with time it will get older and without updates of the other...

Link to comment
Share on other sites

I see you have Renderer:DrawTop() that does the drawing. By having it where it is, wouldn't the top layer be subject to post processing effects? It looks like it's drawn after all of that. If this was use for a GUI you wouldn't want that I would think.

 

I assume we can just do the code in the RenderTop() after the normal framework render code runs though.

Link to comment
Share on other sites

I see you have Renderer:DrawTop() that does the drawing. By having it where it is, wouldn't the top layer be subject to post processing effects? It looks like it's drawn after all of that. If this was use for a GUI you wouldn't want that I would think.

 

I assume we can just do the code in the RenderTop() after the normal framework render code runs though.

 

Yes I think so, is run this code after normal stuff... And sure is not be subject of postprocessing efects, is after...

Link to comment
Share on other sites

OK, I was able to get this working with a normal C project and without the framework. Now to get it in C# and with the framework. I think I need access to the global buffer create by the Renderer class so I can change the current buffer back to the global buffer from the back buffer. Not sure if that's exposed though :rolleyes:

Link to comment
Share on other sites

  • 2 months later...

Hi,

I'm trying to do the same thing in LUA. abstraction of my code is something like this :

 

I create a new world and camera :

FSRfw={}
FSRfw.top={}

local wrld=CurrentWorld()
FSRfw.top.world=CreateWorld()
SetWorld(FSRfw.top.world)
FSRfw.top.camera=CreateCamera()
CameraClearColor(FSRfw.top.camera,Vec4(0,0,0,1))
CameraClearMode(FSRfw.top.camera,BUFFER_DEPTH)
SetWorld(wrld)

 

loading a model in new world :

    SetWorld(FSRfw.top.world)
   object.test=LoadModel("abstract::Environment_CharityBox.gmf",model)
   SetWorld(fw.main.world)

 

and it's my rendering loop:

while KeyHit(KEY_ESCAPE)==0 do    
   fw:Render()

   local wrl=CurrentWorld()
   SetWorld(FSRfw.top.world)
   SetEntityMatrix(FSRfw.top.camera,GetEntityMatrix(fw.main.camera))
   ClearBuffer(BUFFER_DEPTH)
   RenderWorld()
   SetWorld(wrl)

   fw:Update()

   wrl=CurrentWorld()
   SetWorld (FSRfw.top.world);
   UpdateWorld( AppSpeed() );
   SetWorld(wrl)

   Flip(0)
end

 

but it doesn't make any difference!

it's funny! if I remove "RenderWorld()" line, my test-model renders anyway!

 

what is wrong in my code?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...