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

Using floor() function in GLSL when sampling a texture leaves glitch

Here's a shadertoy example of the issue I'm seeing: https://www.shadertoy.com/view/4dVGzW I'm sampling a texture by sampling from floor-ed texture coordinates: #define GRID_SIZE 20.0 void mainImage( out vec4 fragColor, in vec2 fragCoord ) { …
Joseph Humfrey
  • 2,974
  • 2
  • 23
  • 34
3
votes
1 answer

Is there any way to apply shader effect on particular cell of a Grid

Is there any way to apply shader effect on particular cell of a Grid. BR
Saghar
  • 693
  • 2
  • 12
  • 24
3
votes
1 answer

How to build shader effect (.fx) in csproj

I'm trying to build pixel shader in a C# class library. I have added fx file to the project. Since I can't find any suitable build action I tried to manually edit csproj:
Liero
  • 25,216
  • 29
  • 151
  • 297
3
votes
1 answer

WPF Custom Effect disappears when using Remote Desktop

I currently have an issue that removes my effect from the UIElement in question when using Remote Desktop (I've tried various types of clients). RemoteFX is enabled on the host Machine (windows 7 and 8/8.1) The PixelShader i made is compiled to…
Nicholas
  • 783
  • 2
  • 7
  • 25
3
votes
1 answer

Rendering a circle with a pixel shader in DirectX

I would like to render a circle on to a triangle pair using a pixel shader written in HLSL. There is some pseudocode for this here, but I am running in to one problem after another while implementing it. This will be running on Windows RT, so I am…
Justin R.
  • 23,435
  • 23
  • 108
  • 157
3
votes
1 answer

Trying to make Gaussian Blur stronger/blurrier - XNA 4.0 HLSL

I'm trying to implement a gaussian blur on a Texture2D and have had trouble trying to find any good tutorials etc. I've finally managed to find a nice piece of one-pass sample code and it visibly does blur the image a tiny bit but I want to be able…
poncho
  • 1,100
  • 2
  • 15
  • 38
2
votes
2 answers

Per-line texture processing accelerated with OpenGL/OpenCL

I have a rendering step which I would like to perform on a dynamically-generated texture. The algorithm can operate on rows independently in parallel. For each row, the algorithm will visit each pixel in left-to-right order and modify it in situ (no…
spraff
  • 32,570
  • 22
  • 121
  • 229
2
votes
1 answer

How to unset texture data in XNA 4.0

I need to communicate some constantly changing data to my pixel shader. I have a texture2d that I am passing to my pixel shader via a texture parameter. Before I call the shader I need to update the data in the texture. …
Mr Bell
  • 9,228
  • 18
  • 84
  • 134
2
votes
2 answers

How to modify/displace pixel position in a Cg fragment shader?

Is it possible to modify pixel coordinates in a fragment (pixel) shader using Cg? I'm sure such functionality became available in 2nd/3rd-generation shaders but I don't know what profiles exactly, or how to do it.
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
2
votes
1 answer

How to access depth buffer in pixel shader in DirectX 9.0 c

Is it possible to access depth buffer via pixel shader 2.0 in DX 9.0c? I've google'd a bit and the only solution I've found describe GPU hack that works only on GeForce 6 & 7. What I am trying to achieve is to write depth of field shader effect. I…
PiotrK
  • 4,210
  • 6
  • 45
  • 65
2
votes
1 answer

How to correct this HLSL pixel shader to round corners of a quad?

I'd like the make an HLSL pixel shader that can round the corners of a quad. I attempted to port this GLSL example the following way: cbuffer CBuf : register(b0) { float4 color; float2 dimensions; float radius; float na; }; struct…
cecil
  • 317
  • 2
  • 8
2
votes
1 answer

Mandelbrot in a Pixel Shader

I'm working for some days now on a DirectX 11 version of the Mandelbrot set. What I've done so far is create a quad with a texture on it. I can color the points with a Pixel Shader, but for some reason the Mandelbrot set in the Pixel Shader does not…
Gilles Walther
  • 126
  • 1
  • 7
2
votes
1 answer

Unity Shader Graph: Combining texture rotation and offset

I'm making a water simulation, and I'm trying to visualize the velocity field. In this demo I continuously add water in the centre of the image, where the blue 'raindrop' things are. I have a texture where rg is the X and Y direction of the…
The Oddler
  • 6,314
  • 7
  • 51
  • 94
2
votes
1 answer

Color using alpha blending are different on different Android phones with OpenGL-ES

I am experiencing an issue on Android with OpenGL ES 3.1. I wrote an application that shows a liquid falling down from the top of the screen. This liquid is made of many particles that are a bit transparent, but the color using alpha blending are…
Shibakaneki
  • 213
  • 3
  • 12
2
votes
1 answer

Can't access a DXGI_FORMAT_R8_UINT texture

I want to do some calculations on a 8bit image sent by a camera, and I just can't figure out the way to access them. Following is my code to create the texture object / resource view: D3D11_TEXTURE2D_DESC tDesc; tDesc.Height = 480; tDesc.Width =…
SinisterMJ
  • 3,425
  • 2
  • 33
  • 53