A program that runs on the GPU to determine output colors for pixels. Also known as a fragment shader.
2
votes
2answers
92 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
53 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
60 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
306 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
91 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
61 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
128 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
58 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
115 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
238 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 ...
6
votes
2answers
1k 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
326 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
63 views
Vertex and Fragment Shader worldNormal
How to access/calculate worldNormal in a Vertex and Fragment shader ?
Thanks a lot !
9
votes
1answer
228 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
86 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
69 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
131 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
482 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
157 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
52 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
677 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
153 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
133 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
165 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
234 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
70 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
92 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
473 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
60 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
68 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
291 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
227 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
94 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
637 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 ...
1
vote
1answer
263 views
Pixel Shader - apply a mask (XNA)
I'd like to apply a simple few masks to few images.
The first mask I'd like to implement is mask like:
XXXOOO
I mean, that on the right everything is masked (to black), and on the left everything ...
2
votes
1answer
84 views
Best approach to depth streaming via existing codec
I'm working on a development system (and game) intended for games set mostly in static third-person views. We produce our scenery by CG and photographic techniques. Our background art is rendered ...
1
vote
0answers
298 views
How to 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: ...
0
votes
1answer
368 views
How to create a fog effect in XNA with PixelShaderFunction?
I developped a small XNA games in 3D.
I would like to add a "fog of war" on my models instantiated with an effect in my (.fx) file.
The problem is, I do not know how to change the function
...
0
votes
1answer
231 views
Incorrect colour blending when using a pixel shader with XNA
I'm using XNA 4.0 to create a 2D game and while implementing a layer tinting pixel shader I noticed that when the texture's alpha value is anything between 1 or 0 the end result is different than ...
4
votes
0answers
178 views
Premultiplied Alpha And Alpha Testing
I have a shader that is supposed to work with either alpha blending or alpha testing, but the color values being passed in are premultiplied alpha values.
Is there an easy/standard way to have it ...
1
vote
2answers
280 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 :
[...]
//In Engine class
Effect ShaderEffect = ...
9
votes
3answers
403 views
Outline sprites
I'm currently working on a 2D game, and my current task is to outline selected object.
I basically use a blur shader to do it fully runtime.
I first draw my sprite using a vertical gaussian blur ...
0
votes
2answers
128 views
The saturate function is not working in my pixel shader
I wrote a pixel shader for my game and when I tried to compile it an error occurred:
ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
When I removed all the saturate ...
2
votes
0answers
77 views
Fragments never falling into spot light's cone
I am using GLSL version 1.20 with OpenGL 2.1 .
I am trying to compute when a fragment falls into the area of a spot light. I have already set all the light values with glLightfv and glLightf, also ...
3
votes
1answer
217 views
Per Instance Textures, and Vertex And Pixel Shaders?
How do you implement per instance textures, vertex shaders, and pixel shaders?
Given:
1. Two different model templates in Vertex Buffer, Square & Triangle
2. Instance Buffer with [n] instances of ...
0
votes
2answers
146 views
How to implement input-texture limited alphablending of 2 textures with HLSL?
I try to implement a HLSL shader the does the normal Alphablend with premultiplied colors (just as XNA4 does) but depending on some existing colors. One can think of adding a glow to a 2D terrain ...
3
votes
0answers
697 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 ...
1
vote
1answer
600 views
XNA HLSL 2D outline shader
I have gotten into quite a bit of trouble getting my rendering correct in my tile based 2D game.
This kind of shader is surprisingly annoying to write, I've heard (we used it in one of our 3D ...
0
votes
2answers
501 views
HLSL shader optimization [closed]
The following HLSL shader (without preprocessing) results in 65 arithmetic operations (see below). Can the same effect achieved with <=64 operations?
// Center of "light"
float x;
float y;
// ...
1
vote
1answer
296 views
Apply portion of texture atlas
I'm trying to write a shader that only maps a portion of a large texture to my sprite and I'm getting a strange behaviour with my current code.
This is what I have right now:
Texture atlas ...