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

learn more… | top users | synonyms (1)

0
votes
0answers
18 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 ...
0
votes
0answers
23 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 you can see, the limitations ...
4
votes
2answers
135 views

Best way of writing pixel manipuliting-intensive applications with OpenGL/Direct3D

Recently I have been making little experiments with engines similar to old Wolfenstein 3D, Doom and Build, engines where the 3D rendering is entirely done in software and therefore you need full ...
3
votes
1answer
128 views

2D day night mapping

I'm looking for this kind of effect MINUS the lights and snow (Another problem). It needs to change depending on the time of year. Doesn't need snow or city lights. Now I'm pretty new to shaders ...
0
votes
0answers
19 views

In HLSL pixel shader, why am I getting [-256.0, 256.0] values in SV_POSITION input?

My question is basically in my DirectX11 pixel shader, why am I getting a range of values from -256.0 to 256.0 in the SV_POSITION input instead of the supposed values from 0.0 to ViewportWidth and 0.0 ...
0
votes
1answer
48 views

how change branching logic to math equivalent glsl? [closed]

im totally newbie and this just for fun afaik lot of best practice suggest to minimize usage of branching. can you help me optimize below glsl especially on branch part? ( target 120 ) the bgcolor ...
0
votes
1answer
53 views

Sample() returns (0, 0, 0) for normal map 90% of frames

I'm having some trouble reading the values from my Normal map in my lighting fragment shader. The relevant part of the shader code is as follows: Texture2D NormalGB : register(t0); Texture2D ...
0
votes
0answers
39 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: tex2D(TextureHeightSampler, ...
0
votes
0answers
44 views

Shader to mask image with polygon

I'm new to graphics programming and GLSL in particular. I'm working on a 2D game and the setup is as follows: There is an image on the screen (a sprite in the game engine [Cocos2d-x if it matters]) ...
1
vote
1answer
119 views

Tile Map Shader?

I'm trying to write a shader in unity that will take tiles from a sprite sheet and draw them onto a tile map. I'm new to shaders so this might be totally wrong, I think it might just be a math error ...
3
votes
1answer
159 views

How to generate a RGB * a texture for a glow effect in GLSL?

I would like to create a glow effect in GLSL, there is a tutorial that explains how we multiply RGB * a : I have some questions : is it an operation that is in a fragment shader, where RGBa is ...
0
votes
1answer
141 views

How to use a buffer in GLSL to do a LUT-lookup?

I am currently on a medical application which needs different kinds (up to totally individual) lookup tables (LUT) for image display. And this done with 10bit finish. So it is most of the time ...
0
votes
0answers
55 views

DirectX My texture does work in my pixelshader

I got a bit of a mystery as I have a problem that should not be a problem. I am working on a fog feature which is similar to other things that I have done. Not very hard at all. The only real ...
1
vote
1answer
75 views

Calling Shader Functions Inside Other Shaders

I'm new to OpenGL and GLSL, and bit confused about calling conventions of shader functions. I'm trying to implement various procedural noise algorithms in GLSL. I'd like to have separate files for ...
0
votes
0answers
74 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: // Include standard headers ...
0
votes
1answer
63 views

How to combine VAO and shader language?

I'm new and trying to draw a very simple quad with VAO and GLSL. My definitions: typedef struct SPos { float x; float y; } SPos; SPos mVertices[6]; SPos mIndicies[6]; GLuint mVao; GLuint ...
1
vote
2answers
118 views

How to prevent intepolated texture in fragment shader (Unity CG)

Think about minecraft - all the textures in minecraft have a very nice crisp pixelated look. Well, I'm trying to write a shader that will do this but it appears "sampler2d" returns some sort of ...
0
votes
0answers
48 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 frustum. Is there any way I can get a ...
0
votes
0answers
53 views

OpenGL not rendering to correct target

I have a fbo, with 8 textures in it (g-buffer). What I'm trying to do, is to render all information from opaque objects to first four(color, normal, position, depth), and info from transparent objects ...
0
votes
0answers
14 views

How to set up lights in Libqglviewer?

I decided to use Libqglviewer and the simple camera example to have a basic camera setup and play with fragment shading. I have not much experience in OpenGL but I have made my way through it. I have ...
0
votes
1answer
144 views

Fragment Shader output type error

StackExchange! I've been working with opengl for a bit and I'm trying to finally load the shaders instead of having them inline. I'm having a ton of issues, though. As soon as I solve one, another ...
1
vote
1answer
68 views

Is it possible to look up a texel from a texture in GLES2 GLSL framgent shader without using sampler?

Is there some way I can directly access texture memory from fragment shader in GLES2 GLSL? I don't need the sampler to be involved since I am just using it as a look-up table.
3
votes
1answer
189 views

Shadow mapping. I don't understand what to do after creating the depth texture

I'm taking an intro to computer graphics course, so this is something we haven't touched on. I am reading this tutorial ...
4
votes
2answers
1k 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 ...
0
votes
1answer
258 views

3D position of an arbitrary UV coordinate

I have a UV map for a 3D mesh that encodes "links" between pairs of UV coordinates. I have previously defined this links (or pairs), one to one. The links are enconded using the function rgb_color(u1, ...
0
votes
1answer
180 views

2D RGBA texture is gray in GLSL shader

I have a shader to perform LUT coloring of a texture and a c++/c# programs that call it which work perfectly when i use a 1D texture. Since i need to support computers that don't support the 1D ...
17
votes
3answers
2k views

Why is H (blinn) used instead of R (phong) in specular shading?

I can't find a good reason for this anywhere. The reflection vector used in phong has a simple basis in physics. But the half vector used in blinn seemingly has no rational basis, and does not ...
0
votes
2answers
94 views

Best way to detect if vec3 is between vec3(x) and vec3(y) in glsl

As titled I am sampling from a texture and if the color is somehow gray [vec3(.8), vec3(.9)] and an uniform is 1 I need to substitute that color with another one I am not a glsl veteran but I am ...
2
votes
2answers
284 views

Water silhouette shader using GLSL

I have this problem to solve using Cocos2d-x 3.x: In my game there is water represented by rectangle texture, modified by the code on the go. I also have a character moving around, rotating etc. I ...
0
votes
0answers
265 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 ...
0
votes
1answer
564 views

Can't sample texture in HLSL using DX11

Environment: Windows 7 x64 Visual Studo 2012 DirextX11 HLSL Shader Model 5 Ogre 1.9 Okay, so I'm trying to sample a texture in my pixel shader but I'm coming across some strange problems. Here's ...
0
votes
1answer
157 views

How to fix this existing shadow shader/material with alpha textures?

I hope I could get some help here in finally resolving this problem of mine re: shadow casting with alpha textures. Here's a screenshot on what I am hoping for as a result: A friend of mine just ...
1
vote
2answers
129 views

Bad pixels on shader when loading cached binary programs

I have been trying to cache binary shader programs in my game and load them accordingly using "glGetProgramBinaryOES" and "glProgramBinaryOES" respectively. I was successfully able to cache and load ...
0
votes
1answer
928 views

How to change pixel color of Texture with Fragment Shader

I want to change the pixel color of a texture. I don't know where to start and what to add. Really need help, I only find useless snippets in the internet. My current Code: public void ...
1
vote
2answers
1k views

Fast fullscreen quad rendering in Direct3D 11?

For the last few weeks, I've been trying to port a DX9 implementation of HDR rendering (tone mapping, bloom, stars, etc.) over to DX11. I believe I've got all features working but I'm not getting good ...
-1
votes
1answer
173 views

Combine Two Shader Program [closed]

For my android application, I want to apply brightness and contrast shader on same image. At present I am using gpuimage plugin. In that I found two separate program for brightness and contrast as ...
0
votes
0answers
85 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: // Make sure that domain, hull and ...
2
votes
2answers
382 views

Strange if-else branching behavior in a fragment shader

In my fragment shader I have passed an uniform int uLightType variable, which indicates what type of light is in usage right now. The problem is that if-else branching does not work correctly - the ...
1
vote
1answer
308 views

Manually writing a dx11 tessellation shader

I am looking for resources on what are the steps of manually implementing tessellation (I happen to be using Unity CG, but any help is appreciated). Today it seems that it is all the rage to hide ...
1
vote
1answer
58 views

Depth Map resolution shifting

the problem is with shadow mapping as you can see, actually it works fine but in a certain condition that the Depth Map size must be equal to the size of rendering buffer, I use an infinite ...
0
votes
1answer
351 views

Optimizations using GLSL shaders

I have written a simple OpenGL application using GLSL shaders. Actually, my program just displays a simple cube with a phong lighting effect like below : Here's a peace of the client code : ...
1
vote
1answer
50 views

Having trouble setting color in fragment shader

For some reason, the color isn't applying to the object. Here's my fragment shader code. There's probably something obvious wrong with it that i'm not seeing. #version 330 core out vec3 Color; ...
0
votes
1answer
128 views

How does OpenGL determine different outputs with shaders?

Lets say I have this GLSL code: #version 330 out vec4 outputColor; void main() { float lerpValue = gl_FragCoord.y / 500.0f; outputColor = mix(vec4(1.0f, 1.0f, 1.0f, 1.0f), ...
0
votes
1answer
178 views

Normal Map Issues

I'm experiencing a very strange result in my very simple normal map implementation on iOS 7 - OpenGL ES 2.0. I'm only using the bare parameters necessary and I'm also skipping on all the tangent and ...
2
votes
2answers
673 views

3D position to UV coordinates in fragment shader

I am interested in converting an arbitrary 3D position computed at run time in the fragment shader to its corresponding UV coordinates. Notice that the 3D position I am interested in is NOT a 3D ...
1
vote
0answers
113 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
2answers
384 views

gl_FrontFacing - is there perfomance cost?

If I use gl_FrontFacing in my PS, is there any performance cost during vertex transformation (like cross product from triangle vertices), or is this value computed any time ?
1
vote
1answer
281 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
427 views

GLSL blur shader algorithm results in a lumpy blur?

I'm writing a Gaussian blur shader and it's coming along pretty well. However, when I run it on a circle, the result is lumpy. I'm using a simple nested for loop to create the blur. Here's the code ...
0
votes
2answers
235 views

Is there a way to optimize this 2D lighting effect shader? [duplicate]

I'm doing a little 2D game in C++ with Direct3D 11. In the game I want to render a sort of shadow that covers part of the screen: To do this I am using this pixel shader: float4 PS_Main( PS_Input ...