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)

1
vote
1answer
26 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
75 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
80 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
99 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 ...
0
votes
0answers
54 views

Shadow wall sight problems

i used this tutorial https://github.com/mattdesl/lwjgl-basics/wiki/2D-Pixel-Perfect-Shadows to make my shadows. I think its a pretty nice and easy method. I render all my shadow in a Framebuffer and ...
1
vote
2answers
109 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 ?
0
votes
1answer
37 views

blend skybox runtime

I use soil to load the cubemaps. the fragment shader uses cubeMap2 as the current cube map. However, I want to change the cube Map based upon an event. My problem is how can I change the cube map. ...
1
vote
1answer
93 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
125 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
118 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 ...
0
votes
1answer
65 views

Why would I lose the D3D device during an HLSL unroll?

I have a pixel shader that downsamples a texture from one size to another. The downsample shader uses a nested 'for' loop to traverse the uv coordinates. When the for loop executes more than four ...
1
vote
1answer
417 views

Shader which supports vertex colors and pixel lights?

From my question at Unity Answers: Hello everyone, I'm facing a bit of a problem here: I need a shader which has the ability to colour individual vertices and be lit pixel by pixel. Until recently, I ...
0
votes
1answer
259 views

problem using glm::lookAt and glm::perspective

I'm trying to change the code from the 22th tutorial at http://ogldev.atspace.co.uk/, using the GLM library, but the result seems wrong. The problem is shown in the below picture: While it should be: ...
1
vote
0answers
81 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 ...
0
votes
0answers
30 views

Strauss model : no specular component [duplicate]

I implemented the Strauss model with the metalness, transparency and smoothness parameters, taking the formulas from the book "Programming vertex geometry and pixel shaders", this is how I implemented ...
1
vote
0answers
385 views

Two pass blur shader using libgdx tile map renderer

I am trying to apply the following technique: blur effect using two pass shader to my libgdx game using the OrthogonalTiledMapRenderer. The idea is to blur the background wich is also a tilemap but ...
1
vote
2answers
163 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: float alphaX=0.5, alphaY=0.5; // asinotropic roughness float ...
0
votes
0answers
56 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 have to compute it myself. This is ...
2
votes
2answers
58 views

Compiling 2 Dimensional Constant Arrays Right into Pixel Shader to use as Lookup Table

I want to use a small 2 dimensional look up table in a fragment shader, but I don't want to pay for the performance cost of fetching it from memory for every fragment. Is it feasible/reasonable to ...
2
votes
0answers
187 views

Ashikhmin-Shirley model implementation: ugly result

I am trying to implement the Ashikhmin-Shirley model using these formulas: This is the GLSL 1.2 fragment shader code: uniform vec4 materialAmbient, materialDiffuse, materialSpecular; uniform ...
1
vote
2answers
252 views

What is the depth that a pixel shader may output? Is it necessary to write Depth?

In DirectX11, what does the depth that a Pixel Shader can output mean? Does a pixel shader need to output a depth so that we "write" the depth? If not, why would we output it? For any doubts, I'm ...
3
votes
1answer
176 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 ...
0
votes
3answers
140 views

directional lightning

I have managed to get a point light working, but I am facing problem with directional lightning. Fragment shader uniform vec4 lightColour ; uniform vec3 lightPos ; uniform float lightRadius ; ...
2
votes
2answers
172 views

How can I remove branches from a fragment shader function?

I have a fragment shader, when I've carefully managed to remove most branching decisions, as I have found out through research here that they are bad. But I have one function that I just can't work ...
0
votes
2answers
84 views

Alpha interpolation in a pixel shader

How does the interpolation in a fragment shader work when it comes to the alpha parameter? I'm programming a shader with SharpDX, DirectX11. My idea is to interpolate 2 3d points of a segment, so ...
1
vote
1answer
80 views

How can I find a position between 4 vertices in a fragment shader?

I'm creating a shader with SharpDX (DirectX11 in C#) that takes a segment (2 points) from the output of a Vertex Shader and then passes them to a Geometry Shader, which converts this line into a ...
3
votes
4answers
427 views

How many times fragment shader is executed?

I have an OpenGL code, with 3 different shader programs. I have a simple question, I know fragment shaders are executed for every every fragment in the scene. But is there a way using which we can ...
2
votes
2answers
479 views

Computing pixel's screen position in a vertex shader: right or wrong?

I am building a deferred rendering engine and I have a question. The article I took the sample code from suggested computing screen position of the pixel as follows: VertexShaderFunction() { ... ...
0
votes
1answer
132 views

Why i can not load a simple pixel shader effect (. fx) file in xna?

I just want to load a simple *.fx file into my project to make a (pixel shader) effect. But whenever I try to compile my project, I get the following error in visual studio Error List: Errors ...
1
vote
1answer
234 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 ...
1
vote
0answers
75 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
1answer
167 views

Creating a fragment shader to darken a white texture over time - OpenGL GLSL

So as a part of learning OpenGL, I've now decided to try and be a bit more creative with shaders, as part of a practice game I'm making using C/OpenGL. I'm completely new when it comes to working ...
2
votes
3answers
657 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 ...
7
votes
2answers
3k views

GLSL Shader - Change Hue/Saturation/Brightness

I'm trying to change the hue of an image using a GLSL fragment shader. I want to achieve something similar to Photoshop's Hue/Saturation Adjustment layer. In the following image you can see what I've ...
4
votes
1answer
606 views

using heightmap to simulate 3d in an isometric 2d game

I saw a video of an 2.5d engine that used heightmaps to do zbuffering. Is this hard to do? I have more or less no idea of Opengl(lwjgl) and that stuff. I could imagine, that you compare each pixel ...
0
votes
1answer
70 views

Vertex and Fragment Shader worldNormal

How to access/calculate worldNormal in a Vertex and Fragment shader ? Thanks a lot !
9
votes
1answer
309 views

How do I implement 2D shadows cast between layers?

How could I implement 2d shadows that are cast by objects in a different layer? NOT like the dynamic lighting in the well known tutorial from Catalin Zima : But like the shadows of the pipes in ...
0
votes
1answer
117 views

Per-fragment lighting system behaves like ambient lighting system

This is the relevant section of my fragment shader varying vec3 normal; varying vec3 halfv; ... vec4 color = ambient * gl_LightSource[0].ambient; vec3 n = normalize(normal); float ...
2
votes
0answers
90 views

Writing to a D3DFMT_R32F render target clamps 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, I set an integer constant ...
4
votes
1answer
189 views

Better solution for boolean mixing?

Sorry if this question has been asked in the past, but searching Google and here didn't yield relevant results, so here goes. I'm working on a fragment shader that implements both conditional/boolean ...
1
vote
1answer
780 views

Volumetric Fog Shader - Camera Issue

I am trying to build an infinite fog shader. This fog is applied on a 3D plane. For the moment I have a Z-Depth Fog. And I encounter some issues. As you can see in the screenshot, there are two views. ...
1
vote
1answer
294 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. ...
1
vote
2answers
57 views

Defining lines from a heightmap

To a pixel shader of a 2D game, I'm passing a 1-row heightmap that holds the height in UV coordinates of evenly distributed points throughout the texture I'm drawing, but as for n points there will ...
0
votes
2answers
1k views

cocos2dx - Custom Fragment Shader and CCRenderTexture

I have a CCRenderTexture that is filled with a sprite when the scene is loaded, as follows, canvas = CCRenderTexture::create(this->getContentSize().width, this->getContentSize().height); ...
2
votes
1answer
185 views

What is the interval of fragment-shader code execution?

Without any intended delay, is the code of a fragment-shader run once per frame? If not, how often will the code be executed? (I'm new to shaders: I'm talking about glsl if it makes any difference)
3
votes
2answers
142 views

Opengl shader questions

I'm currently building a shader that takes a 2D texture sampler and uses UV coordinates to map it. This works fine for all textured objects. However, I'm having a bit of a problem as I'm trying to ...
2
votes
2answers
229 views

3D Distortion Effect

I'm trying to make a distortion effect similar to this: However I'm not making a 2d screen space effect. I'm applying it to a 3d scene and I want it to be placed IN the world, so it can be blocked ...
7
votes
1answer
388 views

GL ES: Fragment shader optimization

Summary: I get FPS slowdown as soon as I try to tint the sprites (i.e: multiply texture with color in the fragment shader) Details: Hardware: iPod touch 4 I am drawing 700 sprites on the screen ...
0
votes
1answer
94 views

Shader registers for different graphics card

The title is not very explicative, so i'll try to make myself clear. I have two "working"(on which i work on) PCs : a desktop that runs an NVIDIA GT440 an a laptop with a RADEON HD 4650. I have a ...
2
votes
1answer
97 views

What is a Fragment Pipe?

I remember someone saying "24 fragment pipes on nVidia 7800" in a presentation. Am I correct in saying that a fragment is the data that can generate a pixel in the frame buffer? Or are fragments the ...