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

Change shade of color of each shape

I have the following image and I need to change each shapes color to green but each can have a different shade of green. I am unsure how to do this. I have an idea of how to do it with the whole image by changing pixel color, but not part of the…
code-monkey
  • 236
  • 1
  • 2
  • 11
2
votes
1 answer

Unity 3d Sprite Shader (How do I limit Max Brightness to 1 with Multiple Lights Hitting)

I am creating a videogame in Unity. Every sprite is rendered with a Sprite Renderer with a Material that has the CornucopiaShader.shader. The problem I have is I want to limit the max brightness (or color) of the sprite to just be a normal image of…
2
votes
1 answer

Sample multiple textures and render to multiple textures in same pixel shader

My overall goal is to be able to create a pixel shader that takes multiple textures as input, and renders to multiple targets. As well as via an initialise and finalise shader, through repeated runs of this shader i will get my result. I've created…
George Duckett
  • 31,770
  • 9
  • 95
  • 162
2
votes
1 answer

Use shaders to compare images

Do you know how can I write simple shader (hlsl) to compare two images ? I want to get on result percent of similarity ? Is it posible to use shaders in this case ? Can I for example count red pixels on image with shaders ?
piotrek__
  • 21
  • 2
2
votes
2 answers

Support more than one color input in my Pixel Shader (UWP, Win2D)

I've been working on an app that can provide Color Replacement, and had a lot of help from @Jet Chopper on a solution. He's provided me the following code which essentially uses a ControlSpectrum control for Source and Target colors. The idea is you…
Maximus
  • 1,441
  • 14
  • 38
2
votes
1 answer

How to compile shader fx-file for use in WPF?

I have a Shader.fx-file and want to compile it into a Shader.ps-file that can be used as input to a ShaderEffect in WPF. I'm using the compiler in Windows 10 SDK (fxc.exe) like this: fxc /O0 /Fc /Zi /T fx_5_0 /Fo Shader.ps Shader.fx This works…
Andreas Zita
  • 7,232
  • 6
  • 54
  • 115
2
votes
1 answer

DirectX 11 Diffuse Lighting Implementation

Following: https://www.gamasutra.com/view/feature/131275/implementing_lighting_models_with_.php?page=2 I am trying to implement Diffuse Lighting, but I think I am not understanding something..., and I dont know if I am calculating it correctly. The…
Mike5050
  • 625
  • 1
  • 7
  • 22
2
votes
1 answer

Texture sampler in HLSL does not interpolate

I am currently working on a multi-textured terrain and I have problems with the Sample function of Texture2DArray. In my example, I use a Texture2DArray to store a set of different terrain texture, e.g. grass, sand, asphalt, etc. Each of my vertices…
GameDevAlien
  • 195
  • 1
  • 17
2
votes
1 answer

Weird texture glitch in DirectX 12 when using dynamic indexing

Recently, I implemented the texture loading in my engine. But the textures would have some small glitches sometimes. The problem is shown as the following picture. enter image description here This is tested with AMD R9 380. I also tried to execute…
2
votes
1 answer

Image Processing in WPF

I am designing an WPF application which renders data as a 500x500 8-bit indexed image at 10 frames per second using WriteableBitmap. We would like to add some real-time image processing algorithms to our output, such as 2-D median filtering,…
HW2015
  • 81
  • 2
  • 11
2
votes
0 answers

How to color overlay non transparent SKSpriteNode texture parts withs Swift

I am making a isometric game using Swift and Sprite Kit. I am rethinking my approach about coloring buildings before they are build. Like in every game, before user builds an object, he has to move it to the free plot, and by moving it, node will…
SteBra
  • 4,188
  • 6
  • 37
  • 68
2
votes
2 answers

HLSL for getting cylinder effect

I need to write an application with Silverlight 4 and need to show images like wrapped on cylinder. I need some HLSL code, as I wont to do that with Effects of Silverlight. I don't wont to do that with 3D libarries for silverlight. I only need HLSL…
Samvel Siradeghyan
  • 3,523
  • 3
  • 30
  • 49
2
votes
1 answer

Why won't this HLSL Pixel Shader compile when RWStructuredBuffer is referenced?

I'm using DirectX 12, trying to render using UAVs. Here is my pixel shader code: struct PSInput { float4 position : SV_POSITION; float4 color : COLOR; }; struct FragmentDataStruct { float4 color; float depth; }; struct…
L. Biggers
  • 21
  • 3
2
votes
2 answers

Can't render pixel shader to RenderTargetBitmap! Please help!

I wrote a very simple WPF application to test the ability to render a control that has an associated pixel shader to a RenderTargetBitmap. I then write the bitmap to file (jpeg). The control is rendered onto the bitmap, however the pixel shader…
BigPrimate
  • 21
  • 2
2
votes
1 answer

HLSL: Gaussian Blur Effect

I'm trying to achieve a gaussian blur using post-processing. I have two render passes; first pass renders the scene and the second is used for the effect. This is my pixel shader code: const float offset[] = { 0.0, 1.0, 2.0, 3.0, 4.0 }; …
Salah Alshaal
  • 860
  • 2
  • 17
  • 41