0
votes
1answer
83 views

3D position of an arbitrary UV coordinate

I have a UV map for a 3D mesh that encodes "links" between pairs of UV coordinates. I have previously defined this links (or pairs), one to one. The links are enconded using the function rgb_color(u1, ...
0
votes
2answers
59 views

Best way to detect if vec3 is between vec3(x) and vec3(y) in glsl

As titled I am sampling from a texture and if the color is somehow gray [vec3(.8), vec3(.9)] and an uniform is 1 I need to substitute that color with another one I am not a glsl veteran but I am ...
2
votes
2answers
122 views

Water silhouette shader using GLSL

I have this problem to solve using Cocos2d-x 3.x: In my game there is water represented by rectangle texture, modified by the code on the go. I also have a character moving around, rotating etc. I ...
0
votes
0answers
80 views

OpenGL shading doesn't work with different projection and view matrices?

I found an online (public-domain) code to do marching cubes, and I am trying to adapt this code to work in my own project. The code uses GLUT and "older-style" OpenGL, whereas I am using GLM and ...
1
vote
2answers
94 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
votes
1answer
78 views

Combine Two Shader Program [closed]

For my android application, I want to apply brightness and contrast shader on same image. At present I am using gpuimage plugin. In that I found two separate program for brightness and contrast as ...
1
vote
1answer
49 views

Depth Map resolution shifting

the problem is with shadow mapping as you can see, actually it works fine but in a certain condition that the Depth Map size must be equal to the size of rendering buffer, I use an infinite ...
0
votes
1answer
177 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 : ...
1
vote
1answer
42 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
95 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), ...
2
votes
2answers
330 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
2answers
209 views

gl_FrontFacing - is there perfomance cost?

If I use gl_FrontFacing in my PS, is there any performance cost during vertex transformation (like cross product from triangle vertices), or is this value computed any time ?
0
votes
1answer
57 views

blend skybox runtime

I use soil to load the cubemaps. the fragment shader uses cubeMap2 as the current cube map. However, I want to change the cube Map based upon an event. My problem is how can I change the cube map. ...
0
votes
1answer
578 views

problem using glm::lookAt and glm::perspective

I'm trying to change the code from the 22th tutorial at http://ogldev.atspace.co.uk/, using the GLM library, but the result seems wrong. The problem is shown in the below picture: While it should be: ...
0
votes
3answers
154 views

directional lightning

I have managed to get a point light working, but I am facing problem with directional lightning. Fragment shader uniform vec4 lightColour ; uniform vec3 lightPos ; uniform float lightRadius ; ...
3
votes
4answers
671 views

How many times fragment shader is executed?

I have an OpenGL code, with 3 different shader programs. I have a simple question, I know fragment shaders are executed for every every fragment in the scene. But is there a way using which we can ...
0
votes
1answer
202 views

Creating a fragment shader to darken a white texture over time - OpenGL GLSL

So as a part of learning OpenGL, I've now decided to try and be a bit more creative with shaders, as part of a practice game I'm making using C/OpenGL. I'm completely new when it comes to working ...
2
votes
3answers
1k views

OpenGL additive blending not working as expected

I am trying to achieve additive blending with point sprites. When the sprites overlap, all I get is solid red, when I expect to get a smooth blend from red->yellow->white. My sprite texture has all ...
7
votes
2answers
5k views

GLSL Shader - Change Hue/Saturation/Brightness

I'm trying to change the hue of an image using a GLSL fragment shader. I want to achieve something similar to Photoshop's Hue/Saturation Adjustment layer. In the following image you can see what I've ...
4
votes
1answer
953 views

using heightmap to simulate 3d in an isometric 2d game

I saw a video of an 2.5d engine that used heightmaps to do zbuffering. Is this hard to do? I have more or less no idea of Opengl(lwjgl) and that stuff. I could imagine, that you compare each pixel ...
0
votes
1answer
76 views

Vertex and Fragment Shader worldNormal

How to access/calculate worldNormal in a Vertex and Fragment shader ? Thanks a lot !
0
votes
1answer
123 views

Per-fragment lighting system behaves like ambient lighting system

This is the relevant section of my fragment shader varying vec3 normal; varying vec3 halfv; ... vec4 color = ambient * gl_LightSource[0].ambient; vec3 n = normalize(normal); float ...
2
votes
1answer
351 views

Fog shader camera problem

I have some difficulties with my vertex-fragment fog shader in Unity. I have a good visual result but the problem is that the gradient is based on the camera's position, it moves as the camera moves. ...
3
votes
2answers
154 views

Opengl shader questions

I'm currently building a shader that takes a 2D texture sampler and uses UV coordinates to map it. This works fine for all textured objects. However, I'm having a bit of a problem as I'm trying to ...
2
votes
2answers
588 views

Realtime fisheye to cubic or spherical panorama transformations with OpenGL or pixelshaders

I'd like to transform a sequence of circular fisheye-images to cubic or spherical panorama images to be used in a panorama-viewer based on OpenGL. The viewer-part is nemas problemas but the transform ...
0
votes
1answer
124 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 ...
2
votes
1answer
140 views

Fragments never falling into spot light's cone

I am using GLSL version 1.20 with OpenGL 2.1 . I am trying to compute when a fragment falls into the area of a spot light. I have already set all the light values with glLightfv and glLightf, also ...
1
vote
1answer
444 views

Apply portion of texture atlas

I'm trying to write a shader that only maps a portion of a large texture to my sprite and I'm getting a strange behaviour with my current code. This is what I have right now: Texture atlas ...
13
votes
2answers
1k views

Do I lose/gain performance for discarding pixels even if I don't use depth testing?

When I first searched for discard instruction, I've found experts saying using discard will result in performance drain. They said discarding pixels will break GPU's ability to use zBuffer properly ...
2
votes
1answer
235 views

Graphic hardware texture formats shaders relational speed

I'm interested to know, is there a direct correlation to the speed that a shader will run based on the bit depth of a texture upon which it is running. For example: If I have a 2 bit stencil texture ...