Complete with specular and diffuse lighting. The four on the left are specular, as you can see by that awesome glare on the left rubix cube cube, while the right four are only diffuse. Also, the front four use 24 vertices with proper normals, while the back four use the mesh that is only 8 vertices and averaged normals.
The controls are the same, WASD to move the camera, IJKL for the light and the arrow keys for the meshes.
I'm not entirely sure what to talk about this time around, specular lighting is pretty awesome, but the math behind it is pretty simple. It made for an easy assignment that consisted of maybe 30 minutes of graphics related work and maybe 4 hours of creating and manipulating text files and then debugging said text files. I ended up using the message logging system a ton to figure out where all my errors were though, so I'm glad I kept up on our teachers policy of logging errors everywhere.
One issue that kind of confused me is the specular lighting doesn't appear to be working on the back left two cubes that use the averaged normals. Supposedly it should work better,and it's hard to tell because they are so far back, but I don't think it's working. You can rearrange them pretty easily with the text files if you are interested. I don't get how the lighting can work for the other meshes, but not for all of them.
Additionally, I set up my code so that the specular lighting exponent could be read in from the scene file before noticing I was supposed to put it each individual material file. This makes sense so we can specify how rough or smooth and shiny various materials are, but I don't have the sheer force of will to go back and change all the code and add the getters and setters to make that work right now. I'll probably switch that up next week or when we do some bump mapping (we are doing bump mapping eventually, right?)
Oh, one last question I forgot to bring up in class, but I found interesting. I chose to pass the world to view transform into my specular fragment shader cause it was easy, but it seemed like it'd be faster and more efficient to output it from the vertex shader and intercept it with the fragment shader. Then you'd have a vertex shader outputting information that not every fragment shader needs however. Is their a better choice for handling passing this data?
Here's the source code!
No comments:
Post a Comment