Questions tagged [fragment-shader]

A GPU program used in rendering. It is executed for each sample taken from a rasterized primitive. The output of this process is a number of values and a floating-point depth.

Resources

1506 questions
18
votes
1 answer

Fragment shader and coloring a texture

I'm trying to make sense of adjusting texture colors with a fragment shader. My fragment shader is super simple: uniform sampler2D sampler; void main() { vec4 tex = texture2D ( sampler, uvVarying ); gl_FragColor = vec4(tex.r, tex.g, tex.b,…
vertti
  • 7,539
  • 4
  • 51
  • 81
18
votes
2 answers

GLSL pow function?

I have this: float xExponential = pow(xPingPong, 5); And is not working, claiming: ERROR: 0:53: No matching overload for call to function 'pow' Am I doin' something wrong? Developing for iOS with OpenGL ES 2.0.
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
17
votes
1 answer

What does iResolution mean in a shader?

I am new to GLSL. I find there is a variable iResolution in every demo https://www.shadertoy.com/new. What does it mean? If I want to pass this variable to the shader, what do I need do?
Jackie
  • 385
  • 1
  • 3
  • 10
17
votes
3 answers

Are 1D Textures Supported in WebGL yet?

I've been trying to find a clear answer, but it seems no one has clearly asked the question. Can I use a 1D sampler and 1D texture in WebGL Chrome, Firefox, Safari, IE, etc? EDIT Understandably 1 is indeed a power of 2 (2^0=1) meaning you could…
Adrian Seeley
  • 2,262
  • 2
  • 29
  • 37
15
votes
3 answers

Shadertoy - fragCoord vs iResolution vs fragColor

I'm fairly new to Shadertoy and GLSL in general. I have successfully duplicated numerous Shadertoy shaders into Blender without actually knowing how it all works. I have looked for tutorials but I'm more of a visual learner. If someone could…
Podis
  • 379
  • 2
  • 17
15
votes
1 answer

Gaussian Blur - standard deviation, radius and kernel size

I've implemented a gaussian blur fragment shader in GLSL. I understand the main concepts behind all of it: convolution, separation of x and y using linearity, multiple passes to increase radius... I still have a few questions though: What's the…
LodeRunner
  • 7,975
  • 3
  • 22
  • 24
15
votes
8 answers

Efficient Bicubic filtering code in GLSL?

I'm wondering if anyone has complete, working, and efficient code to do bicubic texture filtering in glsl. There is…
Vern Jensen
  • 3,449
  • 6
  • 42
  • 59
15
votes
4 answers

How to calculate gl_FragCoord in glsl

Ok, in my GLSL fragment shader I want to be able to calculate the distance of the fragment from a particular line in space. The result of this is that I am first trying to use a varying vec2 set in my vertex shader to mirror what ends up in…
DaedalusFall
  • 8,335
  • 6
  • 30
  • 43
14
votes
2 answers

Creating a Gradient Color in Fragment Shader

I'm trying to achieve making a gradient color as the design apps (Photoshop for example) does, but can't get the exact result i want. My shader creates very nice 'gradients' but also contains other colors that are different from the colors I want to…
Bahadır
  • 269
  • 2
  • 3
  • 12
14
votes
2 answers

Artifacts from linear filtering a floating point texture in the fragment shader

I'm using the following code taken from this tutorial to perform linear filtering on a floating point texture in my fragment shader in WebGL: float fHeight = 512.0; float fWidth = 1024.0; float texelSizeX = 1.0/fWidth; float texelSizeY =…
Mad Scientist
  • 18,090
  • 12
  • 83
  • 109
14
votes
1 answer

Draw Quadratic Curve on GPU

My task is to render quadratic Bezier curve (path) via Stage3d (Adobe Flash) technology, which have no any extensions for that drawing out-of-the box (while OpenGl have it, as I know). Yea, there is a Starling-Extension-Graphics, but it uses simple…
Ilya
  • 181
  • 1
  • 7
14
votes
4 answers

OpenGL Blend Modes vs Shader Blending

I'm currently doing some research on OpenGL and Shaders but I can't seem to figure out if there are any fundamental differences between blending using the glBlendMode or writing your own blend modes in a shader. What are the reasons to choose the…
polyclick
  • 2,704
  • 4
  • 32
  • 58
13
votes
1 answer

Finding the pixel color in a specific coordinate from a sampler2D using GLSL

I have a 3D object in my scene and the fragment shader for this object receives a texture that has the same size of the screen. I want to get the coordinates from the current fragment and find the color information on the image in the same position.…
Luke B.
  • 1,258
  • 1
  • 17
  • 28
13
votes
3 answers

OpenGL Shading Language Different Types of Variable (Qualifiers)

I've been writing programs using OpenGL. Recently, I started learning OpenGL Shading Language. I'm a newbie; so please be detailed in your answers. My questions are: What are different types of variable (qualifiers) in GLSL? What are they used…
Einiosaurus
  • 191
  • 2
  • 12
13
votes
1 answer

Blend two textures with different coordinates and sizes in the same shader

I have two textures with different coordinates and sizes in my fragment shader: varying highp vec2 v_currentTextureCoords; varying highp vec2 v_backgroundTextureCoords; uniform sampler2D u_currentTexture; uniform sampler2D u_backgroundTexture; void…
GuiTeK
  • 1,561
  • 5
  • 20
  • 39