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
0
votes
2 answers

D3D12 Dynamic indexing of textures with different formats

In shader model 5.1 we can use dynamic indexing for textures like so: Texture2D textures[5] : register(t0) PixelShader(Input p) : SV_TARGET { float4 color = textures[0].Sample(someSampler, p.UV); return color; } Here it's assumed that all…
rashmatash
  • 1,699
  • 13
  • 23
0
votes
1 answer

Comparison operations in HLSL

I am reading through a HLSL implementation of CSM shadow mapping and have come across a line of code i don't quite understande float3 pos; float3 CascadeDistances; ... float3 weights = ( pos.z < CascadeDistances ); Can someone please tell me what…
Steve Medley
  • 151
  • 3
  • 7
0
votes
1 answer

about pixel shader input buffer

I'm using VS2015, directx11 Here's my Vertex Shader code. cbuffer cbperobject { float4x4 gWorldViewProj; }; struct VertexIn { float3 Pos : POSITION; float2 tex : TEXCOORD0; }; struct VertexOut { float4 PosH : SV_POSITION; …
0
votes
1 answer

PSSetSamplers doens't work (The Pixel Shader unit expects a Sampler)

I'm very new at directx11, and I wanted to add texture to a shader I'm using. (until now, I hadn't used any texture yet in directx11) But sampling doesn't seem to work (it's always float4(0,0,0,0)), and I get the warning: "D3D11 WARNING:…
Stef
  • 315
  • 3
  • 14
0
votes
0 answers

What pixel shader can I use to remove a background color, but keep transparent pixels?

I can use a pixel shader in WPF to remove a specific color, but there are alpha pixels layered over the background. I want to remove a background color, but keep alpha pixels. For example, I have Image 1. It is a red rectangle with opacity 50%…
Ziya Jafarov
  • 41
  • 1
  • 6
0
votes
1 answer

GLSL ES update object positions

lately I've been working on a per pixel point light shader. And it all works perfectly as it should, for the exception that if I change the position of a model, the position itself doesn't seem to update in the shader. Some information that could…
0
votes
0 answers

adobe pixel bender(.pbk) range of colors between two colors

I am new to pixel bender. I am programming with as3. I want to do a green screen calibrator. I have manage to turn one rgb(Hex) color alpha to 0 with shader filter (with online search): { input image4 src; output pixel4 dst; parameter…
0
votes
2 answers

Applying a pixel Shader to a texture within a sprite with SlimDX Direct3D9

So, I am very new to Developing with DirectX, I'm slowly getting there... But! I have this which instantiates the Direct3D9 runtime, creates a device and loads a Pixel Shader. - I can confirm the Pixel shader is loaded as 1) it works in other…
0
votes
0 answers

Why won't this shader work?

I have managed to implement a garoud shader with specular lighting efects in Processing 3.0 . Now I am trying with a fragment Phong shader but cannot make it work. I can´t find where is the error. Sketch: import java.io.*; PShader…
eneko
  • 333
  • 4
  • 14
0
votes
2 answers

How to create a diagonal HLSL transition shader

I am trying to adapt the code from a couple of the HLSL shaders in the WPF Pixel Shader Effects Library on Codeplex to create a pixel shader which creates a diagonal transition from Texture1 to Texture2 by sliding Texture2 across Texture1 as if it…
Ian Carson
  • 139
  • 1
  • 10
0
votes
2 answers

Photoshop PhotoFilter pixel Math

Has anyone used the photo filter in Photoshop? Edit > Adjustments > Photo Filter... It produces a really nice image tint that I've been unable to reproduce with blending modes. Has anyone got any idea of the pixel maths behind this filter? - So I…
Rob
  • 1,687
  • 3
  • 22
  • 34
0
votes
1 answer

change specific pixel color via fragment/pixel shader?(opengl)

Is there any way to change specific pixel color via fragment/pixel shader? (like a uniform variable?) To be specific, im trying to implement ray-traced shadows.
J Frap
  • 9
  • 4
0
votes
1 answer

Strange way of declaring variables in hlsl

I found this example of implementing Phong lightning in hlsl. It is first snippet where I see that strange syntax where you declare variables in hlsl like here: float3 materialEmissive : EMISSIVE; float3 materialAmbient : AMBIENT; In usual instead…
bartosz.baczek
  • 1,567
  • 1
  • 17
  • 32
0
votes
1 answer

Invisible edges when applying pixel shader to model

I am currently working on a simple shader in hlsl. What I am trying to achieve is 'highlight' effect when cursor is placed on the object in my screen. My issue is that, the pixel shader doesn't work correctly: In the picture number 1 there is an…
bartosz.baczek
  • 1,567
  • 1
  • 17
  • 32
0
votes
1 answer

Implementing D3DCompileFromFile in VB.NET gives me a "has unbalanced the stack." error

I have taken parts of the code from Shazzam Shader Editor (http://shazzam.codeplex.com/) and modified the code to use the Compile From file instead of memory (https://msdn.microsoft.com/en-us/library/windows/desktop/hh446872(v=vs.85).aspx) …