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
0answers
16 views

GLSL `vec4` as return type syntax error? [on hold]

Here is my GLSL fragment shader code: #version 430 in vec3 fragPosition; in vec4 fragColor; in vec3 fragNormal; uniform int num_lights; layout(std430) buffer light { //... } vec4 lambert() { ...
0
votes
2answers
49 views

How can I use an HLSL pixel shader to peek at other pixels?

I think this is like a pixilation shader but I had a hard time trying to find one online, and one that I could manipulate specifically. I want to create a pixel shader for my monogame project that ...
0
votes
1answer
41 views

GLSL - Only draw arond point / flashlight effect

I'm currently trying to achieve a sort of flashlight effect in GLSL. I only want to draw textures within a certain distance of a specified point (the mouse position, for example). Here's a quick ...
0
votes
0answers
20 views

How to apply individual colours in a fragment shader?

I'm trying to write my own shader. Within the target mesh I have assigned the following attributes in a script: mesh.vertices = points; mesh.colors = colours; //Each element of the array hold a ...
0
votes
0answers
19 views

Fragment Shader Light Sim

In the game Clash Royale, when you have the ability to upgrade a card, the green part has a light sheen to it an this sheen animates from left to right. How can this be done with a shader? I'm quite ...
0
votes
1answer
28 views

Choosing between multiple shaders based on uniform variable

I want to choose from 2 fragment shaders based on the value of an uniform variable. I want to know how to do that. I have onSurfaceCreated function which does compile and link to create program1 and ...
0
votes
1answer
50 views

Luminance 'y' value of surface texture

For my opengl video player app, I am using surface texture bound to GL_TEXTURE_EXTERNAL_OES source : ...
0
votes
0answers
30 views

Convolution of luminance values in shader

For my fragment shader, I need to take the convolution of luminance values of a square block of pixels. I tried with 3x3 block and took luminance and convolution. But it ended up in huge performance ...
3
votes
0answers
143 views

Schlick Fresnel Shader

I hope you are all doing ok. I have an issue with my Fresnel shader that doesn't allow the Fresnel to change as my camera moves around. I'm not sure what i'm doing wrong. I'm using glsl with the ...
0
votes
0answers
69 views

vert/frag custom shader - Shadow is not correct, showing strange artifacts

I am new to shader writing, I want to drop shadows in my own shader, but unluckily I am getting a strange behaviour. When I apply a simple surface shader (Lambert, written in unity shader lab) it ...
0
votes
2answers
106 views

How do I draw individual pixels in the distance?

Hello everyone I am working with unity3d and I am faced with a task. I have a list of 3D points and I want to draw a pixel for every point on the list that exists after my cameras frustums far-plane. ...
3
votes
1answer
63 views

Super formula on shader

I'm using Shader-toy to experiment and try to learn a bit the shader science. As exercise I wan to replicate some of the wikipedia math plots. I've started with a Super Formula. What I want to ...
0
votes
1answer
77 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
1answer
21 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
32 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
57 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
157 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
96 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
127 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
26 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
580 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
268 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
46 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
64 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
260 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
144 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
208 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
290 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
247 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
145 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
165 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
89 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, ...
3
votes
0answers
136 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
189 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
117 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
216 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
276 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
1answer
92 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
63 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
71 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, ...
1
vote
1answer
344 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
1k 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
655 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 ...
1
vote
1answer
287 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
213 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
86 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
610 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
62 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
90 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 ...