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

CG: what's wrong with my per-pixel lighting?

i try to do basic n-dot-l lighting in unity and CG. to my understanding the lighting should not change depending from where you look at the object with your camera. but in my situation it does. struct v2f { float4 pos :…
clamp
  • 33,000
  • 75
  • 203
  • 299
0
votes
1 answer

Show only part of texture

I have transparent circle, and i want to make able to show only a small parth of it by shader, for example from 30 degrees to 90 degrees, my idea is to get he’s origin point from fragment the pass it to vertex to make it more “clean” by doing this…
user9673893
0
votes
2 answers

Actionscript 3: Any way to get data to and from a local program?

I've recently been constructing a pixel shader to apply shading to the player-character in a Flash game I'm currently coding for. As it turns out, however, Actionscript 3 is... Not handling this gracefully, and the framerate hit is pretty huge. What…
0
votes
1 answer

Why is there a non-smooth reduction in intensity for attenuated light?

I'm trying to implement light attenuation in a Phong shader. The pixel/fragment shader does the following calculation (per light source): float3 refl = reflect(e, n); float dist = length(L.xyz); float3 l = normalize(L.xyz); float attn = 1.0 / (1.0 +…
user1803551
  • 12,965
  • 5
  • 47
  • 74
0
votes
0 answers

Changes to Pixel Shader aren't being Saved

I'm working on a DirectX program (I'm not using any wrappers). I'm trying to make a Pixel Shader. I made some changes to the Pixel Shader, it is not reflecting in the code when it is running. This is the code I wrote for the Pixel Shader. (It is…
0
votes
1 answer

Tex2D returns interpolated values when off pixel center in HLSL

The Tex2D function returns interpolated values when off pixel center ((0.5, 0.5) for instance), this is really a problem when you have a large texture like 1920x1080. I have an HLSL pixel shader that first samples a small image, then calculates the…
Martin
  • 335
  • 4
  • 13
0
votes
1 answer

My "perlin" noise effect shader produces either all-white or all-black

I'm trying to code a "perlin" noise shader in NVidia FX Composer. However, no matter how I tweak the noise function, it returns either 100% white or 100% black. I have no clue how to solve this or even where the problem is. Edit: If you've seen This…
Narf the Mouse
  • 1,541
  • 5
  • 18
  • 30
0
votes
2 answers

Turn off color ranges in Pixel Bender

What is the best way to turn turn off (using PixelBender) colors that fall within a certain range. For example, turn off all colors between 0x0000FF and 0x00FFFF. Thanks for your help. This has to work in Flash. Thanks!
Andrei Taraschuk
  • 579
  • 1
  • 5
  • 23
0
votes
0 answers

Inverting texture color with AGAL

I've been using the Genome2D library and wanted to create a filter that inverts all color. After reading Adobe documentation, I can't seem to figure out what's going on with the alpha channel since .rgba doesn't even seem to work. This Genome2D…
dinorider
  • 191
  • 10
0
votes
1 answer

Shader inputs to registers mapping

I have a compiled pixel shader 4.0 (I don’t have source code for that), with the following in the input signature: // Name Index Mask Register // TEXCOORD 4 xyz 4 // TEXCOORD 8 w …
Soonts
  • 20,079
  • 9
  • 57
  • 130
0
votes
0 answers

What's wrong with my Normal mapping? C++ Directx

Hi guys' I'm trying to implement Normal Mapping in Directx and I'm very close to creating it but I'm getting these weird black colors on some objects. This is how it looks like without the Normal Mapping: And when I apply the Normal Mapping effect…
Awni
  • 41
  • 1
  • 5
0
votes
1 answer

DirectX 11 What is a Fragment?

I have been learning DirectX 11, and in the book I am reading, it states that the Rasterizer outputs Fragments. It is my understanding, that these Fragments are the output of the Rasterizer(which inputs geometric primitives), and in-fact are just…
Mike5050
  • 625
  • 1
  • 7
  • 22
0
votes
1 answer

How to change this shader to solid color?

I tried changing "float4 Color: COLOR1" but didn't help because it's for Diffuse or specular color. I don't know what else to do, I don't know what to add. I ran out of ideas. HRESULT GenerateShader(ID3D11Device* pD3DDevice,…
Evilminator
  • 3
  • 1
  • 2
0
votes
1 answer

Inputting Position Into the Pixel Shader

In most of the programs I have seen that make use of vertex position data in the Pixel Shader, there is a tendency to process it as a float4 vector. This restriction does not appear to be present fin the other shaders. In the program that I am…
NAKASSEIN
  • 45
  • 1
  • 6
0
votes
2 answers

Metal kernel shader -- fade implementation

I haven't written many Metal kernel shaders yet; here's a fledgling "fade" shader between two RGBX-32 images, using a tween value of 0.0 to 1.0 between inBuffer1 (0.0) to inBuffer2 (1.0). Is there something I'm missing here? Something strikes me…
zzyzy
  • 973
  • 6
  • 21