General design question

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
l99057j
Gnoblar
Posts: 14
Joined: Wed Aug 28, 2013 1:19 pm

General design question

Post by l99057j »

I've been working with Ogre for several weeks now and I think I understand various individual pieces. Now it is time to stitch them together into a coherent app and I'm a little stumped. I am writing an app that will need to display a lot of geometric figures, similar to the one here: http://etc.usf.edu/clipart/42700/42772/ ... 772_lg.gif in that I want the hidden edges to show as dashed lines.

I *think* to do this I need to draw the front faces like normal and then, when drawing my lines, I need to manually do a depth test in my fragment shader. If the line is hidden, use some combination of sin and discard to get a dashed effect otherwise draw as normal.

Assuming I'm even right on that much, if I have 100 cubes on my screen that means rendering the depth buffer to a texture 100 times. This seems very inefficient and tells me I may be architecting this all wrong from the beginning.

Can anyone give me some idea of how to properly approach a problem like this? It strikes me as something that could be done 20 different ways, 19 of which I'll regret, so I'd appreciate the benefit of more experienced viewpoints.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

Re: General design question

Post by scrawl »

No need to do that, just use an appropriate depth function, see http://www.ogre3d.org/docs/manual/manua ... h_005ffunc :)
l99057j
Gnoblar
Posts: 14
Joined: Wed Aug 28, 2013 1:19 pm

Re: General design question

Post by l99057j »

Are you suggesting two passes for the lines, one with a solid pattern and one with a dashed pattern using greater_equal? I assume I'll also use depth_bias to prevent z-fighting? Sounds like it would work... in the grand scheme of things what is the relative cost of an extra pass? Thanks for the feedback, I'll definitely try it.
l99057j
Gnoblar
Posts: 14
Joined: Wed Aug 28, 2013 1:19 pm

Re: General design question

Post by l99057j »

Tried it, and it worked great. I really was over-thinking it, thanks. Now I have a different issue to resolve. Imagine a smaller cube behind a larger cube. The small cube shouldn't be visible, and indeed its faces aren't. But the outline of the small cube is there as dashed lines.

This makes perfect sense, since I'm using depth_func greater and (I assume) the larger cube happened to be drawn first. But I don't know how to redesign this to prevent it.

Thanks for your response, it was very helpful. Any help anyone can offer on the second issue would be appreciated.
Post Reply