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
0 answers

In HLSL pixel shader, why am I getting [-256.0, 256.0] values in SV_POSITION input?

My question is basically in my DirectX11 pixel shader, why am I getting a range of values from -256.0 to 256.0 in the SV_POSITION input instead of the supposed values from 0.0 to ViewportWidth and 0.0 to ViewportHeight? I am setting explicitly the…
0
votes
0 answers

GPU shaders not running any faster than CPU?

OK, I have a JPG loaded into a WPF Image (I've got a WriteableBitmap which I use as the Image.Source). This JPG is 10,000 x 5,000 pixels. I also have the ability to scale up the image to 200%, so effectively, I'm up to 20,000 x 10,000 pixels, i.e. a…
Garry
  • 623
  • 1
  • 7
  • 11
0
votes
0 answers

Using constant buffer data as index when returning from a shader

So I have a pixelshader that blends different textures using a blend map, but I am attempting to make the blending an option. So my solution was that I calculate 3 different float3 which are in an array (0 is no blend, 1 is blend between two…
Gamewolf3000
  • 63
  • 2
  • 8
0
votes
3 answers

Is it possible to draw simple geometrical shapes in a Pixel Shader?

I'm currently learning about shaders and graphics pipelines and I was wondering if a pixel shader could be used to create, for example, a triangle or a more complex shape like a zigzag. Could this be done without the use of a vertex shader?
TheAuzzieJesus
  • 587
  • 9
  • 23
0
votes
3 answers

How do I use/apply transparency on a pixel using a shader.fx?

I'm not sure if I'm not using the right SpriteBatch parameters or if my shader is not coded properly, but, to be simple, I'm trying to make a shader that sets the alpha of all pixels to 128. However, there seems to be only 2 possible 'alphas'.…
0
votes
2 answers

Can't get texture.Sample to work, although I can get texture.Load to work fine in Direct 3d 11 shader

In my HLSL for Direct3d 11 app, I'm having a problem where the texture.Sample intrinsic always return 0. I know my data and parameters are correct because if I use texture.Load instead of Sample the value returned is correct. Here are my…
antlersoft
  • 14,636
  • 4
  • 35
  • 55
0
votes
1 answer

About the glsl for loop

I have just encountered this issues and I do not know how to look at it. I guess that I have an intuition of how it might work but I want to know if some of you can give me an answer. So, i have a function wave that returns a float. Now, with this…
khael
  • 2,600
  • 1
  • 15
  • 36
0
votes
2 answers

Unity 4.6 UI image blur

Is there a way to set blur on the image in new UI on Unity 4.6? I need normal image to become blurred or pixelized on button click. I did try to use some free shader from asset store but it doesn't work on android phones.
filipst
  • 1,547
  • 1
  • 30
  • 55
0
votes
1 answer

Issues with calculate final pixel color with multiple point lights DX11

As the header denotes I've got some issues calculating the final pixel color when rendering a scene with multiple point lights. When I calculate one light, the scene looks just fine but when I calculate more than one the light it seems to be a bit…
SvinSimpe
  • 850
  • 1
  • 12
  • 28
0
votes
1 answer

No pixel shader means no color output?

I'm doing depth/stencil passes in DirectX11 and I believe I can simply unbind the pixel shader slot to skip the pixel shading and thus all color-output to rendertargets alltogether (even if there are rendertargets bound), and just render to the…
KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199
0
votes
1 answer

Applying a pixel shader to a ViewPort3D

I'm new to pixel shaders, and I'm trying to apply an underwater-effect to my 3d scene. I can apply it to an image and animate it easily enough, but not to my ViewPort3D. The computer just hangs when calling BeginAnimation on the effect being applied…
Paul Rivera
  • 525
  • 1
  • 8
  • 20
0
votes
1 answer

Compatibility issues on GLSL fragment shaders

I have found a few times differences between GPUs handling fragment shaders. One example was doing pow(x) where x is negative. One GPU handled it well while the other one failed. Another situation was where I rewrote if() statements with step()…
lukas.pukenis
  • 13,057
  • 12
  • 47
  • 81
0
votes
2 answers

Up-Down, Left-Right facing ratio shader

A little basic question i can't get my head around. I need to create a shader that works like a facing ratio shader however also containing up-down and left-right (in screen space). Just like this: I want it to work without having the original…
user2339945
  • 623
  • 1
  • 9
  • 14
0
votes
0 answers

Custom ssao in Three.js

I am trying to finish a ssao shader from a tutorial: http://www.nutty.ca/?page_id=352&link=ssao I use multi-pass render in three.js. There is a similar question in stackoverflow SSAO artefacts in Three, and I find we learned from the same…
yongnan
  • 405
  • 7
  • 20
0
votes
0 answers

SharpDX Pixel shaders need different parameters for different SpriteBatches vs DrawQuad. Fixable?

I'm new to building graphics engines and kinda stumped on a particular issue. I have an issue getting pixel shaders to work using the same set of parameters for both. Causing me to have to create 2 different techniques for each method. If I try to…
corylulu
  • 3,449
  • 1
  • 19
  • 35