質問

I am rendering 3D objects using OpenGL. Each object in the 3D world has a bounding box and an associated model matrix for transforming the object from part coordinate system (PCS) to world (WCS). The bounding box is also in PCS. The centroid of each object is compute in WCS and is associated to each object.

Given camera position and target position in WCS: -> I would like to render all opaque objects (with alpha == 1) from front to back. -> I would like to render all translucent objects from back to front after rendering the opaque objects.

Since this is the my first stab at implementing a graphics engine I am not sure how a scene-graph will help me here. I think I have to manually sort the objects based on distance from the camera and then render the same based on opaque / translucent objects. Do I really need a scene graph ? How should I go about implementing the engine. I can use other engines available but I prefer not to and would like to implement myself.

役に立ちましたか?

解決

Well, you don't necessarily need a scene graph here, but you do need a render list. That is, every render cycle you clear your list. Every object to be rendered adds itself to the render list. Once you are done, you sort the list based on distance from the camera.

In your case, you may want to use two render lists: One for translucent objects and one for opaque.

Once your lists are sorted, you rip through them and render the objects in order.

You may have confused the need for scene graphs because pretty much any scene graph implementation will also render lists.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top