A programming language for OpenGL shaders.

learn more… | top users | synonyms

2
votes
1answer
36 views

GLSL 2D Silhouette

I'm trying to render a silhouette of any entity behind foreground objects to indicate their position to the player. Here's an example of what I want to achieve, from Hyper Light Drifter: From what ...
0
votes
0answers
26 views

GLSL lighting shader with model scale

Basically, i'm just trying to find out where to insert the model scale into the lighting calculations. Ive searched the web, but amazingly, couldn't find anything dealing with scale + GLSL. This is ...
1
vote
1answer
21 views

ETC1 Support on android alpha problem (GLSL cocos2d-x)

I want to support etc1 in my game, but somehow it doesn't work (I'm using cocos2d-x C++ GLProgram* glp = new GLProgram(); glp->initWithVertexShaderFilename("testv.vsh", "test.fsh"); ...
0
votes
2answers
33 views

GLSL Fragment shader lighting lambert term

Just a simple question: Should I or should i not normalize the SurfaceToLight vector to calculate the lambert term on a GLSL lighting shader? I mean, here: vec3 CalculateLights ( void ) { vec3 ...
0
votes
1answer
27 views

OpenGL Shaders Ignored

I have been following this tutorial to try and start learning OpenGL. However, upon compiling my code, my triangle turns out to be black. At first I thought that there was something wrong with the ...
2
votes
1answer
66 views

GLSL 330 Core Bug? - Uniform variable will not set to value if it is named a certain way

In the code below I have a uniform variable named "vw_matrix" used in the calculation for gl_Position. When I run my program, a rectangle gets printed to the screen. #version 330 core layout ...
2
votes
0answers
144 views

Texturing Objects in OpenGL

Using OpenGL tutorials found here, I constructed an .obj file loader as well as a texture file loader using SOIL. I have an issue with drawing a textured object. (Shown here) Assuming I created the ...
0
votes
1answer
66 views

How can I blend up to 3 textures on a polygon without blend maps?

For my voxel game I need to blend up to 3 textures in the same polygon. It would be preferable if I could specify a texture id for each vertex, but other solutions are accepted as well. Here's an ...
0
votes
1answer
60 views

Error drawing two VAO, each one using different shader programs (vertex + fragment shader) in OpenGL Core 4.3 / GLSL 430 (SOLVED)

I am trying to draw over a GL_TRIANGLE_FAN one texture to render video frames, using shaderProgram1, and render above it some points (GL_POINTS) using shaderProgram2. By this way: (OpenGL Core 4.3) ...
1
vote
1answer
50 views

WebGL half float equivelant?

I'm trying to find a half float for the purposes of doing math in a fragment shader, not trying to have a half float texture. Is there an equivalent of the half float data type in WebGL? I know you ...
3
votes
1answer
127 views

2D day night mapping

I'm looking for this kind of effect MINUS the lights and snow (Another problem). It needs to change depending on the time of year. Doesn't need snow or city lights. Now I'm pretty new to shaders ...
0
votes
0answers
18 views

Slick2d - apply shader

I have a problem. I'm trying to apply a shader to the whole screen. Since I haven't used shaders before I don't know how to pass the texture to the shader. Everything else works... So here are the ...
4
votes
0answers
294 views

Skeletal animation in OpenGL

I'm using Assimp to do skeletal animation in my OpenGL application. I used Blender to export this one-boned model to a COLLADA file: The model has only one bone, called arm bone, that controls the ...
1
vote
1answer
62 views

How to only render fragments with Z from 0 to 1 in OpenGL?

I have been using OpenGL for a year now, but I just recently found out that OpenGL only clips vertices when the absolute value of the x,y or z coordinate is less than the absolute value of w ...
0
votes
1answer
47 views

how change branching logic to math equivalent glsl? [closed]

im totally newbie and this just for fun afaik lot of best practice suggest to minimize usage of branching. can you help me optimize below glsl especially on branch part? ( target 120 ) the bgcolor ...
0
votes
0answers
43 views

Shader - Simple SSS lighting issue

I am trying to create a simple subsurface scattering effect using a shader but I am facing a small issue. Look at those screenshots. The three images represents three lighting states (above surface, ...
0
votes
1answer
39 views

Can glsl main() have params or return a value?

I haven't ever seen anyone declare main as anything but void main() or void main(void) but I'm curious, is it possible to have a parameter or return value?
0
votes
1answer
102 views

Shader - Color blending

I would like to know how to blend colors in a specific way. Let's imagine that I have a color (A) and an other color (B). I would like to blend them in such a way that if I choose white for the (B) ...
1
vote
1answer
46 views

Modern OpenGL Texture Displaying Incorrectly [closed]

I've been working with this code and have simplified it to the most basic form possible, and even then I cannot get a texture to display properly at all. Here is the code: ...
1
vote
1answer
60 views

Shader - Convert vector into scalar

I am trying to convert a half3 as a simple half but I am facing an issue. As for an example half3(1, 0, 0) give me white but half3(0, 1, 0) gives me black. How can I convert properly a half3 to a ...
2
votes
1answer
85 views

How to handle the birth and death of particle without reading from the buffer

I've implemented a simple particle system where each particle has a position, velocity, age and lifespan stored in different SSBOs. Most of the data including all the position, velocity and age is ...
0
votes
0answers
44 views

Shader to mask image with polygon

I'm new to graphics programming and GLSL in particular. I'm working on a 2D game and the setup is as follows: There is an image on the screen (a sprite in the game engine [Cocos2d-x if it matters]) ...
1
vote
1answer
105 views

2D Hidden Object Silhouette Shader

Right now I am not using any depth information in my engine, but I just found out that it would be neat to be able to render the silhouette of important game objects that are "behind" something with a ...
0
votes
2answers
80 views

Problems with Rotation Matrices on Certain Axes

Here is what my rotation matrix looks like: public Matrix4f initRotation(float x, float y, float z) { Matrix4f rx = new Matrix4f(); Matrix4f ry = new Matrix4f(); Matrix4f rz = new ...
0
votes
0answers
69 views

Is Phong shading supposed to be so camera-angle dependent?

I'm not sure if I have a bug in my code or not. It seems like it's a bug, or at least a major shortfall. Here's two images of the same model at slightly different angles (by moving the camera): As ...
2
votes
2answers
54 views

Rectangular area light illuminance - colour banding

I'm currently working on an implementation of rectangular area lights but I am having some issues with the illuminance calculation, which gives me serious colour banding across the entire lit area. ...
1
vote
0answers
48 views

Confused About My Code Suggesting The Normal Matrix Is Equivalent To The ModelView Matrix

I'm learning environment mapping in OpenGL by following this page. In his vertex shader, the author calculates the vertex normal in eye space with the following code: nEye = vec3(viewMatrix * ...
3
votes
2answers
116 views

Blending vs Texture Sampling

I don't think this question has been asked before as I couldn't find any information about this on the internet. Lets say I want to blend two textures together: A texture containing the result of ...
0
votes
0answers
41 views

change position/orientation of a bone using assimp

I have been using assimp to import rigged models and animations. I followed this tutorial for skeletal animation and I have got it done properly. The part that I am trying to do now is to orient a ...
3
votes
1answer
155 views

How to generate a RGB * a texture for a glow effect in GLSL?

I would like to create a glow effect in GLSL, there is a tutorial that explains how we multiply RGB * a : I have some questions : is it an operation that is in a fragment shader, where RGBa is ...
2
votes
0answers
82 views

OpenGL Planet Generation - Simple Matrix Issue (Planet “Spins” With Mouse)

I originally asked this question on StackOverflow & was directed here by a commenter. Im currently working on a OpenGL planet rendering. I'm using the Tessellation pipeline. So far things are ...
0
votes
0answers
40 views

Can i use shaders in allegro without opengl?

I'm currently learning opengl but it seems quite complicated so i considered using some library like sdl or allegro. I noticed that allegro has some built in functions to create and attach shaders. ...
0
votes
0answers
48 views

Textured/Vertex Colored Shader fallback

I have this simple ShaderLab shader that I use for particles, among other things (it's more complicated than this but I have omitted the unnecessary bits). When I do not specify a texture, it falls ...
0
votes
1answer
194 views

OpenGL Shader Storage Buffer Objects array length problem

Ok guys, I think I have a very strange problem. I have an old laptop, but its HD 6370M currently supports opengl 4.4, so i decided to learn how to use some new features of this platform, so after ...
0
votes
1answer
139 views

How to use a buffer in GLSL to do a LUT-lookup?

I am currently on a medical application which needs different kinds (up to totally individual) lookup tables (LUT) for image display. And this done with 10bit finish. So it is most of the time ...
0
votes
0answers
26 views

converting HSLS gives error

I'm using the following parser: https://github.com/unknownworlds/hlslparser I also have the following code: /* * Bo Sun, Columbia University, All rights reserved * ...
1
vote
1answer
75 views

Calling Shader Functions Inside Other Shaders

I'm new to OpenGL and GLSL, and bit confused about calling conventions of shader functions. I'm trying to implement various procedural noise algorithms in GLSL. I'd like to have separate files for ...
1
vote
1answer
143 views

Dot based light mask with shader on sprites

So I have a scene, completely based on 2D sprites. I want to render "light sources" into a seperate frame buffer (so mostly dots around, for example, the centre of a flame) and then render that frame ...
0
votes
0answers
57 views

Invalid operation (1282) in GLSL vertex shader

My GLSL vertex shader works fine, but you if put a for loop inside or rename the uniform xxx to something else, it says the follwoing: Exception in thread "main" org.lwjgl.opengl.OpenGLException: ...
0
votes
0answers
31 views

Strange result, when changing variable name

I have no idea, what is going on. The mat4 xxx is the cause. Renaming it to "bones"/"bone_transfromations" etc. won't work it gives me an error. Renaming it to "test" works perfectly fine... This is ...
3
votes
1answer
184 views

What are the advantages of tangent space shading/lighting, and what about attenuation?

In several topics here it was suggested by people that doing lighting in tangent space is better than doing it in world space. Right now I am doing it in camera space, but it's really similar to world ...
1
vote
0answers
91 views

How much is atomicAdd slower than an atomic counter?

I am considering replacing an atomic counter in my shader code with a SSBO an atomicAdd operation. What I need to know is the difference in performance of these two. I know the atomic counter executes ...
1
vote
2answers
118 views

glsl uniform int as index of const array

I have a const array that define a few materials for directionnal light. I'd like to change the material using an uniform int as index of that array. Doing that leads to severe framerate drop. I know ...
0
votes
0answers
107 views

loading a model, which has multiple meshes using assimp

I have been using Open Asset Import library(assimp) along with OpenGL API to load and render 3D models. I followed some tutorials and have got the output as expected. But, I have failed to understand ...
0
votes
0answers
66 views

Achieve SSAO with deferred rendering,GLSL

I'm trying to add SSAO effect to my engine and it doesn't look as it should. To achieve this effect I based on this article. I'm using also deferred renderer so I entered some modifications: ...
1
vote
3answers
177 views

Passing array to uniform in glsl error

Here is my attemps to pass array to uniform array: struct Vector{ float x,y,z; } float threshold[2] = { 0.5, 0.25 }; Vector *kernel = new Vector[_kernel_size]; // _kernel_size==16 // fill kernel ...
1
vote
1answer
76 views

OpenGL Post Processing Introducing Artifacts on Certain Systems

Playing around with God-Rays in my framework, I was greeted with the following artifacts on my laptop: The artifacts themselves act almost like noise, flickering around the image rapidly. They also ...
0
votes
0answers
67 views

Motion Blur (as per GPU gems article) only considers camera rotation, not translation

I am following this article and have implemented it exactly as described: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch27.html The problem is that things are only blurred when the camera is ...
-1
votes
2answers
140 views

How can I optimize these GLSL bitwise operations?

I need the following part of my vertex shader simplified. Sb=Sb|((gl_VertexID&(128+1))<<9); Sb=Sb|((gl_VertexID&(512+4))<<6); Sb=Sb|((gl_VertexID&(2048+16))<<3); ...
3
votes
1answer
123 views

If-clause in GLSL

I read a few thing about, that in GLSL both sides of the if-clause is executed, so do you have any idea for a workaround for this one: uniform int uses_bones; uniform mat4[] bone_transformations; ...