Jump to content
  • Advertisement
Sign in to follow this  

Please critique my render pass pseudocode

This topic is 3267 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all I've been doing some groundwork on the rendering part of my game/engine and have come up with the following pseudo code for a depth pass, shadow pass, detail pass and post process pass. If anyone has time, I'd be really grateful if you could pass on a critique of it? It's only a rough outline so I'm just looking to see if I'm on the right track. The game I'm writing is a fairly large outdoor fps style game. Cheers
begin frame
prepare buffer

// this happens for all passes
// there are two 'pipeline's:
// render component pipeline contains all objects and components within each 
// object, e.g. an object may contain 3 meshsets all with a different material
// render object pipeline contains all objects as is - used for depth and shadow
// passes

// render components are identified by a bitmask DWORD key, this contains:
//   mesh subset id, priority, distance, shader id, transparency
// the distance is the only token that gets reset every frame
// this allows us to sort and batch by anything we like - just by switching the 
// order of
// the bitmask format
// e.g. priority for skydome would be very low, whilst objects close to the
// camera would be high

clear object and component pipeline
traverse spatial graph for octree nodes in frustum
traverse visible octree nodes
       for each object in visible node
               process object and its child objects (using scene graph)
                       if detailpass
                               add breakdown of object to render component pipeline
                       end if
                       if using shadowpass or depthpass
                               add object to render object pipeline
                       end if
               end traverse
       end for
end traverse

// shadow pass first
// depth pass next
// detail pass last

for each pass
       if detailpass
               for each object in render component pipeline
                       get each render component from each child object
(at the mesh subset level) with a different material
                       add component to render component pipeline
               end for
               sort render component pipeline by pipeline key
               if postprocess is enabled
                       set render target - postProcessTarget
               end if
       else if shadowpass
               set render target - shadowTarget[0,1,2,3] - depending on
light cascade position
               set shadow shader
       else if depthpass
               set render target - depthPassTarget
               set depthpass shader
       end if

	if detailpass
	       for each component in render component pipeline
	              if detailpass and shader id is different to last shader
	                      set new shader
      	                      set shader parameters (get the values from the
object/game engine/nearest lights, etc)
              		      if doshadowing
                        	     set shader texture stages for shadowing (atlas?) ( shadowTarget[0,1,2,3] )
                    	      end if
               	      else if shadowpass
                       	      set shadow shader parameters (get values from object)
	              end if
              	      render object
       	        end for
	else if shadowpass or depthpass
		for each object in render object pipeline
			set shader parameters (get values from the object)
			render object
		end for
	end if
end for

if post processing is enabled
       set PP shader parameters (texture from previous pass -
postProcessTarget, depthTarget (for DOF blurring), etc)
       set shader(s)
       render full screen quad
end if

swap buffer
end frame

[Edited by - RobMaddison on November 11, 2009 4:50:19 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!