Before we can implement the rest of the rendering pipeline, we need to know how to efficiently paint colors into a framebuffer.
And that gives me a great excuse to give you a fun little assignment for next week. If you go to:
http://mrl.nyu.edu/~perlin/MIS/you will see a silly little scene of a blue moon rising and setting over a horizon. This simple applet is built atop a class I wrote called
MISApplet
,
which packages up in a clean way
the Memory Image Source
facility provided by java.awt
.
My base class MISApplet
also
handles all the details of packing r,g,b
into a 32 bit word, so you won't need
to deal with that (although of course you
are welcome to look at my implementation of
this class, like the bit-packing method pack(r,g,b)
,
if you're interested in how that stuff works).
You will see that
in ExampleMISApplet
I override two methods:
to make my cool little scene.initFrame(double time)
setPixel(int x, int y, int rgb[])
What I'd like you to do is to create some sort of time-varying scene or pattern of your choice by overriding these methods in some different and interesting way. You can make something fun and psychodelic, serious and artistic, or just plain weird. You can try using things like sin functions in various ways. Feel free to play music if you'd like.
The actual code that I use to implement these
two methods,
including the helper method disk()
,
is only there by way of illustration;
I expect that you will make something quite different.
The only thing that's really necessary is that you
end up
setting values for
rgb[]
at each call to setPixel()
.
You really can't go very wrong with this assignment. Try to have fun with it. Experiment. Go a little wild. The important thing is that you get used to the idea of implementing a method that lets you compute stuff at the start of an animation frame, and another method that lets you set r,g,b values at each individual pixel.
Next week we'll use this software base to do serious stuff to implement the rendering pipeline. But meanwhile, have fun!!