A program that runs on the GPU to determine output colors for pixels. Also known as a fragment shader.
1
vote
1answer
75 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
74 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
92 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
51 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 ...
0
votes
1answer
139 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
105 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:
...
0
votes
0answers
69 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
161 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
106 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
49 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
46 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
117 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
148 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 ...
2
votes
1answer
146 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
127 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
132 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
67 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
75 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
352 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 ...
1
vote
2answers
192 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
86 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
196 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
65 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
153 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
424 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
2k 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
454 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
65 views
Vertex and Fragment Shader worldNormal
How to access/calculate worldNormal in a Vertex and Fragment shader ?
Thanks a lot !
9
votes
1answer
283 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
103 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
81 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
162 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
627 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
219 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
55 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
984 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
167 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
137 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
193 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
323 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
76 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 ...
7
votes
1answer
624 views
Optimizing performance of a heavy fragment shader
I need help optimizing the following set of shaders:
Vertex:
precision mediump float;
uniform vec2 rubyTextureSize;
attribute vec4 vPosition;
attribute vec2 a_TexCoordinate;
varying vec2 tc;
...
1
vote
1answer
64 views
I have a frag shader, one with an empty s_lightMap, how and why is it effecting the output?
I have an image of concrete rocks of different shades of colors, and I'm applying this shader, but without referencing s_lightMap's uniform in my program:
precision mediump float; ...
0
votes
1answer
85 views
Weird rendering issue when applying lightmap through HLSL
I have a weird issue when trying to render the lightmaps in my game.
Please see the following screenshots.
Note how the scene looks up close with the lightmaps enabled.
Note how that same part of ...
2
votes
2answers
338 views
Realtime fisheye to cubic or spherical panorama transformations with OpenGL or pixelshaders
I'd like to transform a sequence of circular fisheye-images to cubic or spherical panorama images to be used in a panorama-viewer based on OpenGL. The viewer-part is nemas problemas but the transform ...
1
vote
1answer
288 views
GL_EXT_shadow_samplers killing my shader
I have the following fragment shader for my scene
#extension GL_EXT_shadow_samplers : require
...
vec4 color = texture2D(uTextureUnit0, varTexCoord0);
if (colorTransformEnabled != 0) {
vec3 ...
0
votes
1answer
101 views
How to alter the angle of texture projection
I'm currently working on a 3Dish game; it's on a grid, with 3D props and the camera looking down on the grid at about 45º, but I want to use 2D sprites for the player and NPCs.
Currently, I'm using a ...
1
vote
1answer
831 views
How to do Triplanar Texturing
Ok maybe i'm missing something because its getting late and i've been programming now for about 72 hours straight (minus a nap or 2) ...
I'm trying to write a shader for unity that will apply ...