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

Why does this HLSL pixel shader not compile?

I'm working on a ray tracing pixel shader and came across a weird error. I wrote the following code solely to generate the error, it's pointless but I can't figure out what's wrong with it. float4 main(/*Any input*/) : SV_TARGET { uint…
BubLblckZ
  • 434
  • 4
  • 14
1
vote
2 answers

Emulating a nested loop in Pixel Bender for Flash/Flex

I have two vectors of a large, but arbitrary (v1.length need not equal v2.length), number of points, and I want to pairwise multiply them. Because this is the main bottleneck in a large loop of AS3 code, I thought I would try to pull out the code…
Kizaru
  • 2,443
  • 3
  • 24
  • 39
1
vote
1 answer

Why is the later version of Cg compiler producing shader using more instructions?

I have a shader that looks like this: void main( in float2 pos : TEXCOORD0, in uniform sampler2D data : TEXUNIT0, in uniform sampler2D palette : TEXUNIT1, in uniform float …
BЈовић
  • 62,405
  • 41
  • 173
  • 273
1
vote
1 answer

Normal map overrides smooth edges in DirectX 11

My object is a smooth barrel, with only the color and the original normals it looks like this: When I try to add the normal detail via a texture the smooth normals get overwritten like so: Is there a better way to merge the new normal texture…
1
vote
1 answer

How do pixel values behave in DirectX 11 HLSL shaders?

When sampling texel values in a pixel shader, the sampler always returns a float4. However, the texture itself may contain any of a wide number of formats based on DXGI_FORMAT. It seems fairly straight-forward that any of the _UNORM formats will…
Murrgon
  • 375
  • 4
  • 13
1
vote
0 answers

Easier way to use Texture2D array in shader

I want to use Texture2D array by easier way in PixelShader. That is, PS Texture2D map[3] : register(0); if (input.index == 0) color = map[input.index].Sample(samp, input.uv); else if (input.index == 1) color = map[input.index].Sample(samp,…
MC Smile
  • 11
  • 2
1
vote
1 answer

Adding fisheye effect to CG shader for Unity Sprite

I've got a CG shader which scrolls a sprite in a SpriteRenderer in Unity, like so: https://i.stack.imgur.com/2PT1X.jpg The problem is that there's no "bending" on the edges of the sprite, so it doesn't look like the bowling ball is rolling. I'd like…
1
vote
0 answers

Directx 9 Normal Mapping Pixelshader

I have a question about normal mapping in directx9 shader. Currently my Terrain shader Output for Normal Map + Diffuse Color only result into this Image. Which looks good to me. If i use an empty Normal map image like this one. My shader output…
Daros
  • 43
  • 3
1
vote
1 answer

Pixel Shader performance on xbox

I've got a pixelshader (below) that i'm using with XNA. On my laptop (crappy graphics card) it runs a little jerky, but ok. I've just tried running it on the xbox and it's horrible! There's nothing to the game (it's just a fractal renderer) so it's…
George Duckett
  • 31,770
  • 9
  • 95
  • 162
1
vote
2 answers

Cull off parts above the mesh

So, I want to make scene same to this Sphere Scene Now I have mesh with random generation as a ground and a sphere. But I dont't know how to cull off spheres geometry above mesh. Tried to use Stencil, and hightmap. Stencil rendered ground in front,…
Artromskiy
  • 43
  • 5
1
vote
1 answer

C# WPF Brush to Blur the Canvas

I have a canvas in which I add a child image element. On this canvas, I need to draw ordinary lines that will…
Maxim_A
  • 183
  • 2
  • 13
1
vote
0 answers

Issue with a simple Unlit receive shadow shader

I'm trying to write a basic Unlit shader that also receives shadows. The following code below works almost as expected, except that I get a weird dark area as you can see on this image. Can anybody help me to understand what I'm doing wrong? Any…
1
vote
1 answer

Feedback Loop THREE.js

I have implemented a feedback loop (backbuffer) by doing: function render() { renderer.setRenderTarget(BufferA); renderer.render(BufferAScene, camera); renderer.setRenderTarget(null); renderer.clear(); let temp = BufferA;…
Felipe Gutierrez
  • 675
  • 6
  • 17
1
vote
1 answer

Why can't I access matrices in hlsl pixel-shader?

I'm learning how to create effects for wpf using hlsl. I'm currently trying to make a simple effect that marks edges in an image. I want too use the Sobel operator for this, so I set a public float2x3 in my hlsl code, but I can't seem to access…
1
vote
1 answer

Optimize operation between fragment and vertex shader

I am learning to make a graphical engine with OpenGL. I wanted to know, should repetitive operations be moved from the vertex shader to the fragment shader, since from what I understood the vertex shader is only run once per vertex? For instance,…
Oscar Sjöstedt
  • 289
  • 2
  • 10