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

DirectX 11, Combining pixel shaders to prevent bottlenecks

I'm trying to implement one complex algorithm using GPU. The only problem is HW limitations and maximum available feature level is 9_3. Algorithm is basically "stereo matching"-like algorithm for two images. Because of mentioned limitations all…
Lukasz Spas
  • 556
  • 2
  • 9
  • 23
0
votes
1 answer

DX Shader Assembly Registers

I'm starting to learn dx assembly but I'm really confused there are some registers i can't seem to find what are they for anywhere these registers are: mov_pp mov_sat and basically all of them that have something different from normal assembly…
Makenshi
  • 943
  • 3
  • 14
  • 27
0
votes
1 answer

Pixel shader with SharpDX and DirectX toolkit outputting pure red color

I am creating a Windows Phone 8 app and I'm working with camera. When I don't use any shader, my C# code works perfectly: void photoDevice_PreviewFrameAvailable(ICameraCaptureDevice sender, object args) { …
Can Poyrazoğlu
  • 29,145
  • 40
  • 152
  • 327
0
votes
0 answers

Rendering a line into a 1x1 RenderTarget2D does not change the target's pixel color

What I am trying to achieve is the following: my pass will return a huge array with several unique numbers repeating over and over, which I need to retrieve and process on CPU. I tried rendering into a 2000x1 texture and then sampled it on the CPU…
cubrman
  • 782
  • 6
  • 20
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
  • 631
  • 1
  • 14
  • 32
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
  • 819
  • 13
  • 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
  • 8,943
  • 21
  • 69
  • 131
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
  • 300
  • 2
  • 6
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
  • 2,903
  • 7
  • 27
  • 54
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
  • 2,903
  • 7
  • 27
  • 54
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
  • 540
  • 6
  • 15
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
  • 162
  • 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,516
  • 16
  • 34
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
  • 988
  • 1
  • 16
  • 34
1 2 3
20
21