A programming language for OpenGL shaders.

learn more… | top users | synonyms

2
votes
2answers
91 views

Render with multiple lights (one pass per light)

I have already a system that at the moment handle multiple lights just passing an array of light struct and loop through it. I had been told to switch to a multipass rendering approach. How should I ...
16
votes
1answer
2k views

Why does this geometry shader slow down my program so much?

I have an OpenGL program, and I'm rendering a terrain mesh. I displace the vertices in the vertex buffer and don't really color them in the fragment shader yet. I'm adding a geometry shader one part ...
1
vote
1answer
79 views

Setting uniform value of a vertex shader for different sprites in a SpriteBatch

I'm using libGDX and currently have a simple shader that does a passthrough, except for randomly shifting the vertex positions. This shift is a vec2 uniform that I set within my code's render() loop. ...
1
vote
1answer
81 views

GLSL to Cg: why is the effect different?

With reference to this question, where I was trying to make the shader compile, I am now trying to make an effect appear. The effect can be shown here, through a GLSL shader: But when I use the ...
7
votes
2answers
10k 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): ...
0
votes
2answers
63 views

Passing variables down the pipeline glsl

I am sorry to post a question that may be easily tested, but I don't have an OGL4+ hardware at the moment and I have to make some design decision beforehand so I wanted a clear scenario. Looking at ...
2
votes
2answers
124 views

Strange if-else branching behavior in a fragment shader

In my fragment shader I have passed an uniform int uLightType variable, which indicates what type of light is in usage right now. The problem is that if-else branching does not work correctly - the ...
0
votes
1answer
39 views

GLSL to Cg fragment shader

I have found very useful resource on the Swiftless website on OpenGL. Unfortunately, I cannot manage to adapt a GLSL fragment shader to my project, which uses Cg. Here it is: uniform sampler2D ...
0
votes
0answers
109 views

Problem when using two different shaders

I have created a simple shader for drawing my scene in OpenGL. When another shader was introduced, a problem appeared. I use the first shader and draw few objects in the scene. Then I use the second ...
3
votes
1answer
83 views

what happens with missing vertices in geometry shader

I am relatively new to GLSL shader programming, and the documentation I found is unfortunately often inscrutable. I am having trouble understanding a few things with how geometry shaders fit into the ...
1
vote
1answer
262 views

Deferred Rendering With Diffuse,Specular, and Normal maps

I have been reading up on deferred rendering and I am trying to implement a renderer using the Sponza atrium model, which can be found here, as my sandbox.Note I am also using OpenGL 3.3 and GLSL. I ...
0
votes
1answer
47 views

What coordinates are we passing to pixel shader from vertex shader?

I have read articles about shader programing and understood the very basic knowledge of shader programing. One thing I always get confused is about the texture mapping. What I pass(output) from VS to ...
4
votes
2answers
218 views

Per-pixel displacement mapping GLSL

Im trying to implement a per-pixel displacement shader in GLSL. I read through several papers and "tutorials" I found and ended up with trying to implement the approach NVIDIA used in their Cascade ...
0
votes
1answer
76 views

why is glVertexAttribDivisor crashing?

I am trying to render some trees with instancing. This is rather weird, but before sleeping yesterday night, I checked the code, and it was in a running state, when I got up this morning, it is ...
1
vote
0answers
76 views

How to shade hair (line segments) correctly in GLSL

I render my hair geometry in line segments. The problem I have is with the correct shading of the hair. From what I've read I understood that I need the direction of the line segment and the ...
0
votes
0answers
26 views

Shadow bias selection with moving light

I've been looking at shadow mapping and although I managed to get them to work selecting an appropriate bias. The problem is when I start moving the light. The shadows work fine for not extreme ...
-1
votes
1answer
79 views

More than 8 lights without deferred shading / lighting [closed]

I want to know if there is any technique (efficient) to use more than 8 lights in a scene made ​​with OpenGL and GLSL. Without making use of deferred shading / lighting. I have not implementadon ...
1
vote
2answers
88 views

Bad pixels on shader when loading cached binary programs

I have been trying to cache binary shader programs in my game and load them accordingly using "glGetProgramBinaryOES" and "glProgramBinaryOES" respectively. I was successfully able to cache and load ...
1
vote
2answers
128 views

2D Outline shader in GLSL

I have a simple prototype with 2D worms-like destructible terrain. I use a trivial shader to discard pixels based on a mask. varying vec2 v_texCoords; uniform sampler2D u_texture; uniform sampler2D ...
1
vote
1answer
51 views

Handling multiple lights of different types in GLSL

I want to be able to support multiple lights of different types (point, spot & directional). Note that I also want to be able to render transparent/translucent objects, which rules out deferred ...
2
votes
3answers
268 views

GLSL Sphere from Vertex

I am working on a particle simulation where we have a lot of spheres which can have different radii. Using this tutorial http://mmmovania.blogspot.de/2011/01/point-sprites-as-spheres-in-opengl33.html ...
1
vote
1answer
110 views

Blinn, Normal maps & Fresnel?

So something came up today when I was going over my Blinn shader. As I've been taught, the half-angle vector is calculated in the fragment shader, and is equal to normalize(lightDir + viewDir). This ...
0
votes
0answers
40 views

gl_ClipDistance[] not working

I am unable to get gl_ClipDistance to work. The results I'm getting are the same as if I didn't enable clip distance. I have called glEnable(GL_CLIP_DISTANCE0); and glEnable(GL_CLIP_DISTANCE1); in ...
1
vote
1answer
64 views

Normal Mapping space confusion

I've been reading today about normal mapping. Up to now, the only normal mapping I encountered was with maps already in world space so I just extracted the info from the texture and transformed them ...
8
votes
1answer
108 views

How can I reliably implement GPU skinning in Android?

I'm trying to get character skinning working on Android. The idea is quite vanilla: I have my skinning matrices, and along with each vertex, I send up to four matrix indices and four corresponding ...
1
vote
1answer
50 views

Component-wise GLSL vector branching

I'm aware that it usually is a BAD idea to operate separately on GLSL vec's components separately. For example: //use instrinsic functions, they do the calculation on 4 components at a time. float ...
-1
votes
2answers
48 views

GLSL Normals not transforming propertly

I've been stuck on this problem for two days. I've read many articles about transforming normals, but I'm just totaly stuck. I understand choping off W component for "turning off" translation, and ...
1
vote
0answers
35 views

Normal map lighting bug in bottom right quadrant

I am currently working on getting normal maps working in my project, and have run into a problem with lighting. As you can see, the normals in the bottom right quadrant of the lighting isn't ...
2
votes
1answer
51 views

Why do the order of uniforms gets changed by the compiler?

I have the following shader, everything works fine when setting the value of one of the matrices but I've discovered that getting a value back is incorrect for View and Projection, they are in reverse ...
2
votes
2answers
47 views

Colorize with a given color a texture

I have a texture and I want to "colorize" it with a given color, lets say cyan (#00ffff) or purple (#800080). What I want to do, is get all the pixel values from the texture, and remove the color and ...
1
vote
1answer
54 views

Creating blur with an alpha channel, incorrect inclusion of black

I'm trying to do a blur on a texture with an alpha channel. Using a typical approach (two-pass, gaussian weighting) I end up with a very dark blur. The reason is because the blurring does not properly ...
2
votes
1answer
259 views

OpenGL 4D textures with bilinear interpolation

I want to use and interpolated 4D texture in OpenGL, i.e. a texture that is accessed with a texture coordinate vector (s, t, p, q) and interpolated linearly in every texture coordinate. The extension ...
1
vote
0answers
59 views

Different way to pass uniforms to seperate draws in glMultiDrawElementsIndirect

Given OpenGL version 4.3 and GLSL 430, what would be the best way to pass a matrix to each model in a draw call to glMultiDrawElementsIndirect? I am thinking of going the way of a TBO and indexing it ...
-2
votes
1answer
57 views

List of GLSL ES built-in variables

I am writing an article on WebGL and three.js, I'm trying to search all the built-in variables available in the vertex and fragment shader. I've found many sites mentioning some, for example: ...
0
votes
2answers
61 views

Trouble getting shadow maps working

I am trying to implement shadow maps in my game following this tutorial. For some reason, the light is not being occluded. In the above screenshot, the big white sprite in the foreground is a ...
0
votes
1answer
42 views

Way to avoid excessively bright objects with specular lighting?

I have a typical Phong shading with specular light. I have all the parameters tuned so to give appropriate highlights from a point light source. Now the problem I have is a new object that has a large ...
1
vote
1answer
69 views

GLSL: Noise via texture

I am trying to access a texture in a fragment shader to overlay this texture over a certain area. varying vec4 v_color; varying vec2 v_texCoord0; uniform sampler2D u_sampler2D; uniform vec4 ...
0
votes
1answer
58 views

Light direction not being calculated correctly

I'm trying to implement deferred lighting in my game, and have run into an issue with normals. The image above shows the lighting being applied to a tile map. The yellow shade represents the ...
0
votes
1answer
62 views

Transforming normal vector in GLSL

I'm looking at a basic diffuse light shader here http://en.wikibooks.org/wiki/GLSL_Programming/Unity/Diffuse_Reflection. Diffuse light needs the normal vector in eye-space, so that it can dot it with ...
0
votes
1answer
138 views

Optimizations using GLSL shaders

I have written a simple OpenGL application using GLSL shaders. Actually, my program just displays a simple cube with a phong lighting effect like below : Here's a peace of the client code : ...
2
votes
1answer
166 views

How does GL_INT_2_10_10_10_REV work for color data?

Can anybody tell me how exactly to use GL_INT_2_10_10_10_REV as type parameter in glVertexAttribPointer()? I am trying to pass color values using this type. What is the significance of "REV" suffix ...
1
vote
1answer
100 views

GPU skinning algorithm incorrectly distorts mesh

I've been trying to implement a GPU-based matrix palette skinning algorithm with WebGL, but the rendering appears incorrect even though I can't find evident conceptual problems in the underlying ...
5
votes
1answer
146 views

How can I implement real-time mutual object reflection?

So, given a scene like this (cubemap skybox with "real" spheres) Everything looks great, except for the fact that the spheres don't reflect each other. What's a good way to go about this? The ...
1
vote
1answer
75 views

Gamma Space and Linear Space with Shader

I am using Unity and I can choose between two color space mode in the settings: Gamma or Linear Space. I am trying to build a Custom Lighting Surface shader but I am facing some problems with those ...
1
vote
1answer
132 views

gl_VertexID values when calling glDrawElements

I am struggling a bit to understand the values that gl_VertexID primitive contains when the vertex shader is executed. I have the standard modern rendering pipeline, in which after setting up ...
-1
votes
1answer
65 views

Unity's pack 4 floats

Linked to: GLSL pack floats into an RGBA texture I found EncodeFloatRGBA/DecodeFloatRGBA shader functions in Unity https://gist.github.com/hecomi/9580605 Now I try to figure out how they work. So I ...
0
votes
1answer
100 views

How can I animate a portion of the textures on a model?

I have a model to which I have attached multiple textures. Both textures are currently static, but if I want to move (or slide) the texture which is on the top (in UV space), is that possible? Maybe ...
0
votes
2answers
281 views

GLSL: can i use matrix transformation functions in vertex shader?

I have a working OpenGL code where i render a terrain with some trees. I am doing all the matrix mathematics on the client side. Because of which the frame rate of my app is very low, around 25-30 ...
0
votes
1answer
49 views

Providing texture coordinates and using indexed drawing at the same time

Please consider the following vertex structure struct vertex { vec3 posL, normalL; }; Using this vertex layout, we can provide the vertex data in an interleaved way, i.e. ...
2
votes
1answer
129 views

How can I repeat / scroll a tile which is part of an texture atlas?

I would like to scroll a tile which is part of a texture atlas like it can be done with a single quad and texture wrap mode set to repeat. Can this be done? I hope it's clear what I would like to ...