Questions tagged [fragment-shader]
A program that runs on the GPU to determine output colors for pixels. Also known as a fragment shader.
305
questions
0
votes
1
answer
36
views
filter camera output by mesh
(skip to edit for the actual problem)
I have a simple plane mesh generated via script (has arbitrary shape).
I want the shader to discard (set to black) all pixels that aren't passing through that ...
5
votes
1
answer
2k
views
Creating Blender-like cavity shader
I'm trying to achieve in Godot something similar to cavity effect from Blender (this can be enabled in viewport options; cube on the left is displayed by viewport with this option enabled):
How would ...
6
votes
1
answer
605
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 ...
1
vote
2
answers
287
views
How to colour blend between two materials? [closed]
I've been trying to get a material (with an image texture) to animate towards a colour mix with transparency, but either I'm attempting something the wrong way, or unable to find the right keyword to ...
1
vote
2
answers
111
views
How can I make alternate fragments drop (or make them black) based on a checkerboard texture?
How can I make alternate fragments drop(or make them black) based on a checkerboard texture in a Unity fragment shader?
I am using forward path rendering in my shader passes for lighting and shadows ...
5
votes
2
answers
530
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 ...
0
votes
1
answer
331
views
How to implement dither in pixel shader?
I've seen this talk about INSIDE's rendering (thanks to DMGregory).
It says that we should dither everything.
What I wonder however is how to dither in a simple fragment shader?
In a Pixel Shader I ...
2
votes
1
answer
162
views
Rendering colors from a texcoord output
I'm trying to implement a faster alternative to super-sampling for my isometric 2d monogame game (for when the view is zoomed out). The idea was that I would render the texture coordinates to the ...
0
votes
1
answer
142
views
GLSL Shade a box different colors for two ends with one material in Three.js
First, I knew the following basic knowledges,
GLSL Language, Learn WebGL2 - GLSL
* GLSL Shaders
OpenGL - Coordinate Systems, [OpenGL - Advanced GLSL]
3D Game Shaders For Beginners - GLSL
...
0
votes
0
answers
28
views
Draw a plane in fragment shader using determinant?
I'd like to use the determinant of a matrix to draw a plane in the fragment shader. But I don't understand how to come up with the matrix.
Let's say that I have 3 points that lie on the plane: A, B, ...
0
votes
1
answer
141
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 ...
0
votes
1
answer
202
views
Debugging shader script in GLSL ES - Game Maker 2 (CompileError)
I am trying to use this shader in the game I am making with Game Maker Studio 2.
I tried to convert it for GM2 and here is my result:
Shader type I used on GM2 is ...
1
vote
2
answers
97
views
Custom directional shadow map from sun
Due to some material features, I need to create my own directional shadow map.
Everything seems to work ok, until the moment where I compare depths.
First I add a camera component to the directional ...
1
vote
2
answers
133
views
Combining palette-swaps and smooth scaling in a pixel-art shader
I am creating a pixel-art game in MonoGame, and have written a shader to perform various effects on a sprite when rendering it, such as performing palette swaps, highlighting outlines, etc.. Most of ...
0
votes
0
answers
37
views
How can I make the inside of a mesh solid?
I followed this tutorial to create a simple liquid effect. I am trying to modify it to make an effect where it looks like the liquid is covering an object. I have a shader that changes the alpha of an ...
0
votes
0
answers
12
views
Combine fixed4's inside shader
In my shader I have 2 fixed4's: one for land and the other for water. The land fixed4 is completely opaque whereas the water <...
1
vote
1
answer
41
views
Unity Shader w Color Bar for Fragment Color Manipulation
Situation
I have a shader for images with "wonky" colors - the reason the colors are so messy is because it's a sneaky way to encode data into the RGB color channels eg the red channel is ...
1
vote
0
answers
224
views
1Bit Bayer Ordered Dithering Shader
I’m having a problem trying to fix my 1bit ordered dithering shader.
This shader is going to be perfect to be used but there is some detail that I would like to fix.
First of all, this shader is not ...
0
votes
2
answers
1k
views
How to decorate the floor with a grid?
I got this photo from mixamo.com — I want to draw grid lines similar to this on my floor.
I'm sure this is easy by using textures, but I'm trying to avoid using textures as much as possible. Is there ...
1
vote
1
answer
450
views
intersection of primitive in a unit wrapping 3D space
is there people good enough for a math problem (for a shader)?
I want to write an algorithm that would intersect primitives (triangles, squares, circle, sphere, cube, cylinder) inside a unit wrapping ...
0
votes
0
answers
71
views
Very basic question: Passing data in fragment shader to next frame (Metal)
I am casually trying to learn a bit about writing simple fragment shaders, in particular using Metal API. I have been experimenting in KodeLife. As a simple example, I am trying to remake the Double ...
1
vote
0
answers
124
views
Cursor trail with fragment shader
I wish to draw a simple mouse trail using fragment shaders, similar in appearance to drawing the following in processing (omitting the step of clearing the canvas). I cannot wrap my head around the ...
-1
votes
1
answer
72
views
Post Processing without using FBOs?
Recently, I've been making a 3D game (hint my questions), and I recently have modified a pixelization shader from a unity shader graph tutorial. The thing is, I want to render the shader on the WHOLE ...
0
votes
2
answers
92
views
Is there a way to figure out in which quad I am in fragment shader?
In my openGL project I draw a lot of quads (composed from 2 triangles) - for sake of example let's say quad 0,1,2 and 3. I process them in single pass. I do transform them with projection view matrix ...
0
votes
0
answers
115
views
OpenGL I want my image to change color based on stencil
I have an image and a rectangle on the screen, using the using this stencil functions I managed to render or not render a certain part of my image.
...
2
votes
3
answers
17k
views
Hue, saturation, brightness, contrast effect in hlsl
I am new to pixel shader, and I am trying to write a simple brightness, contrast, hue, saturation effect. I have written a shader for it but I doubt that my shader is not providing me correct result, ...
1
vote
1
answer
171
views
How to avoid banding with raymarched fog?
I have a raymarching shader for fog.
It works well but It creates artifacts in the form of banding:
I understand the problem: The step size is too large and the sample points above the ground are not ...
0
votes
1
answer
42
views
Relocate texture regions with pixel shader
I'm new to DirectX and pixel shader development. I want to know how to relocate region of input image in post processing.
What I want to achieve is to divide my image into 4 pieces and then relocate ...
1
vote
0
answers
70
views
Why is this GL_TRIANGLE fan texturing incorrectly?
I am constructing some terrain for a 3D game (in C) as a 2D grid of tiles, the corners of which have height into the 3rd dimension. In the middle of each tile is another vertex, the height of which is ...
19
votes
2
answers
39k
views
GLSL Shader - Change Hue/Saturation/Brightness
I'm trying to change the hue of an image using a GLSL fragment shader. I want to achieve something similar to Photoshop's Hue/Saturation Adjustment layer.
In the following image you can see what I've ...
-1
votes
1
answer
106
views
Shaders overriding other shaders
Recently, I've been making a 3D game and I have been having trouble with making multiple shaders. I've researched this for a bit, and told that I had to use ...
0
votes
0
answers
28
views
Issues with percentage closer filtering
I'm trying to code a simple game via OpenGL C++.
I've implemented a point light, parallax effect with textures, objects from blender etc. but I seem to have an issue with my percentage closer ...
1
vote
1
answer
1k
views
Manually writing a dx11 tessellation shader
I am looking for resources on what are the steps of manually implementing tessellation (I happen to be using Unity CG, but any help is appreciated).
Today it seems that it is all the rage to hide ...
0
votes
2
answers
208
views
How to use vertex and fragment shaders without using VBOs and VAOs?
Recently, I am trying to make a 3D game in LWJGL 2, not LWJGL 3, just because I am more familiar with LWJGL 2. Since LWJGL decided to shut down their legacy wiki website, I've been researching alot ...
1
vote
0
answers
643
views
OpenGL Compute Shader vs Fragment Shader device support
I have a game with massively parallelizable logic, which I intend to write calculate on the GPU (Java/LibGDX).
I am planning to implement a logic for it through a fragment shader, instead of a compute ...
1
vote
0
answers
112
views
Fragment shader not working as expected
I am porting the following shader into Godot. The results seem not correct though. Apart from the wrong colours there seems to be no change with time. What is the problem with it?
...
1
vote
1
answer
175
views
Why does my stencil buffer allow pixels through?
I'm rendering a scene using OpenGL. The scene consists of a grassy environment and a small lake (visible as two surfaces). To achieve water surface transparency, I'm using a stencil buffer to render ...
1
vote
1
answer
473
views
How to convert screen space to world space?
I have a shader that should do raymarching.
But I have problems converting the fragment's position to a worldspace coordinate.
This is my vertex shader:
...
1
vote
1
answer
1k
views
mapping texture uvs to sphere for skybox
I've been trying to learn shader coding, specifically procedural skyboxes. I've been using this guide here which is a shader graph tutorial and try to write out the steps in code. However, I'm stuck ...
3
votes
1
answer
170
views
Shading a concave cube as a convex cube with forced perspective
Context
I'm building a graphics pipeline for voxel volumes. I'm using an existing game engine (Bevy) which provides a way to put an object in 3D space. In my application, the voxel volumes can be ...
0
votes
1
answer
213
views
Drawing a pixel perfrect rectangle with stroke using shader
I'm drawing a rectangle based on input sizes and use it to mask the screen.
Now I want to give it 1 pixel stroke but it doesn't rasterize to one pixel.
I tried UnityPixelSnap but still no chance.
Here'...
0
votes
0
answers
35
views
How to 3 triangle could generate hundred of fragments? [duplicate]
I am just watching the Shaders intro video from here where the Youtube is saying
3 vertices make up a triangle and Could generate a couple hundred fragments based on how much of the screen that ...
4
votes
1
answer
3k
views
Infinite world floor grid shader
I am trying to render an infinite world floor grid, similar to this question.
My project is using SceneKit with Metal Shading Language but the concepts are no doubt similar between GLSL/HLSL.
Here is ...
2
votes
1
answer
457
views
Is linear filtering possible on depth textures in OpenGL?
I'm working on shadow maps in OpenGL (using C#).
First, I've created a framebuffer and attached a depth texture as follows:
...
0
votes
0
answers
847
views
Unity: Efficient way to get the average pixel color for a portion of the camera viewport
At it's core, the problem I'm trying to solve is this:
I have a camera (not main) that I would like to project to a 2 pixel RenderTexture. I would like the first ...
0
votes
1
answer
64
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:
...
3
votes
2
answers
2k
views
Why is enabling GL_FRAMEBUFFER_SRGB making the colours brighter?
My understanding of gamma correction is as follows: We want to do colour math in linear space so we can lerp etc. between colour values and get the results we expect. But human eyes don't have a ...
1
vote
1
answer
112
views
Sending light data from Vertex Shader to Pixel Shader?
We have a pixel shader constant buffer that contains the light data for the item that is currently rendered.
To implement tangent space normal mapping, i would need to transform each light into ...
1
vote
1
answer
114
views
Fragment shader - map dot texture repeatedly over the sphere
I have a sphere and in Fragment shader, I have available lat / lon position (in radians) for every fragment. I have a texture of a single dot. I need to map this single dot (or any other texture) ...
0
votes
0
answers
377
views
Fragment shader for lighting in isometric perspective
What I'm trying to do is to achieve basic lighting in 2D from an isometric perspective.
Here I have 2 textures that are used as tiles for the ground:
Color:
Normal map:
I have a fragment ...