Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Object render sequence

Author
Message
bergice
19
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 13th Nov 2010 01:39
Hey does anyone know if it is possible to define objects render sequence so it is possible to control that an object will render in front of another, and still make it render behind other objects?

51fa1db0ec7c4af52d93a6f5d0e86bc5


Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 13th Nov 2010 01:52
I don't know dude. The help files aren't all that clear. It's certainly a very important thing to be able to set. At one point I think it drew things in order of texture number, but I think with the current version it's different. Sucks because it screwed up the explosion rendering in my big project.

I have tinkered a bit and think that the object transparency flag has an effect, but when two objects have the same flag, I don't know which is drawn first.

If someone could provide some info I'd be very interested to hear it.
bergice
19
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 13th Nov 2010 13:03
I was thinking about using several cameras to separate the object rendering but this proves to be too slow so it's not an alternative.

51fa1db0ec7c4af52d93a6f5d0e86bc5


Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 13th Nov 2010 13:57
Quote: "Hey does anyone know if it is possible to define objects render sequence so it is possible to control that an object will render in front of another, and still make it render behind other objects?"

Yes it is possible, but it requires a good organization of IDs for textures or objects, or at least that's how I do it

By default any object (Object_A) will appear behind any other objects with a higher Texture ID, if you set on it Disable Object ZRead:



Here is a full example, hold the spacekey to Enable/Disable Object ZRead over the plane object:



In other words, disable object zread gives priority by image numbers. The objects you want drawn behind others need to have the lowest image numbers.

Quote: "At one point I think it drew things in order of texture number, but I think with the current version it's different. Sucks because it screwed up the explosion rendering in my big project."

Well, I haven't updated to 7.5, but here everything works fine. Try the example above to see if the plane stays behind the sphere when it has disabled object zread.

There was an improvement regarding all this since DBPro 7.3 (I think). It was the Set Global Object Creation mode. It seems that it allows to use the Object ID instead of the Texture ID.
So all that has been said will be true but for Object IDs, instead of Texture IDs, if you set:



This is what the manual says about it:

Quote: "SET GLOBAL OBJECT CREATION

This command will set the creation mode of the object manager.

Syntax
SET GLOBAL OBJECT CREATION Creation Mode
Parameters
Creation Mode
Integer
A Creation Mode of 0 is the default, whereas 1 will force the objects to share vertex buffers, 2+3 stops texture sorting, 4+5 uses sort by number and 6+7 sorts by depth.

Returns

This command does not return a value.

Description

A Creation Mode of zero is the default, whereas a value of one will force the objects to share vertex buffers where possible. Vertex buffers are the internal memory resource the
engine uses to store all geometry data before it is rendered to the screen. By sharing vertex buffers, you can gain performance on some 3D cards, but not others. By default vertex
buffers are not shared for the sake of widest compatibility, better generic performance and less prone to buffer overruns. Additionally, objects that share vertex buffers take longer
to delete as they must be disentangled from its buffer on removal."



And this is the advice of Mr. Lee Bamber:

Quote: "Set Global Object Creation 2

Add this at the top of your program and all objects handled in your application use 'sort by object order' rather than 'sort by texture number'.
What this means is that there is no expensive bubble sort each time new objects are introduced into the engine, and so loading and main loop performance may increase slightly.
The downside is that the GPU will be asked to continually swap textures back and forth with no care to render all objects that share a common texture.
In some cases, this will degrade performance based on your scene complexity. Either way, it is another little tweak you may wish to experiment with to gain a few extra FPS from your projects."


I hope all this gives some light over the subject. I use the default texture sorting when needed, as described at the beginning

bergice
19
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 13th Nov 2010 16:07
Thanks Morcilla, this is just what i was looking for.

Just had to load the images in correct order and disable the zread ^^



51fa1db0ec7c4af52d93a6f5d0e86bc5


Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 13th Nov 2010 16:08
Thanks. Very informative post.
I think transparency modes may change things. Should do some experimentation.
Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 13th Nov 2010 16:25
Glad that it helped, tell us any results

Login to post a reply

Server time is: 2026-07-21 18:58:20
Your offset time is: 2026-07-21 18:58:20