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

Fast approximate algorithm for RGB/LAB conversion?

I am working on a data visualization tool using OpenGL, and the LAB color space is the most comprehensible color space for visualization of the data I'm dealing with (3 axes of data are mapped to the 3 axes of the color space). Is there a fast (e.g.…
8
votes
2 answers

What does a pixel shader actually do?

I'm relatively new to graphics programming, and I've just been reading some books and have been scanning through tutorials, so please pardon me if this seems a silly question. I've got the basics of directx11 up and running, and now i'm looking to…
FatalCatharsis
  • 2,938
  • 3
  • 35
  • 59
7
votes
2 answers

Greenish image with BGRA to YUV444 conversion using DirectX11 pixel shader

  I'm new to HLSL. I am trying to convert color space of an image captured using DXGI Desktop Duplication API from BGRA to YUV444 using texture as render target.   I have set my pixel shader to perform the required transformation. And taking the…
7
votes
1 answer

Passing several textures to shader in LibGDX

I need to pass 2(or more) textures to one shader. Also I have to bind textures in render method, because I use FrameBuffer and try to bind textures on fly. So, my code is below: @Override public void show () { fbo = new…
Nolesh
  • 6,126
  • 11
  • 66
  • 105
7
votes
1 answer

HLSL Normal Mapping Matrix Multiplication

I'm currently working in directx9 and have the following code for my normal mapping: (Vertex Shader): float4x4 gWorldMatrix; float4x4 gWorldViewProjectionMatrix; float4 gWorldLightPosition; float4 gWorldCameraPosition; struct VS_INPUT { float4…
dk123
  • 15,184
  • 16
  • 63
  • 74
7
votes
1 answer

Can I create a tile engine in a pixel shader?

I am attempting to create a tile engine using a pixel shader and two textures. One texture will hold the tileset and one the map. Is it possible to read the texture data as actual (unsampled) data so I can pull indexes from the map? What is the…
Jason
  • 183
  • 6
6
votes
5 answers

Shader framebuffer readback

I was wondering if there is support in the newer shader models to read-back a pixel value from the target framebuffer. I assume that this is alrdy done in later (non-programmable) stages in the drawing pipeline which made me hope that this feature…
ronag
  • 43,567
  • 23
  • 113
  • 204
6
votes
2 answers

Recreating in a Pixel Shader/Other Method in WPF

Now that (amongst other effects) has been depreciated, I'm looking to see how I could re-create the exact same thing in a Shader Effect (including it's properties of BevelWidth, EdgeProfile, LightAngle, Relief and…
Todd Main
  • 31,359
  • 10
  • 76
  • 141
6
votes
2 answers

Visual Studio Graphics Debugger omits working pixel shader

I'm programming in C#, Visual Studio 2013 Update 5 RC, and using Direct3D 11 (via SlimDX) to render an animated scene. I was experimenting with unordered access textures in the pixel shader and it works nicely. I.e., my pixel shader has an…
6
votes
1 answer

Preventing pixelshader overdraw for a single ERG

Background Using gluTess to build a triangle list in Direct3D9 from a GDI+ DrawString(..) path: A pixel shader (v3.0) is then used to fill in the shape. When painting with opaque values, everything looks fine: The problem At certain font sizes, if…
Sichbo
  • 408
  • 4
  • 8
6
votes
3 answers

Passing colors through a pixel shader in HLSL

I have have a pixel shader that should simply pass the input color through, but instead I am getting a constant result. I think my syntax might be the problem. Here is the shader: struct PixelShaderInput { float3 color : COLOR; }; struct…
Justin R.
  • 21,845
  • 21
  • 102
  • 147
5
votes
2 answers

Pixel shader to project a texture to an arbitary quadrilateral

Just need to figure out a way, using Pixel Shader, to project a texture to an arbitary user-defined quadrilateral. Will be accepting coordinates of the four sides of a quadrilateral: /// 0,0 float2 TopLeft :…
Trainee4Life
  • 2,124
  • 1
  • 19
  • 38
5
votes
2 answers

WebGL/GLSL time variable similar to ShaderToy

Here is my vertex shader attribute vec4 a_position; varying vec4 v_color; void main() { gl_Position = vec4(a_position.xy, 0.0, 1.0); v_color = gl_Position * 0.5 + 0.5; } Here is my fragment shader precision mediump float; varying vec4…
Mudassir Ali
  • 7,053
  • 3
  • 28
  • 58
5
votes
1 answer

DirectX 11 Pixel Shader What Is SV_POSITION?

I am learning HLSL for DirectX 11, and I was wondering what exactly is the SV_POSITION that is the output for a Vertex Shader, and the input for a Pixel Shader. 1: Is this x,y,z of every pixel on your screen, or of the object? 2: Why is it 4 32bit…
Mike5050
  • 535
  • 1
  • 5
  • 17
5
votes
2 answers

How wrap image around cylinder in Silverlight

I am trying wrap image around cylinder in silverlight. I looked a lot in Google but don't found anything. As I know it can be done with pixel shader, but don't know how. Is it possible? Thanks.
1
2
3
20 21