Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Renderqueue / shader system design question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 cozzie   Members   -  Reputation: 1654

Like
1Likes
Like

Posted 01 February 2014 - 04:34 PM

Hi,
Say you have the following contents in a 3d scene/ level:

- x meshes
- y mesh instances of x
- z renderables, being submeshes of x/y
- a unique materials
- shared over the x meshes and used by the z renderables
- of a materials, b of them have alpha maps/ need blending

- I have a different shader / set of states for the materials with/ without alpha maps.

My questions:
- how would you sort out not blended and blended, by material or by renderable?
(by material would mean lots of complexity and switching vertex/indexbuffers a lot for meshes that have both rederables opaque and blended)
- with todays hardware, would you have 2 different shaders or simply set renderstates when you encounter the materials with alpha map and branch in the shader, to only use alphamap if some parameter per material says yes or no? (difficult to tell unless I add some custom vaue, not in my current X file meshes, exprted from max
- or even a step further, just don't distinguish and keep blending enabled always and only use the alpha map if its set as texture in the stage (downside would be that I have to find a way to sort renderables back to front which use materials with alpha map/blending)
- probably it's a good idea to sort the materials to all opaque first and then the ones with blending/ alpha map

Any input is appreciated

Sponsor:

#2 Dawoodoz   Members   -  Reputation: 331

Like
0Likes
Like

Posted 01 February 2014 - 05:13 PM

Draw opaque from close to far to maximize use of the depth buffer's quad tree optimizations since the pixels are the bottleneck unless you have thousands of tiny items.

Take a copy of the depth buffer if you want to support deep particles.

Then draw alpha filtered from far to close with depth writing disabled to show each layer.


Edited by Dawoodoz, 01 February 2014 - 05:20 PM.

My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."


#3 cozzie   Members   -  Reputation: 1654

Like
0Likes
Like

Posted 01 February 2014 - 06:58 PM

Thanks. How would you sort then, based on materials or based on renderables?
My idea now is:

- 2 arrays with material id's, one opaque and one blended
- for each opaque material sort all renderables front to back and draw
- for each blended material sort all renderables back to front and draw
- find an efficient way of doing this without having to switch meshes/ buffers more then needed

If I do this I can switch between the 2 shaders after opaque is finished and set the corresponding states. Only thing I have to figure out is which material is blended/ uses an alphamap (from the source, export from max). Maybe I can abuse a specific emissive color to mark blended = yes and then in the blended/ alphamap shader, don't use emissive in the lighting calculations? This might be a bit tricky, but no high risk.

#4 Dawoodoz   Members   -  Reputation: 331

Like
1Likes
Like

Posted 02 February 2014 - 03:45 AM

I only sort by instances since anything advanced will just move the bottleneck to the CPU.

 

I use one opaque/alpha flag for the whole model and design with separate instances. This is not a problem since it is mostly particles and breakable windows that use alpha filtering.

 

I once tried removing the code that changed textures and the framerate did not change at all.


My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."


#5 cozzie   Members   -  Reputation: 1654

Like
0Likes
Like

Posted 02 February 2014 - 06:12 AM

Ok clear. That's what I do today but with one downside:

1. I design a scene in 3ds max, containing for example 80 subobjects/ objects
2. Within them 5 of them are blended/ useapha blended textures
3. I know have to make several exports of the scene to distinguish the subobjects that need to be marked as blended

I could solve this by making/ using another mesh format, but I think this will not solve it. Now I think of it, I could simply export the whole scene twice, one for opaque and one for blended. I can use max group filters to hide one of the 2 groups easily and not include them in the export. Then my renderqueue sorts all submeshes like it does today, per mesh. For blended I already sort back to front, I can add front to back for the opaque renderables. That way a specific material is not perse opaque or blended, but only if the object/ renderable that uses the material, is.

#6 Dawoodoz   Members   -  Reputation: 331

Like
0Likes
Like

Posted 02 February 2014 - 10:20 AM

Try to normalize your collection of istances to the first normal form without sub objects so that they can be easily sorted as one list. Design many models in separate files and place them in a level editor to allow dynamic physics, multiple detail levels and easy reuse of models between games.


My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."


#7 cozzie   Members   -  Reputation: 1654

Like
0Likes
Like

Posted 02 February 2014 - 10:31 AM

Thanks dawoodoz. Ideally I think your right. Up till know I didn't find the motivation to build a 3d level editor, where 3ds max fills in around half of what I need. I'll think about it.
Till know it's always pencil and paper, excel and notepad :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS