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
0
votes
1 answer

DirectX - Deferred Shading w/Instanced Stencil Volumes

I'm creating a graphics application using DirectX9 using DXUT. In my application I would like to implement deferred shading. This method of lighting requires that I render a stencil volume( mask ) for each light within the scene. To avoid rendering…
P. Avery
  • 779
  • 1
  • 16
  • 34
0
votes
1 answer

Math behind Tex2D in HLSL

Could someone explain the math behind the function Tex2D in HLSL? One of the examples is: given a quad with 4 vertices, the texture coordinates are (0,0) (0,1) (1,0) (1,1) on it and the texture's width and height are 640 and 480. How is the shader…
user2619459
  • 21
  • 1
  • 4
0
votes
1 answer

How do I add a ghosting effect to a sprite?

I am trying to add multiple effects to sprite to learn how to do pixel and vertex shaders for 2D games in XNA. Unfortunately, many of the tutorials or example code go over my head, as I am new to shaders (or more correctly the Effect class). The…
Blaze Phoenix
  • 859
  • 2
  • 14
  • 33
0
votes
1 answer

Can I create a motion colorizing pixel shader in WPF?

I have a video playing of lines being drawn on the screen. Is it possible to create a pixel shader (for WPF) that turns newly colored pixels a certain color for N milliseconds? That way, there can be some indication to the user to movement on the…
Paul Knopf
  • 9,568
  • 23
  • 77
  • 142
0
votes
1 answer

Direct3D9 / HLSL Depth semantic not working

i have o problem with my shader code (HLSL). I use "DirectX for Managed Code" and Shader Model 3.0. I try to write a custom depth value into the depth buffer by using the DEPTH semantic in the pixel shader output struct: struct PSOutput { float4…
Michael
  • 310
  • 2
  • 7
0
votes
1 answer

DirectX: Pixel Shader derivative calculation

As far as I understand Pixel Shader operates on per-pixel basis. But there are functions like ddx and ddy that calculates derivates. But how can one calculate derivatives from just one pixel coordinates?? Can someone help me on these? These also…
Rachit Agrawal
  • 3,203
  • 10
  • 32
  • 56
0
votes
1 answer

DirectX: Get Filter Type in Shader

I am trying to get the filter type set in the sampler stat in the Shader code. I am not getting a way to retrieve that. Can someone suggest me a way to do that?? Texture2D InputTexture; SamplerState Sampler; float4 PSMain(float2 pos: TEXCOORD,…
Rachit Agrawal
  • 3,203
  • 10
  • 32
  • 56
0
votes
1 answer

Image Effect with Dark Borders

I was creating an effects library for a PhotoBooth App. I have created effects like Black/White, Vintage, Sepia, Retro etc. etc. I wanted to create a few effects now in which I wanted to have a Dark Border at the edges which kind of form a frame for…
Mudit Jaju
  • 590
  • 7
  • 17
0
votes
1 answer

Efficient pixel shader when only u-axis varies?

I'm writing a pixel shader that has the property where for a given quad the values returned only vary by u-axis value. I.e. for a fixed u, then the color output is constant as v varies. The computation to calculate the color at a pixel is relatively…
AnonDev
  • 172
  • 3
  • 7
0
votes
1 answer

How to set multiple times, in a single spritebatch, the same pixel shader parameter

I make a test with Effect class in XNA and I want to set multiple times the same parameters (MyParameter in below code). My code is : [...] //In Engine class Effect ShaderEffect =…
Cyril ALFARO
  • 1,616
  • 17
  • 35
0
votes
0 answers

HLSL and Pix number of questions

I'm having a number of isses with HLSL and Pix. 1) Can you in HLSL 3, declare a Pixel shader alone without a Vertex Shader? If not, what can I do to get around this? 2) Why does Pix skip code? I have a reasonably long shader method but Pix seems to…
Bushes
  • 1,010
  • 1
  • 18
  • 37
0
votes
1 answer

Per Instance Textures, and Vertex And Pixel Shaders?

How do you implement per instance textures, vertex shaders, and pixel shaders, in the same Vertex Buffer and/or DeviceContext? I am just trying to find the most efficient way to have different pixel shaders used by the same type of mesh, but colored…
e.s. kohen
  • 213
  • 1
  • 4
  • 21
0
votes
1 answer

How does pixel shading work for ambient occlusion volumes?

I'm trying to understand the ambient occlusion technique described here, but I've trouble comprehending what exactly is the pixel shader doing. Is the pixel shader invoked on points that belong to the surfaces of occlusion volumes? Can anyone…
pbp
  • 1,461
  • 17
  • 28
0
votes
1 answer

Scriptable image manipulation

I'm desperately in need of some software. What I'm looking for is some type of image editor that has support for pixel level manipulation by means of some type of scripting language (think HLSL/GLSL pixel shaders.) Requirements: Access to pixel…
Chris_F
  • 4,991
  • 5
  • 33
  • 63
0
votes
1 answer

WP8 Image processing with pixel shader

Is there a way to perform this in XAML app?
Artem Flotsky
  • 29
  • 1
  • 6
1 2 3
20
21