Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11992 Posts in 1588 Topics- by 3509 Members - Latest Member: fishigon

26. May 2012, 04:12:45 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Rendering edges, layering passes
Pages: [1] 2
Print
Author Topic: Rendering edges, layering passes  (Read 1058 times)
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« on: 20. December 2010, 10:57:37 pm »

So, I'm trying to figure out how to properly draw outlined polygons using Xith.

I've got some simple models, and would like to have some sort of outline for each face. Now I know that in C OpenGL supports all sorts of weird edge styles and widths, but Xith doesn't seem to expose this functionality.

This is complicated by the fact that each face is made up of (amazingly enough) several triangles. Thus, I don't think that the wireframe view afforded in Xith will work (and I'm still unclear how to use that, beyond the DrawMode class in JaGaTOO).

My options right now seem to be:
1. Write a shader to handle this.
2. Break each face into its own Shape3D object, and somehow apply a silhouette.

Any thoughts?
« Last Edit: 04. January 2011, 10:50:40 pm by ChrisE » Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 21. December 2010, 01:35:12 pm »

Can't you simply draw the object twice? Once in normal render mode and once in wireframe mode?

Marvin
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #2 on: 21. December 2010, 04:02:54 pm »

Right, but the triangles that make up face will still have edges internal to the face visible. Unless perhaps I can guarantee that the wireframe goes first in the renderpass?

How would you suggest I modify my scenegraph to support this?

Right now I have one branch group for the sky box and one branch group for the geometry. The geometry branch group has a transform group for the ground plane and another transform group for the stuff we're drawing; each stuff has a branch group and either Shape3Ds for the faces it has or more transform groups with more stuff (again, Shape3Ds and/or more stuff transform groups). That's the correct sort of use of this, right?

How do I set up render passes to accomplish wireframe and then normal rendering? Would I have to duplicate my branch group?
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 21. December 2010, 09:30:52 pm »

First I would put the ground plane into its own render pass. It should be be taken into account by the sorting algorithm, since it doesn't make sense.

Then I would create a separate render pass and put all the shapes into it, that should be rendered in wire frame mode. These are new Shape3D objects with all the same appearance telling xith to render them in wire frame mode. Using all the same appearance is extremely fast.

The wire frame render pass should be rendered last and this render pass must not go in layered mode, so that wires inside of the shapes are not rendered (z-buffer). Maybe you need to slightly zoom the shapes or apply an offset (rendering attributes).

Of course with a shader you would go fastest and in the end easiest.

Marvin
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #4 on: 21. December 2010, 09:46:56 pm »

After fooling around with RenderMonkey, I think shaders are indeed the way to go.

I'm looking over the shaders in Xith, and it seems like you only support a single program at a time for a given appearance (granted, this could be composed of several shaders).

How would I go about doing multipass shader programs, or shader programs that use render targets (e.g., a depth buffer and a normal buffer) for certain effects?

Having dealt with engine architecture questions regarding multipass stuff, I apologize in advance for any hair-tearing this might cause.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 21. December 2010, 10:32:06 pm »

This is an open point in Xith3D. You'll have to compose everything on your own. Sorry.

I assume, you already found the test cases for render targets in xith-tk.

Marvin
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #6 on: 21. December 2010, 10:50:52 pm »

Yup, was looking around at that a little earlier.

Out of curiosity, what's the story on that design decision so far?

-Chris
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #7 on: 21. December 2010, 11:45:17 pm »

I played around with some thoughts with Mathias some time ago. But we didn't carve anything in stone. So feel free in that area.

Marvin
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #8 on: 28. December 2010, 10:59:36 pm »

So, temporarily not using shaders for the edge effect, and instead using another rendering pass and polygon offsets.

So, what I'm wondering is if the only way to do this is to construct a parallel branch group? There isn't a handy way of just asking the same branch group to be drawn again with the different render config?

(I'm pretty sure there isn't, but never hurts to ask.)

EDIT: sharedCopy() and sharedInstance() seem almost useful here, except I need to change the appearance in order to draw the lines correctly.

EDIT 2: ahahahaha oh god the visual errors encountered while figuring this out are amazing
« Last Edit: 28. December 2010, 11:59:37 pm by ChrisE » Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #9 on: 29. December 2010, 02:26:37 pm »

No, you'll have to recreate the Shapes for the second branch. But you can and should reuse the geometries.

Marvin
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #10 on: 29. December 2010, 04:33:18 pm »

That's what I ended up doing. It looks mostly okay, though I'm having trouble getting the edges to shade correctly.
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #11 on: 29. December 2010, 05:51:22 pm »

Oh, and as another question... is there any way to get render passes to respect the depth buffer, or is it cleared between every pass switch?
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #12 on: 30. December 2010, 01:05:04 pm »

You need to control "layered mode" between the render passes.

Marvin
Logged
ChrisE
Becoming dependent
**
Offline Offline

Posts: 104


View Profile
« Reply #13 on: 30. December 2010, 05:58:02 pm »

Gotcha. I'm assuming that to do this I use setLayeredModeForced() and setUnlayeredModeForced(), and further that passes are unlayered by default, and still further that passes are layered with the previous layer drawn until disabled?

Thanks again!

Do you guys have a feature/documentation/tutorial wishlist I could perhaps start contributing to? Not to add wishes, but to try and help fill them. I've been rolling around in the API for the past month, and it'd be nice to be able to help pass on that experience to new users.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #14 on: 30. December 2010, 07:03:42 pm »

Gotcha. I'm assuming that to do this I use setLayeredModeForced() and setUnlayeredModeForced(), and further that passes are unlayered by default, and still further that passes are layered with the previous layer drawn until disabled?

Yes, I think so. You can also change the default, so that you don't need to set all passes layered/unlayered, if you only need one behavior.

Do you guys have a feature/documentation/tutorial wishlist I could perhaps start contributing to? Not to add wishes, but to try and help fill them. I've been rolling around in the API for the past month, and it'd be nice to be able to help pass on that experience to new users.

That's what this forum is good for.
http://xith.org/forum/index.php/board,4.0.html

Marvin
Logged
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic