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
0
votes
1 answer

Smooth gradient in fragment shader

I am looking for some way how to get smooth gradient with fragment shader. I have palette with 11 colors and value which used to define color (it lays in range from 0.0 to 1.0). I am trying to get smooth color translation with such fragment…
frankie
  • 728
  • 1
  • 10
  • 28
0
votes
1 answer

Writing a Atom editor plugin, animated syntax coloring

I am in for a little experiment, I just need someone to guide me.. I want to make my own custom syntax coloring (for Javascript), and that needs to be animated. Big plus would be (if it is possible) is posibility of using shader-language for fonts…
0
votes
3 answers

How to determine if point lies inside shape?

I need to determine if point lies inside shape. In case our shape is circle it's easy: highp vec2 textureCoordinateToUse = vec2(textureCoordinate.x, (textureCoordinate.y * aspectRatio + 0.5 - 0.5 * aspectRatio)); highp float dist = distance(center,…
Timur Bernikovich
  • 5,660
  • 4
  • 45
  • 58
0
votes
1 answer

OpenGL texture precision / texcoord vs. attribute

I'm drawing a simple textured quad (2 triangles) using a one dimensional texture that hold 512 values ranging from 0 to 1. I'm using RGBA_32F on a NVIDIA GeForce GT 750M, GL_LINEAR interpolation and GL_CLAMP_TO_EDGE. I draw the quad using the…
Nicolas Rougier
  • 670
  • 7
  • 15
0
votes
1 answer

Add radial gradient texture to each white part of another texture in shader

Recently, I have read article about sun shader (XNA Sun Shader) and decided to implement it using OpenGL ES 2.0. But I faced with a problem connected with shader: I have two textures, one of them is fire gradient texture: And another one is texture…
Nolesh
  • 6,848
  • 12
  • 75
  • 112
0
votes
0 answers

What is wrong in this fragment shader?

I am writing a simple OpenGL app, that applies a 2D texture to a triangle strip. My fragment shader does not compile (I am using PyOpenGL): FRAGMENT_SHADER = shaders.compileShader("""#version 130 in vec4 color_v; layout(location = 0) out…
Raoul
  • 1,872
  • 3
  • 26
  • 48
0
votes
1 answer

GLSL: How to lower 2D light center density?

I found a shader on the Internet which creates 2D lights. What I'm curious about is that "How can I make the centre of the light less dense to be able to see other objects while still illuminating them?" Here is the shader: uniform vec2…
Sierox
  • 459
  • 3
  • 18
0
votes
0 answers

Chroma Keying Shader

I want to apply chroma keying shader for my application. For this I used GPUImage plugin. In that I found GPUImageChromaKeyingBlendFilter class to satisfy my needs. In plugin, GPUImageChromaKeyingBlendFilter class contains wrong program for chroma…
Siddharth
  • 4,142
  • 9
  • 44
  • 90
0
votes
1 answer

OpenGL Diffuse Lighting Shader Bug?

The Orange book, section 16.2, lists implementing diffuse lighting as: void main() { vec3 N = normalize(gl_NormalMatrix * gl_Normal); vec4 V = gl_ModelViewMatrix * gl_vertex; vec3 L = normalize(lightPos - V.xyz); gl_FrontColor = gl_Color *…
anon
  • 41,035
  • 53
  • 197
  • 293
0
votes
1 answer

Compatibility issues on GLSL fragment shaders

I have found a few times differences between GPUs handling fragment shaders. One example was doing pow(x) where x is negative. One GPU handled it well while the other one failed. Another situation was where I rewrote if() statements with step()…
lukas.pukenis
  • 13,057
  • 12
  • 47
  • 81
0
votes
1 answer

OpenGL finding `in vec3 vert` but not `in float val` in vertex shader

I have some code that draws squares by passing points through a geometry shader. I construct an array which is sequences of 3 floats, bind that to the in vec3 vert attribute of my vertex shader, and everything is fine. However, I want to add another…
vgel
  • 3,225
  • 1
  • 21
  • 35
0
votes
2 answers

Segfault on glProgramUniform1i

I'm trying to get screenWidth and screenHeight into my fragment shader through uniform variables. Here's my main.cpp where the offender lies, I can get the location (non -1) but when it actually sets the uniform variable thingy I segfault. #include…
0
votes
1 answer

How to properly implement Cook-Torrance shading in three.js?

I'm trying to implement the Cook-Torrance shading algorithm in three.js I have a mostly working solution, however it doesn't show the effects of the ambient light. The sides of the cube not illuminated by the light are completely black. If I remove…
Bakuriu
  • 98,325
  • 22
  • 197
  • 231
0
votes
1 answer

Diffuse lighting error on parallel surfaces

As a test, I created a simple quad. Here are its attributes: Vertex vertices[] = { // Positions Normals {vec3(-1,-1, 0), vec3(-1,-1, 1)}, // v0 {vec3( 1,-1, 0), vec3( 1,-1, 1)}, // v1 {vec3(-1, 1, 0), vec3(-1, 1, 1)}, //…
mchiasson
  • 2,452
  • 25
  • 27
0
votes
2 answers

WebGL - Example of WHERE to set attributes/uniforms

I have seen several examples/tutorials of WebGL where the gl.getAttributeLocation() or gl.getUniformLocation() and the like are called. However, these are all in a demo/tutorial scenario. The issue/concern is this: The gl.getAttributeLocation, for…
AlvinfromDiaspar
  • 6,611
  • 13
  • 75
  • 140