Incorporating Agents into an Implicit Raytracer

Course project for CPSC 601.64, Dr. Brian Wyvill

This page documents the steps taken in completing this project

  • Not sure what implicits are? Check out A simple introduction by Paul Bourke (link) or a more detailed tutorial by Dr. Wyvill (link)
  • This project uses and builds on the Blobtree Studio (link), A work-in-progress primarily by (soon to be Dr.) Erwin de Groot (link).
  • This project focuses on non photo-realistic rendering, and so the results are not intended to look real

Step 1: Incorporation into the blobtree

The agent system is fully integrated into the blobtree, and is accessible from the Blobtree scripting framework; an input script has full control over the agents in a system.

There are three core classes which the script has access to: `Agent, AgentCollection, AgentBehaviours`

  • The Agent class defines an agent, and includes things such as an agent's position, colour, etc.
  • The AgentCollection class is the collection of agents and provides a central class where shared information is stored.
  • AgentBehaviours provides various behaviours which a script can attach to an agent. These behaviours do not need to be used as a script-writer can develop their own within the script.

The agent system adds the following paramters to the GUI:

  • 'Image Size' - Defines the size of the image, in pixels, to be rendered
  • 'StepsPerFrame' - How many agent steps to complete before rendering an image to screen. Setting this to the MaxSteps value only shows the final image, while smaller values provides an animation showing the progress of the agents.
  • 'MaxSteps' - The number of steps in the system. Currently, the system always iterates the maximum number of steps. In the future, an agent system can flag that it has relaxed.

At this point in the implementation, I faked a camera model and implemented a starfield to test the behaviours of the agents. (See image) (script)


Step 2: Evaluating the field function - Sticky Rain

This step involved first implementing a camera model into the raytracer and then giving the agents the ability to evaluate the field function to find a surface.

The function implemented here is simply a reverse starfield (i.e., we are moving away) which makes the agents 'stick' and change colour if they hit a surface. Also, when an agent sticks to a surface a new agent is created at a random location and is added to the starfield. (script). Compare this to the raytraced version of the same field (script).



Step 3: Intelligent Agents: Find the surface!

In this step the agents intelligently search for the surface by following the gradient of the field. When a surface is found, the agent sticks to the surface and generates a new random image in space. This image contains 26,826 agents. (script)



Step 4: Crawling on the surface

These examples are various ways of making an agent crawl along a surface once it found the surface. There are two main variants to the crawling algoritm here: the first set of images crawl along the x or y axis in world space and project the point onto the surface (no wrapping). The second set of images crawl along the x or y axis of the set of tangent planes to the surface, wrapping around the image.

'First set of images: x trace dense (265,480 agents) and x trace sparse(61,628 agents) (script).'



'Below images: y trace dense(110,839 agents) and y trace sparse(34101 agents)(script).'


'Below images: x and y trace BOX dense(161,117) and sparse(32,528 agents)(script).'


'Below images: x and y trace HATCH dense(104,796) and sparse(21,007 agents)(script).'


'Below images: x and y trace with random variations dense(152,562 agents) and sparse(30,444 agents)(script).'



Step 4 part 2: Wrapping traces

'First set of images: x trace dense (246,525 agents) and x trace sparse(49,377 agents) (script).'



'Below images: tracewrap y dense(245,397 agents) and tracewrap y sparse( 49,126 agents)(script).'


'Below images: x and y tracewrap BOX dense(245,987 agents) and sparse(49,222 agents)(script).'


'Below images: x and y tracewrap HATCH dense(244,989) and sparse( 49,057 agents)(script).'


'Below images: x and y tracewrap with random variations dense(246,396 agents) and sparse(49,291)(script).'



Step 5: Silouette finding

This step focused on attempting to find the silouette of an image. This Silouette image has 4379 agents. (script)



Step 6: Sketching

This step attempted to break away form the simple dot agent, and when an agent was 'settled' (found the surface or silouette) it would draw a line in a specified direction.

'Silouette with sketches in the direction of the normal (27,433 agents)(script) and Silouette with sketches in random direction orthogonal to view vector. (27,134 agents) (script).'



'Surface with sketches in the direction of the normal (175,918 agents) (script) and surface with sketches in random direction orthogonal to view vector. (175,508 agents) (script).'


'Surface with sketches in the positive Y direction (175,888 agents) (script) and surface with sketches in a direction specified by the cross product of the normal and the view vector. (174,997 agents) (script).'



Step 7: Clipping

This step uses the raytracer to clip hidden agents.

'Surface with sketches in the direction of the normal, with clipping(175,059 agents) (script) and surface tracing hatch, sparse with clipping. (20,609 agents) (script).'



'X and Y tracewrap with random variations, sparse and clipped (245,130 agents) (script) and tracewrap HATCH, dense and clipped.(491,487 agents) (script).'


'Silouette with sketches in direction of normal, clipped (27,016 agents) (script) and Surface with Sketching in direction

 of crossproduct(look, normal).(175,397 agents) (script).'



Step 8: Shading

This step uses Phong shading to colour the agents.

'Find the Surface, clipped and shaded (26,935 agents) (script) and x surface tracing, dense clipped and shaded (207,331 agents) (script).'



'Surface tracing in hatch, dense clipped and shaded (104,696 agents) (script) and silouette sketching in direction of normal (27,519 agents) (script).'


'x surface tracewrapping, sparse clipped and shaded (49,265 agents) (script) and surface tracing with random variations, dense clipped and shaded (246,266 agents) (script).'


'Surface sketching in direction of cross(gradient,look), clipped and shaded (174,561 agents) (script) and surface tracewrapping in hatch pattern, dense clipped and shaded (244,969 agents) (script).'



Step 9: Brushes

Similar to the sketches, this step creates brushes to replace an agent when rendering. So far, only one brush has been implemented.

' Surface tracewrapping, with a sparse brush (script) and with a dense brush ( agents) (script).'



' High number of agents and steps, with sparse brush (script)'



Additional Experimentation (With help from Lothar Schlesier)