A program that runs on the GPU to determine output colors for pixels. Also known as a fragment shader.

learn more… | top users | synonyms (1)

0
votes
1answer
43 views

Fragment shader, tint color problem

I am new to shaders, and I am trying to tint a texture to mark status of a enemy. I am implementing shaders on OpenGL ES 2.0 (Mobile) The problem is that with this shaders, I see the enemy without ...
0
votes
0answers
6 views

FXAA Parameter Confusion

I have a question about the popular FXAA shaders that are out there written using HLSL or GLSL, and they all mainly feature these three parameters: #define FXAA_REDUCE_MIN (1.0 / 128.0) //0.0078125 ...
-1
votes
0answers
31 views

Create overlapping transparent images [duplicate]

I want to achieve this effect in the image. To make this I don't think a single pass to a stencil buffer would be enough because stencil buffers can't mask out the actual alpha inside of the ...
0
votes
0answers
24 views

Shader - Directional Lights Depth

Is there a way to retrieve the deph from directional lights ? I can access the _ShadowMapTexture but this is not the depth. I found how to access the shadow map of, I think, every light type by using ...
3
votes
1answer
31 views

Libgdx - GLSL shader which uses mod doesn't seem to work properly on android

Through trial and error I've managed to come up with a scanline-ish shader I'm satisfied with. On my desktop testbed it looks like this: Basically, every 2nd(vertical) pixel is darkened. However, ...
3
votes
0answers
97 views

Unity - reconstruct position from depth

I am using Unity and I want to reconstruct position from depth and frustum corners in pixel shader. I am doing this: In my App, I calculate view-space corners of the far frustum plane and pass them ...
3
votes
1answer
76 views

Getting rid of texture bleeding

Edit: I figured out what problem I was facing, it's called Texture/Pixel bleeding, which I was not aware of yet. I posted an answer below consisting of a small description of the problem and a link to ...
1
vote
3answers
118 views

Is there a way to get what pixel is being processed within the fragment shader?

In OpenGL, a fragment shader goes through each pixel, right? So is it possible (within the shader itself) to get what pixel it is processing and color each specific pixel?
1
vote
1answer
23 views

Is it necessary to use texture filtering if I use texture coordinate system?

I have one question about using texture filtering. It's clear when I used normalized texuture coordinates (in any API) for example from (0,0) to (1,1) it is necessary to use texture filtering because ...
12
votes
3answers
448 views

How do I write a shader that lights up when objects are near a surface?

In this Overwatch gameplay video, the character's shield lights up white in areas that are near other objects' geometry. Note the white edges on the blue shield, near the floor, walls and pillar. ...
1
vote
1answer
103 views

Pixelation shader explanation?

I was looking for a pixelation shader for my postprocessing and came across this shader snippet - Works pretty well! - Not a whole lot of explanations on how it works except for "Pixelation is process ...
0
votes
0answers
28 views

How to use shader in order to render FBO lwjgl

I am making a 2D game and I want to make a light mask. So far i made a Frame Buffer where i hold my mask but I cannot apply the shader on it. When I don't use the shader the light map is drawn ...
0
votes
0answers
44 views

Offscreen frame buffer lwjgl

I want to create simple 2d lighting. So my idea is to render everything on the default buffer and then apply light mask. For the light mask i want to use frame buffer which later i will apply on the ...
0
votes
1answer
157 views

Shadertoy getting help moving to glsl

I spent some time writing a shader on shadertoy but now, when I try to translate my code to opengl I don't know how to calculate the uv that they describe as like this: vec2 uv = fragCoord.xy / ...
3
votes
1answer
105 views

Underwater Shader Animation Help

I found an underwater (distort) effect and I got it to work but somehow I cannot make it animate given the offset here: Fragment Shader code: uniform sampler2D fbo_texture; uniform float offset; ...
0
votes
2answers
130 views

How to wrap textures inside shader GLSL

I'm trying out GLSL and one of the problems I'm facing is wrapping a random texture sampler in the shader. Searching for answers on the web first, this leads me to using these commands: ...
1
vote
3answers
184 views

OpenGL, GLSL, Modify Background Fill via Fragment Shader

I have noticed that fragments rendered by the glClearColor() method do not pass through shaders. However, I'd like to modify these fragments using my fragment shader. Is there any way of forcing them ...
2
votes
1answer
144 views

equirectangular panorama rendering?

I want to render my scenes as equirectangular panorama frames. I can get the angular fisheye which is what I actually need by applying the rendered frame as a texture to a correctly UV mapped circle. ...
1
vote
1answer
129 views

How to pass a big (60+) amount of variables to an HLSL pixel shader?

I am in trouble at trying to pass a big amount of variables needed for my pixel shader computations. After trying and failing to link my struct to a cbuffer (data alignement mismatch) I tried passing ...
2
votes
1answer
102 views

Stencil buffer VS conditional discard in fragment shader

I have a continuous height-mapped mesh to represent landscape. I also have 1 to let's say 10 wells on this landscape represented by additional models. What I want to achieve is to create an illusion ...
3
votes
0answers
87 views

Raymarching tangents

I've recently started to experiment with raymarching over on shadertoy.com. It seems common to find the normal for a distance field like so: vec3 scene_normal(vec3 p) { vec3 e = vec3(0.001, 0.0, ...
2
votes
0answers
88 views

How do I sample a cubic shadow map in DirectX 11?

I've implemented a cubic shadow map for dealing with omni-directional light sources in my scene. By defualt it produces hard shadows Obviously a shadow map with higher resolution (currently using ...
0
votes
1answer
150 views

Unity: cg fragment shader processing array of points

I need to write a fragment shader which would somehow be aware of N points that are in the scene and darken pixels based on their world coord distance to the points. I'm looking for a method that ...
1
vote
0answers
89 views

Issues with 2D raycasting lighting under limitations of HLSL 3.0 pixel shader

I've been writing my own HLSL pixel shader for dynamic lighting using raycasting. Unfortunately, since I'm using this out of XNA, I can only use up to ps_3_0. As you can see, the limitations ...
4
votes
2answers
181 views

Best way of writing pixel manipuliting-intensive applications with OpenGL/Direct3D

Recently I have been making little experiments with engines similar to old Wolfenstein 3D, Doom and Build, engines where the 3D rendering is entirely done in software and therefore you need full ...
3
votes
1answer
221 views

2D day night mapping

I'm looking for this kind of effect MINUS the lights and snow (Another problem). It needs to change depending on the time of year. Doesn't need snow or city lights. Now I'm pretty new to shaders ...
0
votes
0answers
25 views

In HLSL pixel shader, why am I getting [-256.0, 256.0] values in SV_POSITION input?

My question is basically in my DirectX11 pixel shader, why am I getting a range of values from -256.0 to 256.0 in the SV_POSITION input instead of the supposed values from 0.0 to ViewportWidth and 0.0 ...
0
votes
1answer
84 views

how change branching logic to math equivalent glsl? [closed]

im totally newbie and this just for fun afaik lot of best practice suggest to minimize usage of branching. can you help me optimize below glsl especially on branch part? ( target 120 ) the bgcolor ...
0
votes
1answer
60 views

Sample() returns (0, 0, 0) for normal map 90% of frames

I'm having some trouble reading the values from my Normal map in my lighting fragment shader. The relevant part of the shader code is as follows: Texture2D NormalGB : register(t0); Texture2D ...
0
votes
0answers
64 views

How to sample png heightmap in HLSL

I am working on simple parallax shader and I have problem with sampling height texture for value. My aproach amples texture and give me RGB values of picture: tex2D(TextureHeightSampler, ...
0
votes
0answers
82 views

Shader to mask image with polygon

I'm new to graphics programming and GLSL in particular. I'm working on a 2D game and the setup is as follows: There is an image on the screen (a sprite in the game engine [Cocos2d-x if it matters]) ...
1
vote
1answer
267 views

Tile Map Shader?

I'm trying to write a shader in unity that will take tiles from a sprite sheet and draw them onto a tile map. I'm new to shaders so this might be totally wrong, I think it might just be a math error ...
3
votes
1answer
855 views

How to generate a RGB * a texture for a glow effect in GLSL?

I would like to create a glow effect in GLSL, there is a tutorial that explains how we multiply RGB * a : I have some questions : is it an operation that is in a fragment shader, where RGBa is ...
0
votes
1answer
479 views

How to use a buffer in GLSL to do a LUT-lookup?

I am currently on a medical application which needs different kinds (up to totally individual) lookup tables (LUT) for image display. And this done with 10bit finish. So it is most of the time ...
0
votes
0answers
97 views

DirectX My texture does work in my pixelshader

I got a bit of a mystery as I have a problem that should not be a problem. I am working on a fog feature which is similar to other things that I have done. Not very hard at all. The only real ...
1
vote
1answer
213 views

Calling Shader Functions Inside Other Shaders

I'm new to OpenGL and GLSL, and bit confused about calling conventions of shader functions. I'm trying to implement various procedural noise algorithms in GLSL. I'd like to have separate files for ...
0
votes
0answers
165 views

opengl shaders getting started problem

I'm following this tutorial for shading in opengl. However I wanted to start with another shader to make things more interesting So this gives me the following code: // Include standard headers ...
0
votes
1answer
78 views

How to combine VAO and shader language?

I'm new and trying to draw a very simple quad with VAO and GLSL. My definitions: typedef struct SPos { float x; float y; } SPos; SPos mVertices[6]; SPos mIndicies[6]; GLuint mVao; GLuint ...
1
vote
2answers
408 views

How to prevent intepolated texture in fragment shader (Unity CG)

Think about minecraft - all the textures in minecraft have a very nice crisp pixelated look. Well, I'm trying to write a shader that will do this but it appears "sampler2d" returns some sort of ...
0
votes
0answers
57 views

Trying to get the fragment shader to output a list

I am trying to figure out a way to get the Fragment Shader to output a list of gl_VertexID-s. I want to use the GPU to get a list of vertices in the viewing frustum. Is there any way I can get a ...
0
votes
0answers
78 views

OpenGL not rendering to correct target

I have a fbo, with 8 textures in it (g-buffer). What I'm trying to do, is to render all information from opaque objects to first four(color, normal, position, depth), and info from transparent objects ...
0
votes
1answer
236 views

Fragment Shader output type error

StackExchange! I've been working with opengl for a bit and I'm trying to finally load the shaders instead of having them inline. I'm having a ton of issues, though. As soon as I solve one, another ...
1
vote
1answer
77 views

Is it possible to look up a texel from a texture in GLES2 GLSL framgent shader without using sampler?

Is there some way I can directly access texture memory from fragment shader in GLES2 GLSL? I don't need the sampler to be involved since I am just using it as a look-up table.
3
votes
1answer
245 views

Shadow mapping. I don't understand what to do after creating the depth texture

I'm taking an intro to computer graphics course, so this is something we haven't touched on. I am reading this tutorial ...
5
votes
2answers
2k views

How to implement color changing fragment shader?

I have a background of a given size and filled with a given color. I want to change it with an animation effect, starting from the center and spread out until it extends the whole background. The new ...
0
votes
1answer
420 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
1answer
265 views

2D RGBA texture is gray in GLSL shader

I have a shader to perform LUT coloring of a texture and a c++/c# programs that call it which work perfectly when i use a 1D texture. Since i need to support computers that don't support the 1D ...
19
votes
3answers
3k views

Why is H (blinn) used instead of R (phong) in specular shading?

I can't find a good reason for this anywhere. The reflection vector used in phong has a simple basis in physics. But the half vector used in blinn seemingly has no rational basis, and does not ...
0
votes
2answers
136 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
359 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 ...