Point Sprites for particle system

Point sprites are indeed well suited for particle systems. But they don’t have anything to do with VBOs and GLSL, meaning they are a completely orthogonal feature. No matter if you use point sprites or not, you always have to use VBOs for uploading the geometry, be they just points, pre-made sprites or whatever, and … Read more

Adding GLSL syntax highlighting to Eclipse [closed]

The Eclipse Shaders plugin mentioned by Gilbert Le Blanc works for me with Eclipse Juno. Place the contents of the “plugins” folder in your Eclipse plugins folder, and place the contents of the “features” folder in your Eclipse features folder. Then restart Eclipse. You might need to name your shaders with the extension “.glsl”, or … Read more

How do I get the current color of a fragment?

The fragment shader receives gl_Color and gl_SecondaryColor as vertex attributes. It also gets four varying variables: gl_FrontColor, gl_FrontSecondaryColor, gl_BackColor, and gl_BackSecondaryColor that it can write values to. If you want to pass the original colors straight through, you’d do something like: gl_FrontColor = gl_Color; gl_FrontSecondaryColor = gl_SecondaryColor; gl_BackColor = gl_Color; gl_BackSecondaryColor = gl_SecondaryColor; Fixed functionality … Read more

Passing a variable to an OpenGL GLSL shader

One option is to pass information via uniform variables. After glUseProgram(myShaderProgram); you can use GLint myUniformLocation = glGetUniformLocation(myShaderProgram, “myUniform”); and for example glUniform1f(myUniformLocation, /* some floating point value here */); In your vertex or fragment shader, you need to add the following declaration: uniform float myUniform; That’s it, in your shader you can now access … Read more

How can I pass multiple textures to a single shader?

It is very simple, really. All you need is to bind the sampler to some texture unit with glUniform1i. So for your code sample, assuming the two uniform samplers: uniform sampler2D DecalTex; // The texture (we’ll bind to texture unit 0) uniform sampler2D BumpTex; // The bump-map (we’ll bind to texture unit 1) In your … Read more