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
1
vote
1 answer

Setting pixel shader uniform variable

Dummy question, I guess. I have a custom shader that looks like this: sampler2D InputTexture; float parameter1, parameter2 etc float4 main(float2 uv : TEXCOORD) : COLOR { float4 result = blah-blah-blah some calculations using parameter1,…
yadda
  • 53
  • 8
1
vote
1 answer

Pixel shader in Direct2D render error along the middle

I've created a pixel shader for Direct2D that blurs along edges with an alpha channel lower then 1.0. For every pixel I sample a blurRadius of pixels up, down, left and right. In the middle (vertically and horizontally) some render errors occur.…
CodeIT
  • 91
  • 10
1
vote
3 answers

HLSL Translucent Plastic Shader

I'm trying to produce a shader to replicate a white plastic object with a colored light inside. Either by having a shader that will be translucent and if I put a light inside the object the light will show through or by having a shader that fakes…
Tristan
  • 3,845
  • 5
  • 35
  • 58
1
vote
2 answers

How to avoid int->float conversion when passing data to pixel shader?

I have a pixel shader: varying vec2 f_texcoord; uniform vec4 mycolor_mult; uniform sampler2D mytexture; void main(void) { gl_FragColor = (texture2D(mytexture, f_texcoord) * mycolor_mult); }; and corresponding C++ code: GLint m_attr =…
Nick
  • 3,205
  • 9
  • 57
  • 108
1
vote
3 answers

XNA + Pixel Shader Difficulties

I've written a basic 2d pixel shader, and i can't seem to get it to work. If i draw with the effect active, then nothing draws to the screen. But if i disable it, then the texture draws to the screen as expected. My aim is to be able to draw an…
RCIX
  • 38,647
  • 50
  • 150
  • 207
1
vote
1 answer

Delphi DX11 Direct3D Vertex and Pixel Shader Issues

I'm attempting to translate some C++ DX11 Direct3d height-map code into Delphi. I'm at at a stage where I have almost the entire code translated across without any compile errors or run-time errors however I cannot for the life of me get anything to…
weblar83
  • 681
  • 11
  • 32
1
vote
1 answer

Why do we implement lighting in the Pixel Shader?

I am reading Introduction to 3D Game Programing with DirectX 11 by Frank D. Luna, and can't seem to understand why do we implement lighting in Pixel Shader? I would be grateful if you could send me some reference pages on the subject. Thank you.
mkorunoski
  • 71
  • 2
  • 7
1
vote
1 answer

HLSL Pixel Shader Colour Sample

I'm new to hlsl. I'm trying to write a pixel shader that converts from RGB space to YIQ space (NTSC). The conversion process is fine, but I cannot seem to get the sampler and tex2D to return any colour besides that in the upper left of the texture.…
vicmcg9
  • 13
  • 1
  • 7
1
vote
1 answer

New to DirectX, can someone explain what this declaration is?

I've been researching a game's engine for the last few months and after extracting the DX9 bytecode, have begun examining the game's shaders. I mainly worked with OpenGL so some of the syntax or way of doing things is new to me. Anyway, this is a…
Ioncannon
  • 901
  • 1
  • 7
  • 19
1
vote
1 answer

Restrict the area that a WPF shader effect gets applied to

How can I restrict the area that a WPF shader effect gets applied to, in a similar manner to the way the obsolete BitmapEffectInput.AreaToApplyEffect used to work for BitmapEffects? Is there an equivalent property for shader effects, or do I have to…
luvieere
  • 37,065
  • 18
  • 127
  • 179
1
vote
3 answers

Silverlight Pixel Shader resource "not found"; what should the URI be?

So I've written and compiled an HLSL pixel shader with Shazzam, placed the resulting .ps file in my project, and am trying to instantiate it. No matter what URI I put, Blend tells me that the resource can't be found whenever I try to view any xaml…
Grank
  • 5,242
  • 7
  • 33
  • 36
1
vote
0 answers

HLSL - Sampling a render target texture always return black color

Okay, first of all, I'm really new to DirectX11 and this is actually my first project using it. I'm also relatively new to Computer Graphics in general so I might have some concepts wrong although, for this particular case, I do not think so. My…
tiansivive
  • 506
  • 1
  • 4
  • 16
1
vote
1 answer

How to implement linear interpolation when stretching a texture in HLSL?

This is the pixel shader code: sampler s0 : register(s0); float4 main(float2 tex : TEXCOORD0) : COLOR { tex.x=tex.x/8 +0.25; float4 l = tex2D(s0, tex); return l; } When running the above code I get the following: I tried changing the sampler…
Jane Smith
  • 11
  • 4
1
vote
1 answer

How could I implement a bleach bypass shader effect for WPF?

How could I implement a bleach bypass shader effect for WPF? I'm also interested in the possibility of implementing the first two Tehnicolor Film Processes, or any variety that would result in an old film look.
luvieere
  • 37,065
  • 18
  • 127
  • 179
1
vote
0 answers

Strange D3D11 Error when creatng shader [SharpDX/MONOGAME]

i'm a true beginner in shader programming and i'm using the monogame framework . I'm trying to follow along the examples in this book packtpub 3d graphics with xna game studio 4.0 But i've been hitting a wall for the past 4 days trying to make the…
DaKi
  • 11
  • 2