Questions tagged [fragment-shader]

A program that runs on the GPU to determine output colors for pixels. Also known as a fragment shader.

Filter by
Sorted by
Tagged with
22
votes
2answers
10k views

Do I lose/gain performance for discarding pixels even if I don't use depth testing?

When I first searched for discard instruction, I've found experts saying using discard will result in performance drain. They said discarding pixels will break GPU's ability to use zBuffer properly ...
7
votes
1answer
6k views

How to make a 2D neon-like trail effect in Unity

Recently I've been toying around with neon-ish effects for a game I'm making and wanted to share my results with you. If you guys have any other methods of achieving this result, please be sure to ...
3
votes
1answer
929 views

Multiple pixel shader passes

I currently have a pixel shader that calculates the texture and I have another that calculates the light. I want another shader that does both. What I would ideally like to do is instead of creating a ...
1
vote
1answer
716 views

Unity: cg fragment shader processing array of points

I need to write a fragment shader which would somehow be aware of N points that are in the scene and darken pixels based on their world coord distance to the points. I'm looking for a method that ...
1
vote
1answer
1k views

Color grading, shaders and 3d textures

I'm trying to implement color correction with the 3d lookup table. The lookup table is actually just a 2d texture 256x16 and consists of 16 squares which one is 16x16. When it comes to rendering, I ...
7
votes
2answers
9k views

How to implement color changing fragment shader?

I have a background of a given size and filled with a given color. I want to change it with an animation effect, starting from the center and spread out until it extends the whole background. The new ...
7
votes
1answer
4k views

2D Line drawing with Pixel Shaders

Recently I asked a question, what is the fastest way to render 2D lines using DirectX, and one of the answers mentioned this paper on Fast Prefiltered Lines which uses Pixel Shaders to accomplish ...
3
votes
1answer
8k views

How do I calculate UV space from world space in the fragment shader?

In my vertex shader I have calculated the world space o.worldSpacePosition = mul(unity_ObjectToWorld, vertIn.vertex); How do I convert that world space into uv ...
2
votes
1answer
736 views

How to use Pixel Bender (pbj) in ActionScript3 on large Vectors to make fast calculations?

Remember my old question: 2d game view camera zoom, rotation & offset using 'Filter' / 'Shader' processing? I figured I could use a Pixel Bender Shader to do the computation for ...
6
votes
1answer
441 views

Animating compression wave shader which uses image for displacement map

I've been testing a variety of shockwave or ripple effect shaders, and spent time on this cleaned up and improved version on shadertoy. I'm not entirely satisfied with that because it produces an ...
5
votes
1answer
2k views

How do I achieve supersampling / anti-aliasing in pixel shaders?

I am trying to write a couple pixel shaders to apply to images similar to Photoshop effects. For example this effect: But I noticed there is aliasing in my resulting image (the above image is a ...
5
votes
3answers
8k views

OpenGL additive blending not working as expected

I am trying to achieve additive blending with point sprites. When the sprites overlap, all I get is solid red, when I expect to get a smooth blend from red->yellow->white. My sprite texture has all ...
2
votes
2answers
1k views

How to set multiple times, in a single spritebatch, the same pixel shader parameter

I make a test with Effect class in XNA and I want to set multiple times the same parameters (MyParameter in below code). My code is : ...
6
votes
1answer
538 views

Why does writing to a D3DFMT_R32F render target clamp to 1?

I'm currently implementing a picking system. I render some objects in a frame buffer, which has a render target, which has the D3DFMT_R32F format. For each mesh, ...
3
votes
1answer
388 views

How to access the nth element in a 2d texture from a pixel shader in XNA

How can I access the nth element in a texture2d from a pixel shader? For example if I wanted to get the 5th vector4 from 10 x 10 texture2d
3
votes
1answer
4k views

Depth Intersection Shader

I am trying to create a shader in Unity that shows where intersections occur between objects. Most of the shader I have so far is based off of this youtube tutorial. However, I have made some slight ...
1
vote
1answer
1k views

Has anyone ever made a shader that produces something similar to pixel art?

I find that pixel art is really pleasing to look at; it has this kind of crisp, satisfying perfection to it. I've been following some beginner pixel art tutorials, when I got an idea: what if someone ...
1
vote
2answers
1k views

Ward model implementation: specular component too weak

I'm trying to implement the Ward shading model, the anisotropic, computationally efficient version: This is how I made it: ...
1
vote
0answers
239 views

Cocos2d-x: Differences between applying shader to child node and entire scene?

I'm beginning with shader. I wonder what if i apply shader for single node, what'll happen? The gl_FragCoord = (0.5,0.5) is the bottom left of the screen or the ...
1
vote
1answer
652 views

DirectX11 pixel shader in pipeline is missing

I'm writing a program which displays a MS3D model using DirectX, and unfortunately, the result shows nothing on the screen. When I use the Graphics Debugger from Visual Studio 13, I notice that the ...
1
vote
1answer
1k views

Surface Depth Intersection Shader

I recently asked a question about the creating an accurate Depth Intersection Shader. When creating this in a fragment / vertex shader it could be achieved by the following code ...
0
votes
1answer
509 views

How does OpenGL determine different outputs with shaders?

Lets say I have this GLSL code: ...