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
4
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
  • 930
  • 6
  • 10
4
votes
2 answers

Using shaders from Shadertoy in Interface Builder (Xcode)

I'm attempting to see what shaders look like in Interface Builder using sprite kit, and would like to use some of the shaders at ShaderToy. To do it, I created a "shader.fsh" file, a scene file, and added a color sprite to the scene, giving it a…
BadPirate
  • 25,802
  • 10
  • 92
  • 123
4
votes
1 answer

How do you access a previously shaded texture in a Pixel Shader?

In WPF, I want to use a pixel shader to modify a composite image i.e. a new image overlaid on top of a previously shaded image. The new image comes in as a largely transparent image except where there is data (think mathematical functions - sine…
Keith Hill
  • 194,368
  • 42
  • 353
  • 369
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,387
  • 1
  • 13
  • 24
4
votes
1 answer

HLSL: Getting texture dimensions in a pixel shader

I have a texture and I need to know its dimensions within a pixel shader. This seems like a job for GetDimensions. Here's the code: Texture2D t: register(t4); ... float w; float h; t.GetDimensions(w, h); However, this results in an error: X4532:…
Justin R.
  • 23,435
  • 23
  • 108
  • 157
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
  • 267
  • 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,308
  • 4
  • 28
  • 35
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,671
  • 2
  • 21
  • 36
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

D3D Texture convert Format

I have a D3D11 Texture2d with the format DXGI_FORMAT_R10G10B10A2_UNORM and want to convert this into a D3D11 Texture2d with a DXGI_FORMAT_R32G32B32A32_FLOAT or DXGI_FORMAT_R8G8B8A8_UINT format, as those textures can only be imported into CUDA. For…
LRK
  • 123
  • 1
  • 8
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,420
  • 5
  • 44
  • 83
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
  • 215
  • 3
  • 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
  • 355
  • 3
  • 10
3
votes
3 answers

JavaFX Custom Effects with Pixel Shader

is it possible to create custom effects for JavaFX, based on a Pixle Shader? I found this article but what is Decora? I cannot find anything about it. THX
user1770962
  • 211
  • 1
  • 2
  • 11