A programming language for OpenGL shaders.

learn more… | top users | synonyms

3
votes
4answers
713 views

How many times fragment shader is executed?

I have an OpenGL code, with 3 different shader programs. I have a simple question, I know fragment shaders are executed for every every fragment in the scene. But is there a way using which we can ...
0
votes
1answer
632 views

GLSL billboard move center of rotation

I have successfully set up a billboard shader that works, it can take in a quad and rotate it so it always points toward the screen. I am using this vertex-shader: void main(){ vec4 tmpPos = (MVP * ...
0
votes
0answers
84 views

Triangle Clipping

I want to determine which part of a triangle is visible in a frustum in OpenGL, is there a way to get visible coordinates of triangle in the viewing frustum?
0
votes
1answer
55 views

Working with floats in OpenGL ES 2

Are there any reasons or situations one would use in their shader float(1) over just 1.0 ?
4
votes
3answers
1k views

Implementing skeletal animation and GPU skinning (DOOM MD5)

DISCLAIMER This question has been completely rewritten to narrow the scope of the question in light of previous suggestions and answers, but the same problem still persists. Currently I'm trying to ...
1
vote
1answer
692 views

GLSL 2d Per Pixel Lighting

First time writing shaders, and having a bit of an issue getting per-pixel lighting to work. The problem is pretty simple, but I'm afraid am doing something wrong here. Vertex Shader: #version 150 ...
1
vote
1answer
225 views

Bump mapping Problem GLSL

I am having a slight problem with my Bump Mapping project. Although everything works OK (at least from what I know) there is a slight mistake somewhere and I get incorrect shading on the brick wall ...
1
vote
0answers
377 views

Geometry shader and triangle adjacency

I'm currently trying to change my project to use GL_TRIANGLE_ADJACENCY instead of GL_TRIANGLES. Following this question, I have managed to construct my index buffer fine, but when it comes to the ...
4
votes
1answer
789 views

Shadow mapping does not work correctly using GLSL shaders

I'm a beginner in shadow mapping. I have in my scene two meshes : a cube and a floor. The scene is lighted by a single point light. Here's for the following display the light properties : ...
3
votes
2answers
1k views

Developing GLSL Shaders? [closed]

I want to create shaders but I need a tool to create and see the visual result before I put them into my game. As to determine if there is something wrong with my game or if it's something with the ...
0
votes
2answers
333 views

HLSL's Tex2D for GLSL?

I am trying to port a HLSL shader to GLSL. I'm just not quite sure how to convert this line: outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-4.0 * pxSz.x * blurSize,0)).a * 0.05; ...
4
votes
1answer
409 views

OpenGL FBO not being drawn to

In my project I'm trying to implement a deferred rendering system, problem is, I can't seem to get a second FBO to work. UPDATE 1 Here is the FBO initialization code: /// G-Buffer FBO GLuint ...
0
votes
1answer
1k views

GLSL - Declaring global variables outside of the main function scope

Does it help to declare variables outside of your main function scope in GLSL? Do these variables actually get reused and is it more efficient? Here is the code in question: varying vec2 vposition; ...
1
vote
2answers
214 views

GLSL: define a constant for both vertex and fragment shader

I have a constant for defining an array in the vertex shader. I want to use this constant also in the fragment shader to define another array of the same size. Naive attempts fail (simply use the ...
6
votes
1answer
714 views

How would one draw many objects using the same VBO

I'm kind of stuck with this question for some time now, maybe because I don't know exactly what to search for, it might be a term I have not heard of yet as most tutorials ends after drawing one ...
0
votes
2answers
959 views

Draw wireframe overlay of model in GLSL

I have a 3D model that has a GLSL script, and I want to draw a line on each border of its polygons in the fragment shader. What should I do? Note: I am using Ogre3D, so I can't use OpenGL's ...
3
votes
0answers
417 views

Jet engine exhaust shader [closed]

How would I create a jet engine exhaust effect, as shown in the image from Fzero GX below. GLSL and OpenGL examples/solutions are prefered, though other resources are also welcome. Requirements ...
7
votes
2answers
259 views

Diffuse Reflection confusion

From what I've read, with a simple directional light, the color of a point, if you only take diffuse reflection into account (intensity = 1), should be color = color_of_point * color_of_light * ...
3
votes
2answers
72 views

Local shape color blending

I am trying to implement this in Unity 4 Pro. But I am stuck in the blending part. I don't understand how you could blend multiples textures/colors using multiples volumes on an object. How could you ...
0
votes
1answer
211 views

Creating a fragment shader to darken a white texture over time - OpenGL GLSL

So as a part of learning OpenGL, I've now decided to try and be a bit more creative with shaders, as part of a practice game I'm making using C/OpenGL. I'm completely new when it comes to working ...
0
votes
0answers
163 views

Shadow-casting through time acting in “reverse” before next notciable shadowmap update

question was re-written to better explain the problem I have a scene of big thin parallelepiped, small cube, and a light source, all aligned on Y axis, like so: _ | | | |----[ ]----Light |_| Both ...
4
votes
1answer
2k views

Implementing a skybox with GLSL version 330

I am trying to get a skybox working with OpenGL 3.3 and GLSL version 330. I could not find a completely modern OGL skybox tutorial anywhere on the web, so I modernised an older one (using ...
0
votes
3answers
1k views

OpenGL tile rendering

Currently I'm trying to render a TileMap using OpenGL 2.1, GLSL 1.2. I would like to draw every tile in just one draw call. I use a single texture with all tiles, identifying each one by an index. ...
0
votes
1answer
203 views

VBO in a class doesn't draw when The class has a destructor

I am making this class QuadTemplate class QuadTemplate { public: QuadTemplate() { vbo=0; uvbuffer=0; vao=0; TextureID=0; vboType=0; ...
3
votes
2answers
3k views

Rotating an object when the center in not the origin - opengl

I'm beginning with GLSL and I learning the basic, I am using glm to do the matrix calculations at this point everthing ok,the problem is how I can move the origin to the center of my object, not the ...
3
votes
1answer
266 views

Directional light shader not behaving as expected

I coded my first glsl shader which manage diffuse and specular effects of a directional light. This is the fragment shader. #version 120 //matrix uniform mat4 model_matrix; //directional light ...
7
votes
2answers
5k views

GLSL Shader - Change Hue/Saturation/Brightness

I'm trying to change the hue of an image using a GLSL fragment shader. I want to achieve something similar to Photoshop's Hue/Saturation Adjustment layer. In the following image you can see what I've ...
1
vote
0answers
136 views

Matrix array doesn't seem to get populated

I'm trying to stream an array of matrices to a vertex shader, but it seems that only the first matrix works. What could be the problem? I suspect that I upload the matrices in a wrong way. C# ...
3
votes
1answer
746 views

Incorrect GPU skinning

I'm having some problems with implementing skinning and skeletal animation. It seems that the skeleton and the mesh are loaded correctly, but the mesh gets funky when the bone transformations are ...
4
votes
2answers
1k views

Using two shaders instead of one with IF statements

I've been working on porting a relatively large opengl ES 1.1 source to ES 2.0. In OpenGL ES 2.0 (which means, everything uses shaders), I want to draw a teapot three times. The first one, with a ...
3
votes
1answer
263 views

Do GLSL 4.x subroutine variables cause any performance overhead?

There's not too much deep information about them on the web. How are they implemented and how they work under the hood? I'd like to know that they cause any performance overhead or not, especially in ...
0
votes
1answer
76 views

Vertex and Fragment Shader worldNormal

How to access/calculate worldNormal in a Vertex and Fragment shader ? Thanks a lot !
0
votes
1answer
308 views

GLSL: Strange light reflections

According to this tutorial I'm trying to make a normal mapping using GLSL, but something is wrong and I can't find the solution. The output render is in this image: Image1 in this image is a plane ...
2
votes
1answer
186 views

Shader Variable Types

I have a simple question. what are the meaning of : half4 myHalf; myHalf.yyyy; myHalf.xxzz; // or myHalf.yw Thanks a lot !
4
votes
2answers
1k views

GLSL Atmospheric Scattering Issue

I am attempting to use Sean O'Neil's shaders to accomplish atmospheric scattering. For now I am just using SkyFromSpace and GroundFromSpace. The atmosphere works fine but the planet itself is just a ...
2
votes
1answer
524 views

How to do directional per fragment lighting in world space?

I am attempting to create a GLSL shader for simple, per-fragment directional light. So far, after following many tutorials, I have continually ran into the issue: my light is specified in world ...
4
votes
1answer
259 views

Better solution for boolean mixing?

Sorry if this question has been asked in the past, but searching Google and here didn't yield relevant results, so here goes. I'm working on a fragment shader that implements both conditional/boolean ...
3
votes
1answer
661 views

TBN Matrix : Eye vs. World Space Conflict

I am tired of misleading and insufficient articles making me more confused each time I read, I need a clarification that will solve my TBN matrix problem forever. Each article I read informs me ...
1
vote
1answer
1k views

Volumetric Fog Shader - Camera Issue

I am trying to build an infinite fog shader. This fog is applied on a 3D plane. For the moment I have a Z-Depth Fog. And I encounter some issues. As you can see in the screenshot, there are two views. ...
0
votes
0answers
317 views

GLSL gl_ModelViewMatrix breaks my code?

So I have the following shaders which work (to the extent that they are completed anyway). //Vertex Shader uniform float offset; void main() { gl_TexCoord[0].t = gl_MultiTexCoord0.t; ...
2
votes
1answer
220 views

What is the interval of fragment-shader code execution?

Without any intended delay, is the code of a fragment-shader run once per frame? If not, how often will the code be executed? (I'm new to shaders: I'm talking about glsl if it makes any difference)
0
votes
1answer
192 views

Shader program compiles fine on Ati, fails on other vendors

Got a real annoying problem here. My shader program compiles fine on my Ati Radeon HD card, but on Nvidia and Intel it failes to compile. Vertex shader: #version 120 attribute vec3 in_position; ...
1
vote
2answers
2k views

What is the best method to update shader uniforms?

What is the most accepted way for keeping a shader's matrices up to date, and why? For example, at the moment I have a Shader class that stores the handles to the GLSL shader program & uniforms. ...
2
votes
1answer
241 views

GLSL Multiple Uniform Structs

I'm developing a lighting system for my voxel game, and I have to send multiple (alot, say up to 200) lights to my shader program. Those lights contain the following data: Position (vec3) Color ...
2
votes
1answer
668 views

Simple Optimized Blur Shader

I have a vertex-fragment shader that use the Unity3D GrabPass functionality (it grabs the screen). And I apply my GrabPass to have a transparent effect. GrabPass { "_GrabTex" } sampler2D ...
5
votes
1answer
2k views

GLSL Light (Attenuation, Color and intensity) formula

I'm implementing point lights in my Voxel engine, and I'm really struggling to get a good flow of light, from 100% near the light source to 0% at the light radius. I have 5 arguments for the ...
-1
votes
1answer
162 views

OpenGL shader problem

So, I've been working on this game engine for a while now, and just the other day my friend tried running the program and his output doesn't match my output... My Program Output: His Program ...
2
votes
1answer
161 views

OpenGL Calculate Matrices

Im trying to switch from the glTranslate etc to my own Matrices, but for some reason it does not work. Here are my 2 functions to create the view- and projection matrix: public Matrix4f ...
0
votes
1answer
216 views

Get world-position in Vertex shader

I'm wondering how I can get the final position of a vertex. I use glTranslate in my render code, and I'm not getting the world-coordinates correct. My world is devided in chunks and my position get's ...
0
votes
1answer
282 views

GLSL Shaders-> How to manage?

As your game get's bigger and bigger, you will use more and more different shader effects. Let's take an easy example: I have clouds in my voxel-based world, and I want to give it a blue-ish tint ...