A programming language for OpenGL shaders.

learn more… | top users | synonyms

1
vote
1answer
67 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
58 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 ...
2
votes
2answers
175 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 ...
1
vote
0answers
42 views

Normal map lighting bug in bottom right quadrant [closed]

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
2answers
76 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 ...
2
votes
1answer
61 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 ...
1
vote
1answer
68 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
303 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
88 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
217 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. ...
-2
votes
1answer
71 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
75 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
51 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
76 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
62 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
196 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 : ...
0
votes
1answer
109 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 ...
2
votes
1answer
632 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
118 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
1answer
133 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 ...
4
votes
2answers
375 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 ...
1
vote
1answer
111 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
281 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
103 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
2answers
518 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
65 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
211 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 ...
0
votes
0answers
76 views

Using multiple uniform blocks in OpenGL

I'm using OpenGL with JOGL and want to use two unfirorm blocks in my vertex and pixel shaders. The following GLSL-Code shows the definitions:- uniform perObject { Material uMaterial; mat4 ...
1
vote
1answer
70 views

Why aren't subsequent glDrawArrays showing up?

I am attempting to redraw with the same arrays using glDrawArrays in a GLKView on iOS. When I comment out any two of these calls, the other draw call draws as I expect. My last hunch was that I was ...
2
votes
1answer
80 views

How to store an array into a texture and sampler the texture in vertex shader correctly?

I'm a new learner about OpenGL and GLSL. I'm coding a program in which i wanna store a group of datas in a texture and get the data by sampling the texture in vertex shader. Then i want to set the ...
1
vote
1answer
43 views

Having trouble setting color in fragment shader

For some reason, the color isn't applying to the object. Here's my fragment shader code. There's probably something obvious wrong with it that i'm not seeing. #version 330 core out vec3 Color; ...
0
votes
1answer
98 views

How does OpenGL determine different outputs with shaders?

Lets say I have this GLSL code: #version 330 out vec4 outputColor; void main() { float lerpValue = gl_FragCoord.y / 500.0f; outputColor = mix(vec4(1.0f, 1.0f, 1.0f, 1.0f), ...
3
votes
1answer
107 views

Applying a noise texture to distort edges

I asked this question over on StackOverflow but then found this site, and it's probably better suited to here. I'm trying to implement Sketchy Drawings. I'm at the part of the process which calls ...
1
vote
1answer
158 views

Why is the light following my camera around?

I have implemented a simple Phong shader without specular highlights for now (just ambient + diffuse components) The problem however, is that the calculations seem to be done in camera space; as I ...
0
votes
1answer
69 views

How do I follow this glsl1.2 + lights + shadows tutorial?

I am following this great tutorial but I have many questions. Let's see if I understand the basic idea. 1. I must create the same number of FBOs that lights (maximum 8). 2. I must create the same ...
1
vote
1answer
140 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 ...
3
votes
2answers
150 views

GLSL: sampler2D fallback to constant color?

So I have the following situation: I'm sharing a blinn shader accross many meshes. Some meshes have specular & normal maps, others do not. I'd like to, without making the shader code too ...
5
votes
1answer
163 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 ...
0
votes
1answer
143 views

(WebGL) Point light per-fragment issue

I'm using an FPS-like camera, this is the code: CAMERA mat4.identity(mat.mvMatrix); mat4.rotate(mat.mvMatrix,degToRad(-camera.pitch),[1,0,0]); ...
2
votes
2answers
396 views

3D position to UV coordinates in fragment shader

I am interested in converting an arbitrary 3D position computed at run time in the fragment shader to its corresponding UV coordinates. Notice that the 3D position I am interested in is NOT a 3D ...
1
vote
1answer
102 views

In glsl, how do indices work?

I have made a vertex shader and fragment shader and kind of know how they work, and I know that you specify what index you want your vertices to be in inside the shader program. So if the vertex was ...
2
votes
1answer
349 views

Alpha Blending: use the pixel with the smallest alpha

I'm writing a transparency shader where I need any intersecting textures to, wherever they overlap, take the texture pixel with the smallest alpha value and render only that, discarding the other ...
1
vote
1answer
324 views

GLSL - std140 uniform block - fields(vec, float, mat4) always 0.0

Ok, First of all, if just use uniforms everthing works like it should. Switching to uniform blocks nothing goes, as all values look like 0.0. I tested this with various if-then-else stuff within the ...
10
votes
2answers
986 views

Refractive glass shader

I have an infinite hexagonal floor, generated by tessellating a point grid in a tessellation shader pair: Note that this is a flat wireframe - the "shadows" are a lighting trick: Now, I'd like ...
2
votes
2answers
190 views

Does GLSL copy function arguments by value?

My question is about passing variables to GLSL shader. I'm not sure how that works and what are the performance implications. Say I got a function that accepts a "vec4" variable. The question is - is ...
1
vote
1answer
125 views

GLSL associating multiple uniform samplerBuffers

At the moment I'm not sure how my VBO and TBO associate with a specific uniform samplerBuffer in my shader, I have not linked them using the location or the vbo/tbo together. It seems to still work ...
1
vote
0answers
351 views

Normal mapping does not work correctly using GLSL and OpenGL [closed]

Hello I wrote a simple OpenGl program using GLSL to render a simple uv mapped plane using the normal mapping technics. Here's the display with a simple phong shading (without normal mapping) : Now ...
0
votes
1answer
94 views

GLSL/SFML - Only make portion of texture alpha

I'm trying to take a portion of the current texture and turn it to 50% transparent. I send in four values, signifying the rectangle I want to make transparent. It seems every time, however, that ...
0
votes
0answers
153 views

glsl fragment shader work diffrently on different devices

i'm making a 2d android game where i have a mechanics that allow the player to move the camera away from the main character, and to not allow him to explore the hole world, a have create a Fog shader, ...
2
votes
1answer
146 views

How to work with smaller intermediate textures in OpenGL and GLSL?

I'm working on a project rendering water simulated through smoothed-particle hydrodynamics (SPH) with a non-photorealistic look to use in games. In the actual stage of the project everything about ...