Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [fragment-shader]

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

0
votes
0answers
13 views

Blinking color shader

Currently i'm using Unity3D, and i want to make one variable blink along time in a fragment shader. Now i have code like this: ...
0
votes
2answers
58 views

Shader vs Working with Pixels

I am working on 2d games only. In that context, when would I ever need to use a shader rather than simply manipulate the pixel-data of an image? For example, I have an image of a car and I want to ...
0
votes
0answers
33 views

Why does this work in the fragment shader but not in the vertex shader?

I'm doing some model view and projection transforms in the vertex shader and I want to determine whether the current vertex will end up on the viewport or not. After searching a bit I found that ...
1
vote
1answer
61 views

My Single Pass Gaussian Blur Looks Awful

I've based my shader on this single pass shadertoy here: https://www.shadertoy.com/view/XdfGDH I applied the same shader and it looks like this: Scaled up so you can see the faint tears in the ...
0
votes
1answer
46 views

Combining several passes in shader in Unity

I am very new to shaders but can't seem to find an answer to my problem. To put it simple I have created a flag shader, which can apply texture, animates and should also react to light. The problem ...
0
votes
1answer
23 views

Combination Lighting Shader?

I am currently working on writing a shader for combination lighting. The idea behind it is to apply directional light, point light, and spot light in a single pass. I believe I can do this by: ...
-1
votes
0answers
21 views

Fragment shader out of sync with vertex data

I'm writing a macOS game using Metal. I have a small visual glitch that causes me a lot of headache. The game has two kinds of game objects: The creatures, which move along the playfield (their ...
0
votes
1answer
27 views

HLSL Manual Alpha Blending

I'm trying to do alpha blending manually because I only want to apply alpha blending on certain pixels. Underlying is the texture I'm writing to. This is what I got so far, but it doesn't give the ...
1
vote
0answers
39 views

Artefacts in SSAO Shader

I am having trouble with my Screen Space Ambient Occlusion shader. The objects in the game have the correct occlusion applied to them, however the occlusion flips depending on the angle of the camera:...
-1
votes
0answers
58 views

Is the GPU's texture memory cache cleared when reading from multiple textures?

I have been reading lately about the memory layout of graphics cards and the issue with dependent texture reads. I am worried about the efficiency of the way I use framebuffer textures. Initially I ...
0
votes
0answers
117 views

Turn off linear filtering of texture in SpriteKit custom shader

I am using SpriteKit to draw some sprites on macOS. I create a texture as follows: ...
0
votes
0answers
40 views

ray intersection of surfaces created by swiping a curve (shader)

What I want is to swipe any curve into a plane, axis aligned. I made 2d intersection of the cross section then the 2d hieght extruded: - first I want to compute ex: the xz intersections - then using ...
0
votes
1answer
52 views

GLSL - Efficient Point inside Box Check

I'm attempting to improve the performance of a shader that changes the colour of a region of the world that is inside a "zone". I am using a deferred lighting system, so the colour and world-space ...
1
vote
1answer
42 views

How to implement multicolored flashing sprite effect like in Contra and the Messenger?

I want to implement an effect similar to what you see in this clip of Contra. When the boss takes damage, he flashes wildly with different colors. A similar effect can be seen in this clip from the ...
1
vote
1answer
87 views

Low fps on Arm Mali GPU

I was trying to google and understand my problem in two weeks but i am defeated, so i am asking for help. The main problem is that my custom unlit frag shader after certain amount of time on devices ...
0
votes
1answer
76 views

How can I write an additive mesh shader that splits the RGB channels while accounting for depth?

I'm trying to create a sort of "hologram" effect. So far, what I have is an additive, three-pass shader that uses ColorMask for each pass to separate the RGB channels. The problem is that doing so ...
1
vote
1answer
58 views

Does texture splatting always sample 4 x N textures per fragment (regardless of the weights)?

Texture splatting - usually - is done by vertex painting, where each channel R-G-B-A is assigned as a different texture weight. Due to the way shaders are executed, doesn't it mean that the fragment ...
1
vote
1answer
36 views

Wrap texels between desired values

I'm using a basic pixel shader here ...
0
votes
0answers
53 views

Unity shader pixelated on Android/ WebGL

I'm writing an image effect shader that should display an overlay texture on the screen using the following code in the fragment function: ...
1
vote
1answer
105 views

Does it make sense to do more calculations in the fragment shader if there are more vertices than pixels?

I'm very new to graphics programming, and as I understand it vertex shaders are called per vertex and fragment shaders are per pixel (ignoring anti-aliasing). When it comes to optimization all sources ...
0
votes
0answers
18 views

How to properly index countries for a pallette-swap in glsl?

I've been playing alot of EU4 (think: 3D historical Risk+ set in the 1400's-1800's) lately, and decided that it would be interesting to implement a map like the one in those games. To do this, I have ...
4
votes
1answer
203 views

Weird shader behavior on different devices

I'm trying to combine an ordinary shader with a Single Distance Field shader (for fonts and scalable icons) into one shader program. The idea is simple - if uv.x is less than 1.0, it is drawn as ...
2
votes
1answer
84 views

OpenGL Outlining Cubes in a Greedy Meshed Mesh

So I've managed to get myself a greedy meshing algorithm implemented for a little voxel game I'm developing to teach myself LWJGL/OpenGL, and it's going great. The thing is, I don't plan on using ...
1
vote
1answer
606 views

Surface Depth Intersection Shader

I recently asked a question about the creating an accurate Depth Intersection Shader. When creating this in a fragment / vertex shader it could be achieved by the following code ...
2
votes
1answer
1k views

Depth Intersection Shader

I am trying to create a shader in Unity that shows where intersections occur between objects. Most of the shader I have so far is based off of this youtube tutorial. However, I have made some slight ...
0
votes
1answer
101 views

How can I Fade Paint over time?

I want to fading my paint over time like this: but currently It's gray! what Is the problem? Code: ...
0
votes
0answers
35 views

Is there another to blur a cubemap other than changing mip level for PBR?

I am working on a physically based shader and have encountered a problem of high mip levels not properly blurring environmental maps. At first I've tried to linearly interpolate between two mip ...
1
vote
0answers
106 views

What's wrong with my normal mapping, and how can I fix it?

I'm trying to implement Normal Mapping in Directx and I'm very close to creating it but I'm getting these weird black colors on some objects. This is how it looks like without the Normal Mapping: And ...
2
votes
1answer
814 views

How can I create an outline shader for a plane?

All these toon shaders I have been seeing render an duplicated mesh behind it and extrude the normals of the vectors to make it look like it has a border, but it feels a bit hacky to me. Basically I ...
0
votes
1answer
96 views

How can you pass a large amount of textures or equivalent to the fragment shader in OpenGL?

I am adding shadow mapping to a game engine I am working on. For this effect, each light source needs it's own associated shadow map cube texture. I am going to be exaggerated and say there can be ...
0
votes
1answer
130 views

How to create a depth-recording shader for shadow mapping?

I am attempting to implement shadow maps. I am first going to implement spotlights over directional lights (I am aware this is harder). Since I was already rendering the geometry, my attempt was to ...
4
votes
0answers
92 views

Writing a leather shader

I'm trying to write a leather material shader. I have a normal map, bump map (grayscaled), specular map, diffuse map, cube maps. I have done the following ...
4
votes
0answers
92 views

Phantom objects in ray tracing

I am attempting to add volumetric shadowing to an application I am working on to test some things. For this effect I wrote the following fragment ...
0
votes
1answer
873 views

How can I fix my shadow caster problem?

I'm trying to make invisible object with shadow by using it's shadow castting pass it additionaly shades back side of object itself. I mean object shades his back side and draws shadow on the ...
0
votes
1answer
667 views

Change shadervalues for different Meshes in Three.js

Hey I am writing a Shader for Three.js. My goal is to have multiple objects with the same shader and each object should have a color set on the object that is then given to the shader. The goal is to ...
3
votes
2answers
326 views

How to run Shader after Build without problems?

I always have problems with shaders, while my partners avoid using custom shaders because it always causes problems. When I write shaders I have to test it in many devices and optimize every time. In ...
0
votes
1answer
295 views

how can I make delay in shader?

my effect is loop but I need have delay between each flash effect.i don't want use c# code because i believe there is easy way to implement delay in shader. ...
6
votes
1answer
321 views

Animating compression wave shader which uses image for displacement map

I've been testing a variety of shockwave or ripple effect shaders, and spent time on this cleaned up and improved version on shadertoy. I'm not entirely satisfied with that because it produces an ...
2
votes
2answers
371 views

Spherical fragment shader shockwave regardless of screen dimensions

I've been working on a shockwave shader based on some examples I've looked at. My primary issue is that the screen/resolution dictates the shape of the shockwave. I need it to be spherical, but with ...
-2
votes
1answer
519 views

Shader FloodFill Alogrithm

I'm new to openGL and shaders. Is there a way to implement shader algorithms for floodfills? Basically, I have a picture with outlines and i want to fill the insides of where the user touches it
1
vote
0answers
82 views

Draw line around mesh with defined width at cut plane

I want to display a solid line around mesh with a defined width at a cut plane. Currently I realized that using the same method as gl_ClipDistance works using ...
5
votes
2answers
2k views

Algorithm for a rain effect (Shaders)

I'm trying to implement a rain effect using shader, I use godot 3-alpha, which uses a simplified GLSL 3.0 language. But I'm just finding very complex examples for me, I understand little about shaders,...
3
votes
2answers
320 views

DirectX11 - Color Interpolation Along Quad Diagonal

Imagine that we have a vertex structure that looks like this: struct Vertex { XMFLOAT3 position; XMFLOAT4 color; }; The vertex shader looks like this: <...
1
vote
1answer
580 views

Has anyone ever made a shader that produces something similar to pixel art?

I find that pixel art is really pleasing to look at; it has this kind of crisp, satisfying perfection to it. I've been following some beginner pixel art tutorials, when I got an idea: what if someone ...
1
vote
0answers
287 views

Passing an UAV to a Pixel Shader in DirectX11

I have a compute shader which task is to take an input image and then blur it using a Gaussian filter approach. The input and output for the compute shader looks like this: ...
2
votes
1answer
62 views

Fading previous frame doesn't fade all the way to black?

I'm working on a 2D OpenGL program. It'll be a fairly simple fireworks visual. So far what I have is that I draw a circle with a gradient "glow" to it and move it around on the screen. I want it to ...
0
votes
1answer
155 views

Sprite masking with multiple, non-equally dimensioned textures in XNA

I know this question's been asked many times before, but I can't seem to get sprite masking to work in XNA/Monogame no matter if I try the stencil method, or the shader method. Considering I'm having ...
1
vote
0answers
33 views

Can sampling an input texture in shader return values updated in same pass?

In my hlsl, (I am using Direct2D helpers which I guess just call tex2D), can D2DSampleInputAtOffset() return a pixel value that was only updated in that same pass ...
1
vote
4answers
680 views

Output pixel to different position from pixel shader?

Is it possible to output a pixel processed by my pixel shader to a different position? For example if SV_POSITION of the pixel is 14,26, can I change it to 14,27? I see there are only two possible ...
3
votes
1answer
118 views

GLSL ES 2.0 alternative for dFdxFine

I'm trying to generate normal map on the fly in fragment shader. The implementation I've found is using dFdxFine function, which can't be used in WebGL, is there any alternative for dFdxFine in GLSL ...