CG programming for non-programmers, lesson 12

Eventually, as your program does more things, you will want to abstract out useful tasks like “make a circular disk”, so that you don’t just keep writing the same code in different ways.

To handle this, shader programs let you create your own functions, and that is what we are doing in lesson twelve.

We are breaking out the concept of “create a circular disk” into its own separate function. Then, in the main part of the shader, we call that function with the particular arguments we want.

One nice thing about this approach is it makes it easier for us to understand our own program. A circular disk shape always needs three things: an x position, a y position, and a radius. By writing code that makes such concepts clear, we end up with programs that are easier to write, easier to read, and less likely to break.

You can see this lesson by CLICKING HERE.

Leave a Reply

Your email address will not be published. Required fields are marked *