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

c++ DirectX lighting in pixel shader issue

I have a problem that I cant manage to figure out. I just added a point light to my project and it makes the textures go completely black. I have no idea why. I think that it might be either the normal that is not updating correctly or it might be…
Rickard
  • 33
  • 7
2
votes
1 answer

Pixelation/filtering issue in Silverlight when using a pixel shader with a rotation transformation

I am doing some game-related rendering with Silverlight, and when I attach a pixel shader to an image that has a (rotational) transformation, I am seeing a strange, fuzzy, pixelation effect. Here is a screenshot of the problem. The image on the left…
Andrew Russell
  • 26,924
  • 7
  • 58
  • 104
2
votes
1 answer

Restricting Pixel shader on particular area of image

Is there any way to restrict Pixel shader on particular area of image. BR
Saghar
  • 693
  • 2
  • 12
  • 24
2
votes
1 answer

HLSL Shader to Subtract Background Image

I am trying to get an HLSL Pixel Shader for Silverlight to work to subtract the background image from a video image. Can anyone suggest a more sophisticated algorithm than I am using because my algorithm isn't doing it correctly? float Tolerance :…
Michael S. Scherotter
  • 10,715
  • 3
  • 34
  • 57
2
votes
0 answers

How do you fix wobbling shadow edges?

I've implemented an omni-directional shadow map and I've noticed a rather unwanted behaviour on the shadows. It seems like when the angle between the occluded points and the light source is really steap, then the egde of the shadow starts to wobble.…
SvinSimpe
  • 850
  • 1
  • 12
  • 28
2
votes
1 answer

What happens if Vertex Attributes not match Vertex Shader Input

As I know, if the vertex buffer has an attribute that shader does not use, there will be no problem. What happens if the vertex buffer does not have an attribute that the vertex shader uses for OpenGL? I know for DirectX11, nothing will draw if the…
user2400739
  • 23
  • 1
  • 5
2
votes
2 answers

Pixel coordinates in Metal fragment shader

I am writing a 3D app using Metal. For rendering in 3D I need to control each pixel. In normal screens this seems to be working ok with the [[position]] variable passed to the shader. But in Retina display, where there is a scaling factor, each…
zolio
  • 2,439
  • 4
  • 22
  • 34
2
votes
3 answers

HLSL How can one pass data between shaders / read existing colour value?

I have 2 HLSL ps2.0 shaders. Simplified, they are: Shader 1 Reads texture Outputs colour value based on this texture Shader 2 Problem: Need to read in the colour from Shader 1 Outputs the final colour which is a function of the input…
RJFalconer
  • 10,890
  • 5
  • 51
  • 66
2
votes
1 answer

About AutoHotkey's ImageSearch shades of variation and its calibration

My question is related to the following AutoHotkey function (you may find it here): ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile According to its purpose, this function searches a region of the screen for an image. As of the…
Lisa Ann
  • 3,345
  • 6
  • 31
  • 42
2
votes
3 answers

Can pixel shaders be used when rendering to an offscreen surface?

I'm considering integrating some D3D code I have with WPF via the new D3DImage as described here: My question is this: Do pixel shader's work on offscreen surfaces?
dicroce
  • 45,396
  • 28
  • 101
  • 140
2
votes
2 answers

DirectX11 pixel shader in pipeline is missing

I'm writing a program which displays a MS3D model using DirectX, and unfortunately, the result shows nothing on the screen. When I use the Graphics Debugger from Visual Studio 13, I notice that the pixel shader is missing from the pipeline, as it…
khanhhh89
  • 317
  • 5
  • 19
2
votes
2 answers

Is the distinction between vertex and pixel shader necessary or even beneficial?

From what I've been able to get, both vertex and pixel shader operations boil down to passing data and doing a lot of the same with it for every available unit. Surely, vertex and pixel shaders are in different parts of the classical graphical…
user2341104
2
votes
1 answer

Performance of dynamic constant buffer indexing in pixel shaders

I have a pixel shader, written in HLSL, that declares the following constant buffer: cbuffer RenderParametersData : register(b2) { float4 LineColor[16]; }; In one of the shader functions, I look up the output color based on the index "color"…
Justin R.
  • 23,435
  • 23
  • 108
  • 157
2
votes
1 answer

How to achieve supersampling / anti-aliasing in pixel shaders?

I am trying to write a couple pixel shaders to apply to images similar to Photoshop effects. For example this effect: http://www.geeks3d.com/20110428/shader-library-swirl-post-processing-filter-in-glsl/ But I noticed there is aliasing in the…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
2
votes
1 answer

VS2012 Shader Designer broken algorithm?

I was having no end of trouble with this function, emitted by the shader designer in VS2012. If you look at the code below, you can see the difference between the VS Version and MY Version. In the VS version, they do not take into account the…
Dave
  • 1,521
  • 17
  • 31