Using OpenGL Shader Language to write a simple shader
I'm going to start this off by saying that I am new to GLSL but have a decent amount of experience with OpenGL.
I currently have a project that I want to practice shaders with. I am using gluTeapot and having it rotate around the xyz axis and I want to practice writing a basic shader with it.
I currently have a sample shader and it works so I know that the OpenGL side of things is working well. All I need to do at this point is work with my vertex shader and fragment shader.
I want to start out with something simple. I want to write a shader that makes alternating stripes of red green and blue.
Here's what I know I need to do so far, but I'm not exactly sure how to actually implement it: 1) I know that I need to make constants for red, green, and blue that are of the type vec4 2) I开发者_如何转开发 know that I should probably just use mod(ycoord, 3.0) to determine which color belongs at a certain location 3) I know that I am going to have to figure out some way to get this pattern to rotate along with the teapot or else it will just look stupid.
I have tried looking around the internet for some good tutorials for the basics of GLSL but I haven't understood any of the ones that I have read well enough to put them to use. I also haven't been able to find any questions here that I have been able to put to use.
Any help that you can give to a newbie at writing shaders would be appreciated.
Thanks.
Try the Learning WebGL series. It'll give you examples of simple shaders and work you up to advanced topics. Everything uses standard GLSL and you can play with it in your web browser.
http://learningwebgl.com/
精彩评论