A programming language for OpenGL shaders.

learn more… | top users | synonyms

2
votes
3answers
1k views

Passing POD arrays to shader?

How do I pass to my vertex shader an array of N elements? From what I see I can only pass float arrays of 3|4 elements, vectors 2|3d and matrices, but I want to pass a POD array and use it like this: ...
8
votes
2answers
525 views

Sharing functions across multiple shaders

Simple question: In GLSL, is there a way to share functions across multiple shaders, or do I have to define all functions in every shader that needs them?
6
votes
1answer
589 views

GLSL subroutine not being used

I'm using a gaussian blur fragment shader. In it, I thought it would be concise to include 2 subroutines: one for selecting the horizontal texture coordinate offsets, and another for the vertical ...
7
votes
2answers
11k views

GLSL - one-pass gaussian blur

It is possible to implement fragment shader to do one-pass gaussian blur? I have found lot of implementation of two-pass blur (gaussian and box blur): ...
37
votes
2answers
3k views

How to render realistic ice?

I am trying to write an ice shader in Unity that looks good and at least semi-realistic. If the following shot (found on Google) was CG, what would its shader include? (the foreground cave). I might ...
1
vote
0answers
374 views

How to setup my texture cordinates correctly in GLSL 150 and OpenGL 3.3?

I'm trying to do texture mapping in GLSL 150 and OpenGL 3.3 Here are my shaders I've tried my best to get this correct as possible hopefully this is :) I'm guessing you want to know what the ...
4
votes
1answer
2k views

Proper way to do texture mapping in modern OpenGL?

I'm trying to do texture mapping using OpenGL 3.3 and GLSL 150. The problem is the texture shows but has this weird flicker I can show a video here. My texcords are in a vertex array. I have my ...
1
vote
1answer
1k views

Why doesn't my texture display with this GLSL shader?

I am trying to display a DXT1 compressed texture on a quad using a VBO and shaders, but I have been unable to get it working. All I get is a black square. I know my texture is uploaded properly ...
3
votes
4answers
6k views

How do multipass shaders work in OpenGL?

In Direct3D, multipass shaders are simple to use because you can literally define passes within a program. In OpenGL, it seems a bit more complex because it is possible to give a shader program as ...
2
votes
1answer
332 views

Update single entry in GLSL array

I have an array in my vertex shader like this: uniform mat4 MeshTransforms[20]; At the moment I'm just updating the entire array of matrices like so: int meshTransforms = ...
1
vote
2answers
969 views

How to achieve this particular screen filter with GLSL?

I know this may be a "short" question, but still here it goes. I would like to know how to achieve a post rendering effect, that looks like the following image from walking dead series: I will ...
4
votes
1answer
632 views

Can I use the default depth buffer when drawing to FBO?

How to attach default depth buffer to FBO? How to use depth renderbuffer buffer attached to FBO (after drawing to it) as a default depth buffer? Basically I want to use the same depth buffer for both ...
9
votes
3answers
1k views

Deferred shading - how to combine multiple lights?

I'm starting out with GLSL and I've implemented simple deferred shading that outputs G-buffer with positions, normals and albedo. I've also written a simple point light shader. Now I draw a sphere ...
0
votes
4answers
1k views

Render 3D torus shape entirely in GLSL

I was wondering, is it possible to render a (3D) torus shape entirely in GLSL, i.e. without using vertex/index arrays? Suggestions are welcome, thanks.
1
vote
1answer
345 views

Positioning a texture inside a 3D object with GLSL

I have a 3D object in my scene and a texture that is the same size of the screen (a render to texture). Is there a way to make the object act like a "mask" for the texture(using glsl), so the texture ...
1
vote
3answers
1k views

iOS - pass UIImage to shader as texture

I am trying to pass UIImage to GLSL shader. The fragment shader is: varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; void main() { ...
1
vote
2answers
4k views

FBO Depth Buffer not working

I'm trying to get the depth buffer for my 2D game working by offsetting the z value of the rectangles. For some reason, my depth buffer is coming back empty. The value is always 0. I'm assuiming there ...
6
votes
1answer
568 views

Fast and simple attenuation from a flaming torch

I have a single point light-source which is a flaming torch. I compute the distance from the light accurately. I am not trying to have a particularly realistic torch effect, but I will be moving the ...
4
votes
1answer
3k views

Why does my GLSL 1.20 shader not work with an OpenGL 4.0 driver?

I'm just starting out with OpenGL on Linux. In order to write future-proof code, I explicitly wrote code for OpenGL 4.0 Core Profile in the first place, thus the shaders are GLSL 4.0. That worked ...
1
vote
1answer
792 views

glsl applying shader

I want to use a shader just for learning purposes. But i have a few questions about it. I have the following code: Vertext shader: const float Eta = 0.66; // Ratio of indices of refraction ...
5
votes
1answer
421 views

Raymarching artifacts

I was playing with raymarching using distance fields in GLSL sandbox and got stuck with a strange problem with artifacts. Click here and take a look at the spheres generated in corners, they have ...
24
votes
4answers
19k views

Using multiple shaders

I'm currently studying opengl shaders but I can't figure out something: how to apply different shaders to the objects, for example, a teapot rendered using toon shader and another one in the same ...
2
votes
4answers
531 views

What is a right datatype in C++ for OpenGL scene representation with use of GLSL

I am programming in C++ OpenGl with GLSL. Until now I have been using a data structure that is composed of std::vector filled with structures of vertexes and with their parameters (position , normal, ...
10
votes
1answer
882 views

How do I create good looking plasma explosion effects?

Is this just a billboard quad with a bloom shader?
10
votes
3answers
2k views

Go pure OpenGL or GLSL? [closed]

I got interested in studying graphic programming so the obvious entry point was to learn OpenGL. But gathering scattered information around forums and sites, it seems that a pure OpenGL implementation ...
8
votes
1answer
6k views

What do the components of gl_TexCoord[0] mean?

What are the differences between gl_TexCoord[0].s, gl_TexCoord[0].t gl_TexCoord[0].p and gl_TexCoord[0].x, gl_TexCoord[0].y gl_TexCoord[0].z ? I understand that gl_TexCoord[0].x, gl_TexCoord[0].y ...
5
votes
1answer
2k views

Optional samplers in shaders

I have a scene. Sometimes I draw untextured, coloured, semi-transparent triangles, sometimes I texture them, and I draw a lot of both in a fairly interleaved manner. In a fixed function pipeline the ...
1
vote
1answer
453 views

Setting the values of a struct array from JS to GLSL

I've been trying to make a structure that will contain all the lights of my WebGL app, and I'm having troubles setting up it's values from JS. The structure is as follows: struct Light { vec4 ...
2
votes
1answer
3k views

How can I write only to the stencil buffer in OpenGL ES 2.0?

I'd like to write to the stencil buffer without incurring the cost of my expensive shaders. As I understand it, I write to the stencil buffer as a 'side effect' of rendering something. In this first ...
3
votes
1answer
942 views

Renderbuffer to GLSL shader?

I have a software that performs volume rendering through a raycasting approach. The actual raycasting shader writes the raycasted volume depth into a framebuffer object, through gl_FragDepth, that I ...
1
vote
1answer
353 views

Why am I seeing streak artifacts on the cube map I'm rendering?

I'm getting strange streaks on my cube map when rendering to it. He is my code that is being called each frame: void drawCubeMap(void) { int face; glClear(GL_COLOR_BUFFER_BIT | ...
9
votes
1answer
8k views

OpenGL/GLSL: Render to cube map?

I'm trying to figure out how to render my scene to a cube map. I've been stuck on this for a bit and figured I would ask you guys for some help. I'm new to OpenGL and this is the first time I'm using ...
4
votes
2answers
481 views

OpenGL, Offset and Camera Space

I was reading chapter 4 of the Arcsyntesis OpenGL tutorial when I came across this line in the GLSL shader. vec4 cameraPos = position + vec4(offset.x, offset.y, 0.0, 0.0); About it, the tutorial ...
5
votes
1answer
1k views

How does one get adjacency information in a geometry shader?

If you use triangle_adjacency as the input type of a geometry shader, do you need to do something on the client side besides make the primitive mode triangle_adjacency? Basically what I'm asking do ...
3
votes
1answer
1k views

GLSL Core Functionality Geometry Shader examples

I'm doing some research on geometry shaders and am having problems finding code examples/tutorials that does not use one of the extensions introduced before it was core functionality of OpenGL 3.2. ...
2
votes
1answer
1k views

Pygame water ripple effect

I have Googled for it but there are no ready scripts - as opposed to the same effect on Flash. I have checked the algorithm on The Water Effect Explained and also tested an implementation of the ...
8
votes
2answers
3k views

GLSL Shader Editors for Linux

Are there any good IDE's for linux that lets us edit GLSL shaders and visualize their effect? Note : Shader Designer By Typhoon Labs is a good option but I am looking for alternatives as this ...
11
votes
2answers
7k views

How can I create an efficient bloom shader with GLSL?

I have searched the net for resources related to rendering a bloom effect using GLSL, but haven't found anything. Although the tutorial at Philip Rideout's website is a good one, it performs very ...
4
votes
1answer
623 views

Why are my texture coordinates always (0,0) in this shader?

What I'm trying to do is add my depth buffers values to my scene, ie. I'm trying to make objects closer to the camera darker and objects further away lighter. Which should be easy: just render the ...
6
votes
3answers
502 views

shadowing billboards

I have a lot of billboarded 3D spheres (they have a heightmap so work properly with depth and penetration; although each is made of just a quad (with slight distortion), they look and feel and are ...
6
votes
2answers
3k views

Using a GLSL fragment shader to draw a texture in the middle of a quad

I'm not sure how possible this is, but I'm trying to use a fragment shader to draw a portion of a texture in the middle of a quad. This is all 2D. The quads consist of four vertices from (0, 0) to ...
3
votes
1answer
529 views

moving glDepthMask into a shader

Can a fragment shader make per-fragment decisions on whether the fragment updates the depth buffer or not, even if the fragment is not discarded and the color is written?
2
votes
2answers
1k views

Multiplatform GLSL shader validator?

Im working on a multiplatform (Pc,Mac,Linux) game that uses shaders quite extensively. Since we do not have any funding, it is pretty hard to test our game on all possible hardware configurations. ...
2
votes
1answer
382 views

Learning GLSL: What's a good intermediate project to work on?

I know the basics of OpenGL and I'm starting to love computer graphics more and more. I have a computer science background and have been programming for 5 years. I've been reading the orange book and ...
3
votes
2answers
3k views

computing gl_FragDepth

I am trying to draw spheres using a billboard, so I have a normal map with a z component that I am sampling in my fragment shader. I just need to add this z component to the depth of my fragment to ...
6
votes
1answer
4k views

GLSL - Rewriting shaders from #330 to #130

I recently created a game (LD21) that uses a geometry shader to convert points into textured triangles/culling. Since I was under the impression that the support for #330 was widespread I only wrote ...
1
vote
1answer
736 views

GLSL woes involving texturing

I'm a beginner to OpenGL and GLSL especially, and I'm having a lot of trouble getting textures to display via shaders. My shader code compiles without any warnings or errors, but I seem completely ...
22
votes
4answers
6k views

Why is programmable pipeline( GLSL ) faster than fixed pipeline?

So I'm teaching myself GLSL and am trying to figure out why it's suppose to be faster than the fixed function pipeline. The reason I am having a problem is that from my understanding , the shaders ...
37
votes
1answer
4k views

How can I reduce aliasing in my outline glow effect?

I'm trying to replicate the glowing outline effect in the Left 4 Dead game. The effect causes an objects outline to glow, even when the object is occluded. Here is a screenshot of the effect: I'm ...
5
votes
2answers
826 views

How'd they do it: sphere effects in Osmos

I'm curious how the sphere effects were done in Osmos from Hemisphere Games. Any ideas how the resolution independent zoom in was achieved? Edit, more specifics on questions: How do you render the ...