Questions tagged [pixel-shader]

Pixel shaders, also known as fragment shaders, compute color and other attributes of each fragment. Pixel shaders range from always outputting the same color, to applying a lighting value, to doing bump mapping, shadows, specular highlights, translucency and other phenomena.

Pixel shaders, also known as fragment shaders, compute color and other attributes of each fragment. Pixel shaders range from always outputting the same color, to applying a lighting value, to doing bump mapping, shadows, specular highlights, translucency and other phenomena.

They can alter the depth of the fragment (for Z-buffering), or output more than one color if multiple render targets are active.

In 3D graphics, a pixel shader alone cannot produce very complex effects, because it operates only on a single fragment, without knowledge of a scene's geometry. However, pixel shaders do have knowledge of the screen coordinate being drawn, and can sample the screen and nearby pixels if the contents of the entire screen are passed as a texture to the shader. This technique can enable a wide variety of two-dimensional postprocessing effects, such as blur, or edge detection/enhancement for cartoon/cel shaders.

Pixel shaders may also be applied in intermediate stages to any two-dimensional images in the pipeline, whereas vertex shaders always require a 3D model. For instance, a pixel shader is the only kind of shader that can act as a postprocessor or filter for a video stream after it has been rasterized.

310 questions
1
vote
0 answers

What's the most efficient way to write a video shader that uses many previous input frames?

I'm writing a video effect in iOS using Metal that requires pixel data of the current frame as well as many previous frames of the original input video. Is there a common pattern or best practice for how to achieve this type of shader that makes the…
Ian Pearce
  • 143
  • 1
  • 10
1
vote
0 answers

The homemade Chroma Key filter I developed in OBS-Studio can't use the usual green or blue background, but it can be used in red

I refer to the OBS Studio 20.1.0 documentation and chroma_key_filter.effect on github. I have had a problem with the recent homemade obs-studio filter. I can't think of how to solve it. I want to ask everyone here, I hope I can get some suggestions…
Jared C
  • 11
  • 3
1
vote
0 answers

HLSL custom bitpacking not working correctly

I'm a bit of a noob with Directx but i have been trying to get this custom bitpacking working all day. I'm trying to pack a float4 and another float into a uint. The float4 is a color and the float is a depth value. I want to use 6 bits each for the…
kostenickj
  • 11
  • 3
1
vote
0 answers

WPF PixelShader whose Input is data below UIElement not in the UIElement

I am trying to create a PixelShader similar to Photoshop’s Adjustment Layer. Invert is a simple example where it generates a negative image (return 1 – pixel). The problem I have is you attach the Effect to a UIElement and the pixels used are…
Pat
  • 11
  • 2
1
vote
2 answers

Apply DropShadowEffect to WPF Textbox text

How can I apply the DropShadowEffect on the content of a TextBox, as opposed to around the TextBox itself? I'd like the text to have the same effect as if I applied DropShadowEffect to a TextBlock.
B-H
  • 57
  • 1
  • 9
1
vote
1 answer

Speed of ComputeShader vs. PixelShader

I've got a question regarding ComputeShader compared to PixelShader. I want to do some processing on a buffer, and this is possible both with a pixel shader and a compute shader, and now I wonder if there is any advantage in either over the other…
SinisterMJ
  • 3,425
  • 2
  • 33
  • 53
1
vote
1 answer

How to apply a glsl pixel shader to a texture?

I have a texture and i would like to apply to it a glsl shader. Is it possible and how to do it ? For example i want to apply this glsl shader to my texture : varying vec4 coord; uniform sampler2D texture; uniform float opacity; void main() { …
zeus
  • 12,173
  • 9
  • 63
  • 184
1
vote
0 answers

Pixel Art Sprite Shader cant cut off edges?

I'm trying to write a sprite shader that can turn normal sprites into pixel art. And it works relatively well IN the texture, but the entire things always has the shape of the original sprite instead of being whole squares. I suspect that is because…
1
vote
0 answers

Reflections in pixel shader

I am having trouble in my pixel shader's reflections https://www.shadertoy.com/view/lsycD1, I cant get them to work, currently they are inside my main's render loop and are almost displaying what I want but not really, I have tried using reflect(…
Felipe Gutierrez
  • 675
  • 6
  • 17
1
vote
1 answer

Show / Hide specific color ranges with PixelBender

What is the best way to hide specific (interpolated) color ranges? For example, I have a gradient that goes from blue > cyan > yellow > red. What I need is to hide blue > cyan, yellow > red but leave the cyan > yellow. var rangeA:Object =…
Andrei
  • 73
  • 3
1
vote
1 answer

Is there a way to concurrently write to a UAV without race condition?

I have a compute shader which simulates some fluid as particle. Particles are read from a buffer. Each particle is handled in one thread. During the execution of the thread, one particle moves its uv position and adds to pixel of a UAV named Water .…
morteza khosravi
  • 1,599
  • 1
  • 20
  • 36
1
vote
2 answers

Strange floating point arithmetics in WebGL fragment shader

I'm writing a simple WebGL program. I'm stuck with a strange behavior in a shader program: condition ( 1.01 * 2.0 > 1.0 ) evaluates to true but condition ( 0.99 * 2.0 > 1.0 ) evaluates to flase Every time I multiply a number lesser than 1.0 by…
bartek
  • 505
  • 1
  • 4
  • 19
1
vote
1 answer

Direct3D11 Pixel Shader Interpolation

I'm trying to create a simple transition between two colors. So a render of a quad with top edge colors being #2c2b35 and bottom color being #1a191f. When I put it through simple pixel shader which just applies colors to the vertices and…
majstor
  • 379
  • 3
  • 14
1
vote
4 answers

Tool for pixel and vertex shader

Is there any tool for testing pixel and vertex shaders?
Amir Rezaei
  • 4,948
  • 6
  • 33
  • 49
1
vote
1 answer

How to create multiple shader effect instances?

I've created custom shader effect that looks like this: class MyShaderEffect : ShaderEffect { private PixelShader _pixelShader = new PixelShader(); public readonly DependencyProperty InputProperty = …
yadda
  • 53
  • 8