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.

314 questions
4
votes
1 answer

Creating WPF effects with different sized pixel shader samplers

I want to create an effect where I use a quite large image to produce a smaller image with HLSL through a WPF Effect. But it seems that WPF for some reason resizes all input images to the rendered size, which isn't what I want, since it will crop…
Markus
  • 1,554
  • 18
  • 31
4
votes
0 answers

GPUImage: Detecting average luminosity of multiple rectangular sub regions

I am using GPUImage to process incoming video, and each frame I would like to determine the average luminosity of many rectangular subregions of the incoming image for hit detection purposes in a game, but I am having trouble doing so in a way that…
KeithComito
  • 1,389
  • 1
  • 13
  • 24
4
votes
1 answer

Where to call SetRenderTarget?

I'd like to change my RenderTargets between SpriteBatch.Begin and SpriteBatch.End. I already know this…
s0ubap
  • 257
  • 3
  • 8
4
votes
1 answer

What causes the periodic performance spikes that are seen when doing computationally expensive array processing on the Nexus 4?

I'm new to threads (don't kill me for my implementation below :) and I need to do multiple blurring passes of pixels on a separate thread (see below). It's not the most efficient implementation of box blur (it's from Gaussian Filter without using…
torger
  • 2,118
  • 3
  • 27
  • 34
4
votes
0 answers

Which would be faster for pixel format convertion? Pixel shader or compute shader, or maybe OpenCL?

I want to convert frames from YUV420p format(or something like that) to ABGR format on the fly, and put the result frames in video memory as textures. There are two ways I can think about now: Let each channel be a source texture, and render to…
BlueWanderer
  • 2,546
  • 2
  • 19
  • 35
3
votes
4 answers

Image processing C#

I have a function to check if an image is just one color. bool r = true; Color checkColor = image.GetPixel(0, 0); for (int x = 0; x < image.Width; x++) { for (int y = 0; y < image.Height; y++) { if (image.GetPixel(x, y) !=…
3
votes
1 answer

Texture2D Array as Render Target in HLSL Pixel Shader

Currently I need a couple of textures' worth of per-pixel data from my rendering pass (normals, depth and colour). Instead of running three passes with shaders that are essentially the same (WorldViewPos multiplication, etc.) but each outputting a…
Nick Udell
  • 2,306
  • 5
  • 41
  • 81
3
votes
0 answers

Where is "Enable gather of GPU Disassembly" in visual studio 2017?

I need to debug a pixel shader, but I get the following message instead of disassembly: Enable GPU disassembly via View->Options->Graphics Diagnostics->Enable gather of GPU Disassembly. The vsglog must be re-opened for this change to take effect. I…
3
votes
1 answer

GLSL Shader Unwanted Grayscale Effect

Let me preface this with the fact that I am very new to GLSL. I am attempting to use a shader to add a blur effect to slot reel symbols while they spin. I have a working blur effect going, which I have commented out just for simplicity and isolating…
3
votes
1 answer

HLSL modify depth in pixel shader

I need to render an image (with depth) which I get from outside. I can construct two textures and pass them into a shader with no problem (I can verify values sampled in a pixel shader being correct). Here's how my HLSL looks like: // image…
chainerlt
  • 167
  • 1
  • 8
3
votes
1 answer

DX9 and DX10): what is the default pixel (and vertex) shader? (OpenGL too, if possible.)

I'm aware that I can optionally specify shaders in DX9, and that I'm required to specify a shader in DX10. The question I have is what happens if I say I want to use a shader and I don't specify one. In a phrase, what I'm looking for is the default…
jowens
  • 315
  • 2
  • 10
3
votes
1 answer

Dynamically compiling and running shaders from file in XNA

im wondering if its possible to dynamically compile a pixel-shader from file and apply it to a mesh. First I'll just start with some background information. I have a system which creates HLSL pixel-shaders based on a range of data which is not…
Val
  • 900
  • 6
  • 10
3
votes
1 answer

Using floor() function in GLSL when sampling a texture leaves glitch

Here's a shadertoy example of the issue I'm seeing: https://www.shadertoy.com/view/4dVGzW I'm sampling a texture by sampling from floor-ed texture coordinates: #define GRID_SIZE 20.0 void mainImage( out vec4 fragColor, in vec2 fragCoord ) { …
Joseph Humfrey
  • 2,783
  • 2
  • 20
  • 30
3
votes
1 answer

Is there any way to apply shader effect on particular cell of a Grid

Is there any way to apply shader effect on particular cell of a Grid. BR
Saghar
  • 655
  • 11
  • 23
3
votes
1 answer

How to build shader effect (.fx) in csproj

I'm trying to build pixel shader in a C# class library. I have added fx file to the project. Since I can't find any suitable build action I tried to manually edit csproj:
Liero
  • 19,054
  • 16
  • 100
  • 195