[Verse-dev] Question about materials

eskil at obsession.se eskil at obsession.se
Fri Dec 23 20:09:52 CET 2011


> Hi
> <div><br /></div>
> <div>I need to learn how to implement materials from a verse respository
> in&nbsp;C/C++ and OpenGL. &nbsp;Is there any good source of information
> about this ?

I would say the Co On code is pretty good. It actually has 3 different
implementations, one that generates shaders, one that generates
displacement, and one that is responsible for the preview spheres in the
interface.

The way i have implemented them has been to make a recursive function with
a big switch/case that evaluates all the fragments. Its actually very
straight forward.

The main thing to figure out is how you want to implement each fragment.
What kind of lighting model do you want to use, and how will you implement
reflections? All that is the same kinds of problems you would have to
solve making any shader system.

The 2 "gotchas" I would recommend you think about is:

-Remember that it is possible to create infinite loops, so you need to
check for that when you make your recursive evaluator.

-Sometimes several fragments point to the same fragment, so you may want
to add some code to only evaluate that branch once.

Let me know if you need more help.

Cheers

E



More information about the Verse-dev mailing list