Tagged Questions

A programming language for OpenGL shaders.

learn more… | top users | synonyms

4
votes
1answer
611 views

My GLSL shader isn't compiling even though it should. What should I investigate?

I'm porting an iOS game to Android. One of the shaders I'm using wouldn't compile until I reduced the number of uniform variables. Here are the uniform definitions: uniform highp mat4 ...
5
votes
1answer
2k views

GLSL default shaders

I've been arming my engine with error checking code. I'll try to describe this situation to my best abilities. Whenever i load a shader and there's an error (file doesn't exist, compilation error, ...
1
vote
1answer
364 views

How to calculate the viewing cone radius at a distance in raymarching?

I'm "raymarching distance fields" (proper lingo: sphere-tracing) in GLSL. To implement cone-marching atop of it (and also to minimize the number of raymarching steps regardless of whether ...
0
votes
2answers
850 views

GLSL shader compilation

When i'm compiling a shader does it have to be complete? Can i use glCompileShader on a shader without a main() function? The OpenGL reference documentation has a nice writeup on program linking ...
2
votes
1answer
289 views

Steps to take before trying to implement screen space ambient occlusion

I very recently started learning modern OpenGL. I have implemented a wavefront file loader and a basic ADS shading model. At some point I'd like to implement screen space ambient occlusion. I tried ...
0
votes
1answer
829 views

CG/CGFX to GLSL

So, I'm making the painful move from my beloved XNA to OpenTK, and I'm stuck: Since I've got a LOT of existing shaders written in HLSL, NVidia's CG compiler seems like a natural way to minimize the ...
6
votes
1answer
2k views

How to invert background pixel's color

I'm writing a game and map editor using Java and jMonkeyEngine. In the map editor, I've got a brush done by wireframed sphere. My problem is: I want to make it visible everywhere, so I want to invert ...
0
votes
2answers
851 views

Can't render to FBO using a shader

I've added functionality so that I can render to a framebuffer (for post-processing and stuff). I can successfully render to my framebuffer and then render that framebuffer, but anything with a ...
4
votes
2answers
612 views

How Do I Raycast for a Spherical Harmonic Shader Using the iOS GPU?

I am beginning an Spherical Harmonics shader project for an iOS app I am writing. I have begun by reading this excellent in-depth paper on the subject (PDF) - http://bit.ly/aQmax3. The paper ...
2
votes
1answer
1k views

GLSL Shader Solution for Ambient Occlusion?

For the iOS app I am writing I want to incorporate some aspects of ambient occlusion for photo manipulation. Can someone suggest a GLSL approach that will work. Realtime performance is not super ...
6
votes
1answer
411 views

Weird problem with advect program in fluid simulator

I implemented 2d fluid simulator. Solver runs entirely on GPU. All works fine... on my work PC. But on home PC I have some awful glitches, and I can`t understand how to fix them. Empirically I ...
2
votes
0answers
2k views

How to implement fisheye effect with a GLSL fragment shader [duplicate]

I would like to render my scene with a wide FOV and then apply a fisheye distortion via fragment shader. How would this shader best be implemented? Update I try to reproduce a fisheye effect similar ...
2
votes
2answers
975 views

Optimizing gaussian blur with linear filtering

There's a few (here, and here) gaussian blur tutorials out there suggesting that you can essentially cut the number of texture lookups in a gaussian blur shader in half by exploiting the GPU's ...
4
votes
1answer
1k views

GLSL Editor and Debugger for MacOSX with ES2 support

is there a GLSL editor for the mac? I need it for iOS OpenGLES2 shader. How do you best debug shader? Regards
0
votes
1answer
686 views

Help understand GLSL directional light on iOS (left handed coord system)

I now have changed from GLKBaseEffect to a own shader implementation. I have a shader management, which compiles and applies a shader to the right time and does some shader setup like lights. Please ...
7
votes
2answers
2k views

Billboard rendering without distortion?

I use the standard approach to billboarding within Unity that is OK, but not ideal: transform.LookAt(camera) The problem is that this introduces distortion toward the edges of the viewport, ...
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
533 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
600 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
377 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
337 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
983 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
643 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
348 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
573 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
4k 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
801 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
423 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
550 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
893 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
457 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
957 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
357 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
488 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 ...