Questions tagged [fragment-shader]

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

47 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
1answer
549 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, ...
5
votes
0answers
138 views

Raymarching tangents

I've recently started to experiment with raymarching over on shadertoy.com. It seems common to find the normal for a distance field like so: ...
4
votes
1answer
286 views

Weird shader behavior on different devices

I'm trying to combine an ordinary shader with a Single Distance Field shader (for fonts and scalable icons) into one shader program. The idea is simple - if uv.x is less than 1.0, it is drawn as ...
4
votes
0answers
111 views

Writing a leather shader

I'm trying to write a leather material shader. I have a normal map, bump map (grayscaled), specular map, diffuse map, cube maps. I have done the following ...
4
votes
0answers
1k views

How do I sample a cubic shadow map in DirectX 11?

I've implemented a cubic shadow map for dealing with omni-directional light sources in my scene. By defualt it produces hard shadows Obviously a shadow map with higher resolution (currently using ...
4
votes
1answer
614 views

Fog shader camera problem

I have some difficulties with my vertex-fragment fog shader in Unity. I have a good visual result but the problem is that the gradient is based on the camera's position, it moves as the camera moves. ...
3
votes
0answers
159 views

What am I doing wrong, in regards to multi-texture?

I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader. This is the texture part of my OpenGL code: ...
3
votes
0answers
807 views

Unity - reconstruct position from depth

I am using Unity and I want to reconstruct position from depth and frustum corners in pixel shader. I am doing this: In my App, I calculate view-space corners of the far frustum plane and pass them ...
2
votes
2answers
709 views

Why is enabling GL_FRAMEBUFFER_SRGB making the colours brighter?

My understanding of gamma correction is as follows: We want to do colour math in linear space so we can lerp etc. between colour values and get the results we expect. But human eyes don't have a ...
2
votes
0answers
780 views

How can I apply an overlay effect to a sprite in XNA?

Suppose I have a character sprite and I want to apply some animating effect that overlays its color, how would I do it? What I desire is something along this line: (From final fantasy tactics) It is ...
1
vote
1answer
63 views

Rendering colors from a texcoord output

I'm trying to implement a faster alternative to super-sampling for my isometric 2d monogame game (for when the view is zoomed out). The idea was that I would render the texture coordinates to the ...
1
vote
1answer
44 views

How can I make alternate fragments drop (or make them black) based on a checkerboard texture?

How can I make alternate fragments drop(or make them black) based on a checkerboard texture in a Unity fragment shader? I am using forward path rendering in my shader passes for lighting and shadows ...
1
vote
0answers
203 views

Blinking color shader

Currently i'm using Unity3D, and i want to make one variable blink along time in a fragment shader. Now i have code like this: ...
1
vote
0answers
94 views

Artefacts in SSAO Shader

I am having trouble with my Screen Space Ambient Occlusion shader. The objects in the game have the correct occlusion applied to them, however the occlusion flips depending on the angle of the camera:...
1
vote
0answers
168 views

What's wrong with my normal mapping, and how can I fix it?

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 ...
1
vote
0answers
164 views

Draw line around mesh with defined width at cut plane

I want to display a solid line around mesh with a defined width at a cut plane. Currently I realized that using the same method as gl_ClipDistance works using ...
1
vote
0answers
536 views

Passing an UAV to a Pixel Shader in DirectX11

I have a compute shader which task is to take an input image and then blur it using a Gaussian filter approach. The input and output for the compute shader looks like this: ...
1
vote
0answers
42 views

Can sampling an input texture in shader return values updated in same pass?

In my hlsl, (I am using Direct2D helpers which I guess just call tex2D), can D2DSampleInputAtOffset() return a pixel value that was only updated in that same pass ...
1
vote
0answers
686 views

How do I set the UV coordinate from a texture value in HLSL?

I have a UV render pass, where RG is the image and B is always set to 255: I want to set the UV pass texture value to UV Coordinate; when I test it, the result should pixelate noise, like the below ...
1
vote
0answers
252 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
0answers
49 views

Trouble rendering shadowmap for planets

Im currently trying to create a game where you visit planets in LibGDX for Java. To do this I use a TiledMap which is basically just an array of tiles to represent the planets themselves. To get the ...
1
vote
0answers
891 views

Adding an extra Pass to the Unity Standard Shader

I'm experimenting with adding some procedural textures to the unity standard shader. I'd like to add an extra pass (with vert and frag functions), but am unsure about where in the sequence this should ...
1
vote
0answers
745 views

Unity - soft blur effect for dark void edges

I'm a former Flash dev working in Unity (or in 3D for that matter) for the first time. For the game I'm working on, I've designed an interior room like so: To represent void/space outside the bounds ...
1
vote
0answers
168 views

Game Maker - Shader CGA - how to swap the palette

I created a shader that get the actual color of the surface and render it to the closer of a cga palette I have to change it to swap the palette in 4 colors but I don't know how secondary, I have to ...
1
vote
0answers
299 views

Issues with 2D raycasting lighting under limitations of HLSL 3.0 pixel shader

I've been writing my own HLSL pixel shader for dynamic lighting using raycasting. Unfortunately, since I'm using this out of XNA, I can only use up to ps_3_0. As ...
1
vote
0answers
231 views

Pixel Shader : Backbuffer is 'Black'

After Fiddling around I am pretty sure this is not a Shader issue. Edit 4: The only diference I can see is that BasicEffect calls these methods before drawing: ...
1
vote
0answers
196 views

How can I modify my procedural shadows to also show some of the walls?

I'm rendering shadows in Libgdx with the method from this tutorial. I think it's a nice and easy method. I render all my shadows in a framebuffer, then invert it. Before invert: After Invert: ...
1
vote
0answers
202 views

Can't understand the Schlick model formula

I'm trying to implement the Schlick shading model in the fragment shader. I took the formulas from Karsten Schwenk's "a survey of shading models for real-time rendering": First of all I don't ...
1
vote
0answers
815 views

How can I compute spotlight attenuation when I only have a spotlight cutoff angle?

I am trying to compute the spot light attenuation, though I don't have a spotCosCutoff (cosine of the spotlight cutoff angle) predefined variable in the shader so I ...
1
vote
0answers
121 views

How do I align textures properly with an exploding sprite / breakable body?

I'm working on a game based on Box2D and Starling which includes breakable bodies - bodies/objects that when hit with sufficient force break apart (into smaller pieces). I've managed the physics part ...
0
votes
0answers
8 views

Unity mesh shader for outlining colour changes

I've written a shader to change colour on a deformable mesh's Z position. This is to create the effect of topographic/contour maps where the colour changes based on the height of terrain of the mesh. ...
0
votes
0answers
55 views

intersection of primitive in a unit wrapping 3D space

is there people good enough for a math problem (for a shader)? I want to write an algorithm that would intersect primitives (triangles, squares, circle, sphere, cube, cylinder) inside a unit wrapping ...
0
votes
0answers
16 views

Shader intersection radiate outwards

I've been working on a water shader for a project I'm currently working on and have been trying to work on the intersections between objects in the water to create a foam effect that radiates outwards....
0
votes
0answers
21 views

Gamma adjustment slider implementation

Various online sources talk in sufficient detail about gamma correction. By following them, I achieved a rendering pipeline that looks somewhat like this: ...
0
votes
0answers
38 views

I need help debugging this Spotlight implementation

I'm hoping someone can help me debug this wacky implementation of a Spotlight done in Java LWJGL that I found online. Basically, I found the bug, but I cannot figure out how to fix it so that the math ...
0
votes
0answers
36 views

how would I render particle system in a 3D scene in Opengl 3.3

I have a scene that imports .obj (Wavefront) files and I have written the shaders for rendering them in a scene with multiple light sources. Here are my Shaders: Vertex Shader: ...
0
votes
0answers
80 views

Show the edges between the clipping plane and clipped objects

I want to utilize shaders to not only discard fragments if they are on one side of a predefined plane but also render a contour along the intersection. My fragment shader currently does something ...
0
votes
0answers
51 views

Why does this work in the fragment shader but not in the vertex shader?

I'm doing some model view and projection transforms in the vertex shader and I want to determine whether the current vertex will end up on the viewport or not. After searching a bit I found that ...
0
votes
1answer
47 views

Combination Lighting Shader?

I am currently working on writing a shader for combination lighting. The idea behind it is to apply directional light, point light, and spot light in a single pass. I believe I can do this by: ...
0
votes
1answer
107 views

How can I write an additive mesh shader that splits the RGB channels while accounting for depth?

I'm trying to create a sort of "hologram" effect. So far, what I have is an additive, three-pass shader that uses ColorMask for each pass to separate the RGB channels. The problem is that doing so ...
0
votes
0answers
208 views

HLSL sampler always returns white

I'm having an issue with a simple HLSL pixel shader. As a start to writing a lighting engine, I created a point light texture that looks like this. The texture itself is a white -> transparent ...
0
votes
0answers
145 views

Shader - Directional Lights Depth

Is there a way to retrieve the deph from directional lights ? I can access the _ShadowMapTexture but this is not the depth. I found how to access the shadow map of, I think, every light type by using ...
0
votes
0answers
234 views

How to sample png heightmap in HLSL

I am working on simple parallax shader and I have problem with sampling height texture for value. My aproach amples texture and give me RGB values of picture: ...
0
votes
0answers
503 views

opengl shaders getting started problem

I'm following this tutorial for shading in opengl. However I wanted to start with another shader to make things more interesting So this gives me the following code: ...
0
votes
0answers
125 views

Trying to get the fragment shader to output a list

I am trying to figure out a way to get the Fragment Shader to output a list of gl_VertexID-s. I want to use the GPU to get a list of vertices in the viewing ...
0
votes
0answers
823 views

OpenGL shading doesn't work with different projection and view matrices?

I found an online (public-domain) code to do marching cubes, and I am trying to adapt this code to work in my own project. The code uses GLUT and "older-style" OpenGL, whereas I am using GLM and GLEW/...
0
votes
1answer
31 views

PostFX2 Custom Effect's Y position has wrong offset ONLY in GAME camera. Scene camera is OK

I implemented raymarching in a full-screen Post FX2 custom effect. Let's say I'm rendering a SDF sphere at world coordinates 0, 0, 0. Everything is fine in the scene camera -- if I rotate the camera ...