1
vote
1answer
26 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
75 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
97 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
122 views

GLSL blur shader algorithm results in a lumpy blur?

I'm writing a Gaussian blur shader and it's coming along pretty well. However, when I run it on a circle, the result is lumpy. I'm using a simple nested for loop to create the blur. Here's the code ...
0
votes
0answers
30 views

Strauss model : no specular component [duplicate]

I implemented the Strauss model with the metalness, transparency and smoothness parameters, taking the formulas from the book "Programming vertex geometry and pixel shaders", this is how I implemented ...
1
vote
2answers
159 views

Ward model implementation: specular component too weak

I'm trying to implement the Ward shading model, the anisotropic, computationally efficient version: This is how I made it: float alphaX=0.5, alphaY=0.5; // asinotropic roughness float ...
0
votes
0answers
56 views

How can I compute spotlight attenuation when I only have a spotlight cutoff angle?

I am trying to compute the spot light attenuation, though I don't have a spotCosCutoff (cosine of the spotlight cutoff angle) predefined variable in the shader so I have to compute it myself. This is ...
2
votes
0answers
187 views

Ashikhmin-Shirley model implementation: ugly result

I am trying to implement the Ashikhmin-Shirley model using these formulas: This is the GLSL 1.2 fragment shader code: uniform vec4 materialAmbient, materialDiffuse, materialSpecular; uniform ...
3
votes
4answers
424 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
167 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 ...
7
votes
2answers
3k 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 ...
0
votes
1answer
70 views

Vertex and Fragment Shader worldNormal

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

Better solution for boolean mixing?

Sorry if this question has been asked in the past, but searching Google and here didn't yield relevant results, so here goes. I'm working on a fragment shader that implements both conditional/boolean ...
1
vote
1answer
776 views

Volumetric Fog Shader - Camera Issue

I am trying to build an infinite fog shader. This fog is applied on a 3D plane. For the moment I have a Z-Depth Fog. And I encounter some issues. As you can see in the screenshot, there are two views. ...
2
votes
1answer
185 views

What is the interval of fragment-shader code execution?

Without any intended delay, is the code of a fragment-shader run once per frame? If not, how often will the code be executed? (I'm new to shaders: I'm talking about glsl if it makes any difference)
7
votes
1answer
793 views

Optimizing performance of a heavy fragment shader

I need help optimizing the following set of shaders: Vertex: precision mediump float; uniform vec2 rubyTextureSize; attribute vec4 vPosition; attribute vec2 a_TexCoordinate; varying vec2 tc; ...
0
votes
1answer
111 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
127 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 ...
11
votes
1answer
879 views

Toon/cel shading with variable line width?

I see a few broad approaches out there to doing cel shading: Duplication & enlargement of model with flipped normals (not an option for me) Sobel filter / fragment shader approaches to edge ...
4
votes
3answers
156 views

How to read BC4 texture in GLSL?

I'm supposed to receive a texture in BC4 format. In OpenGL, i guess this format is called GL_COMPRESSED_RED_RGTC1. The texture is not really a "texture", more like a data to handle at fragment ...
1
vote
3answers
592 views

GLSL mesh discard command?

Is there a GLSL command similar to the discard, but it discards the whole mesh and not just a fragment?
2
votes
0answers
2k views

How to implement fisheye effect with a GLSL fragment shader [duplicate]

I would like to render my scene with a wide FOV and then apply a fisheye distortion via fragment shader. How would this shader best be implemented? Update I try to reproduce a fisheye effect similar ...
7
votes
1answer
9k 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): ...
1
vote
3answers
930 views

iOS - pass UIImage to shader as texture

I am trying to pass UIImage to GLSL shader. The fragment shader is: varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; void main() { ...