A programming language for OpenGL shaders.

learn more… | top users | synonyms

3
votes
1answer
21 views

Strange depth map projection

I'm trying to implement depth-only SSAO and for that, I render a depth map into a texture and pass it to my SSAO shader which then uses it. The problem is that when I try to output the depth map ...
1
vote
0answers
33 views

Set Render Target usage

I am using Unity and I have some difficulties about understanding the way Set Render Target works and how it can behave with the shaders. Is it possible to render a shader pass in multiple render ...
0
votes
1answer
47 views

How to wrap textures inside shader GLSL

I'm trying out GLSL and one of the problems I'm facing is wrapping a random texture sampler in the shader. Searching for answers on the web first, this leads me to using these commands: ...
1
vote
3answers
44 views

OpenGL, GLSL, Modify Background Fill via Fragment Shader

I have noticed that fragments rendered by the glClearColor() method do not pass through shaders. However, I'd like to modify these fragments using my fragment shader. Is there any way of forcing them ...
2
votes
0answers
37 views

equirectangular panorama rendering?

I want to render my scenes as equirectangular panorama frames. I can get the angular fisheye which is what I actually need by applying the rendered frame as a texture to a correctly UV mapped circle. ...
1
vote
2answers
41 views

Problem passing variables in fragment shader

I'm trying to pass a point light from an array to a CalcLight function in a fragment shader. It works when I hard code in the value, but not when I use a loop. Here's the code: #define TOTAL_LIGHTS ...
2
votes
1answer
30 views

Stencil buffer VS conditional discard in fragment shader

I have a continuous height-mapped mesh to represent landscape. I also have 1 to let's say 10 wells on this landscape represented by additional models. What I want to achieve is to create an illusion ...
1
vote
3answers
88 views

GLSL shaders work when hardcoded, not when loaded from file

I am trying to learn OpenGL. I have a main.cpp where I create the vertex and fragment shaders as strings, compile and link and it works fine. When I try to load the identical shaders from text files, ...
3
votes
0answers
65 views

Raymarching tangents

I've recently started to experiment with raymarching over on shadertoy.com. It seems common to find the normal for a distance field like so: vec3 scene_normal(vec3 p) { vec3 e = vec3(0.001, 0.0, ...
1
vote
1answer
30 views

Cubemaps turn black OpenGL GLSL Java LWJGL

Recently I tried to add cubemaps to my 3D-rendering engine. The objects with a cubemap now turn completely black. This is how I load my cubemap: public static int loadCubeMap(String filename) { ...
0
votes
1answer
24 views

Processing through multiple shaders (LWJGL/Java/OpenGL)

Very simple question: Is it possible to process a vbo through different shaders? If so, how? What I want is sth like this: reflectionShader.bind(); //starts shader reflectionShader.load(some_values); ...
2
votes
1answer
22 views

LibGdx OpenGl prevent black part of Light mask texture from overlapping

I am using this masking texture for a dynamic lighting effect in my game: It looks beautiful until two lights begin to overlap: This is obviously because the textures are overlapping when I draw ...
0
votes
0answers
18 views

Pass uniforms to Filter's shader

I wanna implement this shader (https://www.shadertoy.com/view/MslGWN#) in PhaserJS state. So i transformed the shader to WebGL style. I overload Phaser.Filter's update function to pass iChannel ...
0
votes
0answers
25 views

glsl specular not working

ok, i'm a complete noob regarding shaders and all this, so i must be doing something really stupid, but i cannot get specular lighting to work. I've read a whole lot of different shaders on the ...
0
votes
0answers
15 views

Perspective divide: Why use the w component? [duplicate]

In OpenGL, I have read that a vertex should be represented by (x,y,z,w), where w = z. This is to enable perspective divide, whereby (x,y,z) are divided by w in order to determine their screen position ...
0
votes
1answer
14 views

Passing data into a vertex shader for perspective divide

In OpenGL and GLSL, I am just learning about perspective projection and the vertex shader. However, I am a little confused about what data actually needs to be passed to the vertex shader, and what ...
0
votes
0answers
35 views

Image speeds up while moving and or rotating instead of constant speed

I'm having a problem with rotating/moving an image. I've set one of my images to rotate on it's z-axis buy updating the angle, but when I run my game, the image starts slowly starts to rotate from a ...
0
votes
0answers
17 views

OpenGL, glDrawElementsInstanced behaving differently on NVIDIA GPU than AMD

I have an AMD GPU on my desktop, AMD HD 5770. I am working on a project on my desktop for over a year. In the scene, I have instanced grass and instanced trees. Everything is working fine on desktop, ...
2
votes
1answer
34 views

OpenGL ES God Ray Precision error

I have encountered the following (i think) precision error. (missing link need 10 rep) My source of inspiration was: (missing link need 10 rep) On the PC everything works fine, but on android it ...
0
votes
1answer
47 views

Create a “genie” effect in fragment shader GLSL

I have tried a while now to create a genie effect on a scrolling plane to emulate the background/floor from the Mad Hatter fight in Adventures of Batman and Robin (SEGA). Judging the way the 16 bit ...
0
votes
2answers
65 views

How do I start and stop a GLSL shader?

Is there a way to start and stop a shader?. I want to use this shader to sweep once over my texture and then stop. Does anybody know how to do that? void mainImage( out vec4 fragColor, in vec2 ...
0
votes
0answers
31 views

ETC1 texture opacity

I'm using the cocos2d-x engine and want to support etc1 on android devices for my game. For ETC1 i'm using the mali compression tool, and GLSL. Everything is working, but I can't change the opacity ...
4
votes
1answer
107 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
30 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
56 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
59 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
40 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
81 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
157 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 ...
1
vote
1answer
80 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
71 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
70 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
143 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
33 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
1answer
398 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 ...
0
votes
0answers
71 views

Transparency in GLSurfaceView

I'm new in game development. I have a view using GLSurfaceview and call in MainActivity. i want to make transparent that view. i have tried setZOrderOnTop() method in MainActivity and glClearColor() ...
1
vote
1answer
66 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
67 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
51 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
52 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
113 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
80 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
125 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
57 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
2answers
207 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
83 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
89 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
64 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
54 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 * ...