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

Why is a transformed Vector multiplied with the inverse transformation Matrix not the original Vector?

I my code I am currently working on, I have to transform a vector in my fragment shader to another coordinate space (simliar to the transformation between the cameras space and the lights space with shadow mapping), do some calculations in this…
nurgan
  • 309
  • 1
  • 4
  • 22
0
votes
0 answers

Position of lights in blinn light model

I have implemented Blinn-Phong shading in my fragment shader to calculate the lighting of each fragment with multiple lights. The computation seems to be all good except for one part. My directional light is computed correctly but my position light…
0
votes
2 answers

GLSL subroutine is not changed

I have begun learning GLSL and OpenGL. RIght now I am trying to see how GLSL subroutines work, so I have my fragment shader here: #version 330 core out vec4 color; subroutine vec4 ColorFunc(); subroutine (ColorFunc) vec4 colorBlue() { return…
ali
  • 10,927
  • 20
  • 89
  • 138
0
votes
0 answers

Opengl: Making texture background transparent by picking a color

I have a picture of a tree in OpenGL as a 2D texture. I want to remove the background (skyblue) or rather make that part transparent. How can I do this in the fragment shader. The closest I came up with is removing the pixels of the texture that are…
jaykumarark
  • 2,359
  • 6
  • 35
  • 53
0
votes
1 answer

Blend two images using GPU

I need to blend thousands of pairs of images very fast. My code currently does the following: _apply is a function pointer to a function like Blend. It is one of the many functions we can pass, but it is not the only one. Any function takes two…
cloudraven
  • 2,484
  • 1
  • 24
  • 49
0
votes
0 answers

Fragment shader does not behave the same between WebGL and Three.js => migration failure

I have a big issue by trying to "port" a fragment shader from WebGL into Three.JS. First, I managed to apply a concentric halo effect within a square by using a fragment shader across WebGL here : unitary test successfully managed by WebGL. To…
0
votes
1 answer

Drawing circular splats from vertex position

I want to draw circular splats, however my only data is the vertex position. So I draw the points in C++ and they appear at the right position. My point size is set to 20pixels, thus the points are big enough to discard some pixels to get a…
Aloys
  • 682
  • 4
  • 11
0
votes
1 answer

Can I call a shader with a different array for each call or should I make multiple shaders?

I'm trying to determine the best way to handle custom dashed lines using shaders in Three.js (webgl). There are different patterns these dashed lines could have. I hope I am able to write a single shader that could handle any kind of dash pattern.…
Ben Zuill-Smith
  • 3,504
  • 3
  • 25
  • 44
0
votes
2 answers

Shader transparancy not working with one half

glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); and used this in the fragment shader. I've used Alpha blend to get the transparency working however it only seems to work from one side. Not sure what the problem is, am new…
0
votes
2 answers

Create And Write GL_ALPHA texture (OpenGL ES 2)

I'm new to OpenGL so I'm not sure how to do this. Currently I'm doing this to create an Alpha Texture in iOS : GLuint framebuffer, renderBufferT; glGenFramebuffers(1, &framebuffer); glGenTextures(1, &renderBufferT); glBindFramebuffer(GL_FRAMEBUFFER,…
0
votes
1 answer

OpenGL texture1D

I'm trying to read from a fragment shader a texture1d: uniform sampler1D world; ... texelFetch(world, 0, 0); I upload w, where w[0]=123.0f w[1]=123.0f...: glActiveTexture(GL_TEXTURE0); glGenTextures(1, &pt->world); glBindTexture(GL_TEXTURE_1D,…
dv1729
  • 987
  • 1
  • 8
  • 25
0
votes
2 answers

OpenGL + Qt 4.8 is not drawing anything

I've been trying to use OpenGL in Qt with shaders and a simple vertex array. I basically want a plain to be drawn in the middle of the screen but nothing appears when I run the program. I'm basing my code in the "Texture" example of Qt, everything…
BlastDV
  • 112
  • 7
0
votes
4 answers

Fragment shader color interpolation: details and hardware support

I know using a very simple vertex shader like attribute vec3 aVertexPosition; attribute vec4 aVertexColor; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; varying vec4 vColor; void main(void) { gl_Position = uPMatrix * uMVMatrix *…
Farzad
  • 3,288
  • 2
  • 29
  • 53
0
votes
0 answers

Shadow with Phong's lighting model

I am looking for a description of how shadow should be represented in the Phong lighting model. You can take a look at Phong shading here: http://en.wikipedia.org/wiki/Phong_shading I think quite some people are, maybe unknowingly, familiar with…
skiwi
  • 66,971
  • 31
  • 131
  • 216
0
votes
0 answers

OpenGL Shaders - Structuring blocks of data of similar types

I'm having a bit of a structural problem with a shader of mine. Basically I want to be able to handle multiple lights of potentionally different types, but I'm unsure what the best way of implementing this would be. So far I've been using uniform…
Silverlan
  • 2,783
  • 3
  • 31
  • 66