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

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

1
vote
0answers
29 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:...
0
votes
0answers
49 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
111 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
43 views

Unity Shaderlab: Pixel Perfect Distortion Shader that uses screen position?

So I am trying to make a distortion effect vertex-fragment shader! I am pretty new to shaders in general, and I am having some trouble with it. The effect is: from a distortion texture, I get a ...
0
votes
0answers
26 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
46 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
41 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
65 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
68 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
42 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
34 views

Wrap texels between desired values

I'm using a basic pixel shader here ...
0
votes
0answers
37 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
92 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
14 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
179 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
58 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
361 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
845 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
96 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
26 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
96 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
654 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
93 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
129 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
89 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
90 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
685 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
527 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
297 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
246 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
296 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
289 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
428 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
62 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
278 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: <...
0
votes
1answer
455 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
253 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
52 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
139 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
604 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
101 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 ...
1
vote
1answer
68 views

GLSL Fragment Shader compiles fine on certain computers [closed]

I got this piece of code in a fragment shader: if (color.a < 0.01f) discard; It runs fine on an older graphic card but can't even compile on my newer (...
2
votes
0answers
117 views

What am I doing wrong, in regards to multi-texture?

I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader. This is the texture part of my OpenGL code: ...
1
vote
0answers
279 views

How do I set the UV coordinate from a texture value in HLSL?

I have a UV render pass, where RG is the image and B is always set to 255: I want to set the UV pass texture value to UV Coordinate; when I test it, the result should pixelate noise, like the below ...
1
vote
1answer
103 views

Does GLSL support multitexturing?

I am using LWJGL libraries to code myself a game. I want to be able to import a project from blender to my game. I have the wavefront .obj reader and it works perfectly for my needs. Although because ...
1
vote
0answers
148 views

Cocos2d-x: Differences between applying shader to child node and entire scene?

I'm beginning with shader. I wonder what if i apply shader for single node, what'll happen? The gl_FragCoord = (0.5,0.5) is the bottom left of the screen or the ...
0
votes
1answer
61 views

Fragment Shader Code returns weird values

i've implemented a shader that produces a simple Radar Ping given a uniform time input. ShaderToy Proof of concept Now i implemented this into my real Opengl GLFW GLAD C++ Core4.5Profile NVIDIA ...
1
vote
0answers
42 views

Trouble rendering shadowmap for planets

Im currently trying to create a game where you visit planets in LibGDX for Java. To do this I use a TiledMap which is basically just an array of tiles to represent the planets themselves. To get the ...