Hi there,

I'm sorry if this is a vague question, but I've just been assigned to create a color animation project with GLSL, and I've never really used it before. The criteria for the assignment is that the animation should depend on object coordinates, vary over time
and should use shaders and GLSL. Basically, we make an object and the colors change on its surface. In no way am I asking on what the code is like or anything, but do you have any suggestions on where to look to start researching on how to do it? Or theoretical steps to designing this program? I don't even really know much of where to start with this. :(

Thanks for your help!

Recommended Answers

All 6 Replies

I've never used GLSL but a simple search using Google came up with the 3 websites I use when using plain old OpenGL. Seems as good a place as any.

You also should take a look at Shader Designer. This is an IDE for GLSL, I've used it in the past when I played around with shaders, it's pretty nice and easy. I think it also provides base codes to start from.

Awesome, thanks so much for the links and suggestions! What kind of design am I looking for? I first use a shader to create a texture, correct? And then I have it change colors based on a certain time? How would I deal with coordinates?

I first use a shader to create a texture, correct?

No. Shaders are used to transform texture(s), at least, fragment shaders do that. Shaders are basically small programs that run on the GPU. A vertex shader is a small program that runs for each vertex (point in a 3D mesh) that you render, and its job is to apply whatever transformations are necessary to prepare it to be rendered on the screen (these transformations include projecting it into a point on the screen, and other things like computing its texture coordinates, applying a bump-map to it, or even animating the vertex). After vertices are projected to a place on the screen, the OpenGL pipeline generates a number of pixels on those surfaces that should appear on the screen. The fragment shader is a small program that takes each pixel (or fragment) and performs a final transformation of the values associated to the pixel, that can include applying lighting, blending the pixel color coming from different textures, and possibly generating colors too, even animating them, and I think that's what you are asked to do.

And then I have it change colors based on a certain time?

Yes, shaders have a number of inputs, some that are fixed by OpenGL, and some that you can customize. You can use Uniforms (see glUniform) which are like constant parameters, and Attibutes (see glVertexAttrib) which are per-vertex values. The inputs that are fixed by OpenGL include the coordinate of the pixel on the screen and its depth, the color value, the texture coordinates, the textures themselves, and some other things. The job of the fragment shader is to take all or any of that and produce a color value to be put on the screen, and you can produce that color value any way you like, including as a function of time, including a blend of textures, etc.

How would I deal with coordinates?

You get them as inputs to the shader program. OpenGL takes care of it for you, all you have to worry about is how to use the coordinates to affect the pixel color, if that's something you want to do.

Great, thank you for all of your help, mike_2000_17! Let's hope I can get this project figured out...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.