A programming language for OpenGL shaders.

learn more… | top users | synonyms

0
votes
1answer
259 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
128 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
855 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 ...
1
vote
1answer
415 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
215 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 ...
2
votes
1answer
500 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
944 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
256 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
208 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
186 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; ...
0
votes
2answers
1k 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
222 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
529 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 ...
4
votes
1answer
1k 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
158 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
147 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
193 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
264 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 ...
3
votes
2answers
289 views

Using a programmable pipeline in a game engine

As a learning experience, I'm developing my own 3D game engine using OpenGL. I'm a little confused as to how to implement my rendering engine such that it uses a programmable pipeline while still ...
0
votes
1answer
956 views

How to draw a circle with WebGL using GL_POINTS [closed]

I'm trying to draw a circle using simple vertices points and a big gl_PointSize value. I found this example and try to reproduce it on WebGL with no success.
7
votes
1answer
982 views

Optimizing performance of a heavy fragment shader

I need help optimizing the following set of shaders: Vertex: precision mediump float; uniform vec2 rubyTextureSize; attribute vec4 vPosition; attribute vec2 a_TexCoordinate; varying vec2 tc; ...
-1
votes
1answer
108 views

Shader applied to Texture is not showed in GLSLES

I'm trying to learn the basic of shaders following basic tutorials in Ogre. I use GLSL ES 2.0 #version 100 I think I have a basic concept problem. I'm trying to render a model + texture without make ...
0
votes
0answers
264 views

Specular Light not working Phong shading

I want to implement Phong-Shading using GLSL. I also want to calulate all values using uniforms in the shaders. Nearly everything works fine, but there is an error with the specular term of the ...
0
votes
1answer
92 views

Direction from the camera to the light source

I'm currently writing a game using OpenGL and GLSL. For the shader I need the direction from the current camera to the light source. The lightsource is given by lightSource.position as a uniform as ...
1
vote
3answers
855 views

Set a variable inside a GLSL fragment shader that persists for the render

Is it possible to set a varying variable inside a fragment shader and have it persist? I'd like to use the depth component of the first fragment and use it on all the others, making the fragments all ...
3
votes
2answers
2k views

2D water shader similar to Limbo's effect

I'm wondering how I would go about creating a 2D water shader that is seen in this video http://www.youtube.com/watch?v=phChFfi4GOs The water effect that limbo uses is pretty awesome. I'm not so ...
0
votes
1answer
199 views

bump mapping with 2 normal maps

I was wondering if its actually possible to do bump mapping with 2 normal maps... I have tried doing it this way however I get a function overload on max and dot. uniform sampler2D n_mapTex; uniform ...
0
votes
1answer
121 views

texture movement stutters

Hey I at the moment I have got my texture to move however it stutters as I increment by 0.001 every second. My animation is done via FPS if that make sense and here is some code FrameCount++; ...
0
votes
1answer
218 views

texture won't move OpenGL ES 2.0

I want be able to move my texture in GLSL I have set my texture to wrap S and wrap T but not sure why it wont move my fragment shader looks like this at the moment uniform sampler2D n_mapTex; ...
3
votes
2answers
823 views

scaling point sprites with distance

How can you scale a point sprite by its distance from the camera? GLSL fragment shader: gl_PointSize = size / gl_Position.w; seems along the right tracks; for any given scene all sprites seem nicely ...
4
votes
1answer
843 views

variable number of lights in a glsl shader?

I want to render an arbitrary number of lights in my fragment shader. I do not understand how you can properly pass them into the shader though. For example, I want something like this: uniform int ...
0
votes
1answer
119 views

How to alter the angle of texture projection

I'm currently working on a 3Dish game; it's on a grid, with 3D props and the camera looking down on the grid at about 45º, but I want to use 2D sprites for the player and NPCs. Currently, I'm using a ...
-1
votes
2answers
240 views

GLSL: Why can only some of the matrices be found? [closed]

I've been learning GLSL and to start I've been trying to replicate the fixed-function pipeline functionality with it, for 2D graphics. I've done it successfully in most things, so far, but I came into ...
2
votes
1answer
206 views

gbuffer - how to store an integer data

In a gbuffer I store a diffuse color in following texture: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); I want to store an integer data which ...
5
votes
1answer
2k views

How to do simple bump mapping

I'm trying to do bump mapping, and I'm getting fairly close at achieving my goal. I miss one crucial piece of my puzzle to have bump mapped effect in my scene; I need to transform the normals from my ...
0
votes
1answer
701 views

Reinhard tone mapping and color space [closed]

I found two ways of doing tone mapping (first, second): //Ld - this part of the code is the same for both versions float lum = dot(rgb, vec3(0.2126f, 0.7152f, 0.0722f)); float L = (scale / ...
2
votes
1answer
323 views

RGB to xyY color space conversion and luminance

The luminance calculated by following GLSL functions (fragment shaders - tonemap) has different value: float GetLuminance (vec3 rgb) { return (0.2126 * rgb.x) + (0.7152 * rgb.y) + (0.0722 * ...
2
votes
0answers
202 views

iPhone GLSL shader dynamic branching issue

I am trying to pass an array of vec3 as uniform and then iterate through them on each pixel. The size of array varies on situations so I can't make the loop with constant number of iterations. ...
0
votes
1answer
164 views

How do I pass textures into a fragment shader in Slick?

I've written a shader that uses three different textures, tex0, tex1, and tex2. I can load it into Slick and successfully display it, but I can't figure out how to set the three different textures. ...
2
votes
2answers
1k views

GLSL Motion blur on mobile.. possible at acceptable framerates?

I have been struggling to implement a simple linear motion blur effect on mobile (Android, OpenGLES 2.0) but it just seems to destroy my framerate. I'm rendering to texture (FBO) then applying a ...
2
votes
1answer
415 views

How to solve artifacts caused by vertex lighting in my voxel engine?

My current lighting system bakes the light amount based on ray-tracing from the light source to the 8 corners of the block (so per-vertex) and the distance to the light on the blocks. It works ...
0
votes
1answer
248 views

How to get a smooth dimming with SSAO?

I implemented SSAO in my game based on the tutorial at gamerendering.com. But the results I get are disappointing. Instead of a smooth effect as seen in the nvidia demos, my implementation causes ...
0
votes
2answers
230 views

LWJGL Game crashes on some other machines [closed]

I just tried running my game on a friend's laptop, but for some reason it crashes. The exported .jar runs fine on my machine, and some others too. I can see that is has something to do with the ...
4
votes
3answers
697 views

Voxel engine artifacts

There are white little dots between blocks at random places, mainly at very near blocks. They disappear when I move the mouse and change the view direction. I use Vertex Arrays with ...
1
vote
1answer
176 views

OpenGL VBO Additional Attributes

If I have a buffer with my vertices, normals and texture coordinates, and I use glDrawArrays to draw the VBO to the screen, how can I send attributes per vertex that I placed in an array to the shader ...
4
votes
2answers
626 views

Do opengl games tend to use multiple shaders? [duplicate]

For any given object that you want to render, there may be a whole bunch of things that need to be considered for rendering (Material, Texture, Lighting, Blending etc). But, you may also have some ...
2
votes
1answer
1k views

glsl 150 struct in uniform buffer object

Can I do this in opengl 3.2 / glsl 150? glsl shader: struct LightSource { vec4 ambient; vec4 diffuse; vec4 specular; vec4 position; vec4 direction; }; ... layout(std140) uniform ...
2
votes
1answer
249 views

How to transform a shadow map to camera view?

I'm making a rendering engine as a hobby to learn more about 3D. I have a deferred renderer with the G-buffer (color, normal and depth). I also have a lighting controller that uses only spotlights at ...
-5
votes
3answers
334 views

in the shadow of a sphere [duplicate]

(Related, but somewhat different, to my previous question) How can I determine in a fragment shader if a fragment is in the shadow of a sphere? That is, if it is occluded by the sphere and is past ...
5
votes
1answer
831 views

What is the recommended way to output values to FBO targets? (OpenGL 3.3 + GLSL 330)

I'll begin by apologizing for any dumb assumptions you might find in the code below since I'm still pretty much green when it comes to OpenGL programming. I'm currently trying to implement deferred ...