A program running on one of the last stages of the pipeline in a graphics card. Geometry information (usually vertex information) from the earlier stages of the pipeline goes through the rasterizer stage and becomes input to the pixel shader which then generates a single color value as output - the ...
-1
votes
0answers
41 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;
...
0
votes
1answer
30 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
88 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 ...
0
votes
1answer
147 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
116 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 ...
0
votes
0answers
34 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
103 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
148 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
76 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
113 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
97 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
286 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
76 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 ...
-4
votes
2answers
214 views
What shaders make a game look “next-gen”? [closed]
I'm working on a "pretty mod" for a game which adds shaders but doesn't change anything else.
Current shaders are:
1. bloom
2. motion blur
3. DOF
Is there any other kind of filter shader I could ...
3
votes
1answer
181 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
103 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 ...
2
votes
0answers
373 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
376 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
319 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;
// ...
0
votes
0answers
92 views
How to efficiently render resizable GUI elements in DirectX?
I wonder what would be most efficient way to render the GUI elements.
When we're talking about constant-size elements (that can still be moving), the textures' atlas seems to be good.
But what with ...
3
votes
1answer
498 views
In HLSL pixel shader , why is SV_POSITION different to other semantics?
In my HLSL pixel shader, SV_POSITION seems to have different values to any other semantic I use. I don't understand why this is. Can you please explain it?
For example, I am using a triangle with the ...
-1
votes
1answer
201 views
New to CG shader programming, what program should I use to write and test them? [closed]
I have started witting some shaders. First ones were fairly easy to write in notepad but now I need something with a bit more meat. I have checked rendermonnkey that seems to support CG but it is ...
11
votes
2answers
355 views
Do I lose/gain performance for discarding pixels even if I don't use depth testing?
When I first searched for discard instruction, I've found experts saying using discard will result in performance drain. They said discarding pixels will break GPU's ability to use zBuffer properly ...
2
votes
1answer
223 views
How to use Pixel Bender (pbj) in ActionScript3 on large Vectors to make fast calculations?
Remember my old question: 2d game view camera zoom, rotation & offset using 'Filter' / 'Shader' processing?
I figured I could use a Pixel Bender Shader to do the computation for ...
4
votes
1answer
717 views
How do I use screen-space derivatives to antialias a parametric shape in a pixel shader?
In Valve's Alpha Tested Magnification paper, it mentions using "per-pixel screen-space derivatives" for doing anti-aliasing. My understanding is that this is the ddx and ddy intrinsic functions in ...
1
vote
1answer
535 views
Pixel Shader, YUV-RGB Conversion failing
I am tasked with playing back a video hthat comes in in a YUV format as an overlay in a larger game. I am not a specialist in Direct3d, so I am struggling. I managed to get a shader working and am ...
1
vote
1answer
564 views
2D Mask antialiasing in xna hlsl
I have two texture2d , one of these is a mask texture and have 2kind color
and i use that for mask (filter) second texture2D
something like
float4 tex = tex2D(sprite, texCoord);
float4 bitMask ...
0
votes
1answer
168 views
Instancing pixel shader parameters — pass instance data through vertex shader?
I'm working on a deferred shader, and I want to use instancing to draw point lights.
From what I understand, I can send the instance data through the vertex shader and pass it through unchanged to ...
0
votes
0answers
164 views
What's a good way to organize samplers for HLSL?
According to MSDN, I can have 4096 samplers per context. That's a lot, considering there's only a handful of common sampler states.
That tempts me to initialize an array containing a whole bunch of ...
1
vote
1answer
428 views
Need to combine a color, mask, and sprite layer in a shader
My task: to display a sprite using different team colors. I have a sprte graphic, part of which has to be displayed as a team color. The color isn't 'flat', i.e. it shades from brighter to darker. I ...
0
votes
1answer
357 views
Multiple render targets and pixel shader outputs terminology
I'm a little confused on the jargon: does Multiple Render Targets (MRT) refer to outputting from a pixel shader to multiple elements in a struct? That is, when one says "MRT is to write to multiple ...
1
vote
0answers
382 views
Sprite visual effect in XNA?
Suppose I have a character sprite and I want to apply some animating effect that overlay its color, how would I do it? What I desire is something along this line:
(From final fantasy tactics)
It is ...
2
votes
1answer
194 views
isometric tile - How would I apply effect on only specific part of a sprite?
How would I apply a mask for pixel shading effect to restrict it only to some part of image? For example I have a height tile:
Now I want to apply the effect only on the tile-shape of this ...
2
votes
3answers
3k views
Hue, saturation, brightness, contrast effect in hlsl
I am new to pixel shader, and I am trying to write a simple brightness, contrast, hue, saturation effect. I have written a shader for it but I doubt that my shader is not providing me correct result, ...
1
vote
0answers
1k views
How to implement fisheye effect with a GLSL fragment shader
I would like to render my scene with a wide FOV and then apply a fisheye distortion via fragment shader. How would this shader best be implemented?
Update
I try to reproduce a fisheye effect similar ...
9
votes
1answer
561 views
How to create a “retro” pixel shader for transformed 2D sprites that maintains pixel fidelity?
The image below shows two sprites rendered with point sampling on top of a background:
The left skull has no rotation/scaling applied to it, so every pixel matches perfectly with the background.
...
6
votes
1answer
6k views
GLSL - one-pass gaussian blur
It is possible to implement fragment shader to do one-pass gaussian blur?
I have found lot of implementation of two-pass blur (gaussian and box blur):
...
1
vote
1answer
183 views
Why can't a blendShader sample anything but the current coordinate of the background image?
In Flash, you can set a DisplayObject's blendShader property to a pixel shader (flash.shaders.Shader class).
The mechanism is nice, because Flash automatically provides your Shader with two input ...
2
votes
1answer
226 views
Applying effects to an existing program that uses BasicEffect
Using the finished product from the tutorial here.
Is it possible to apply the grayscale effect from here:
Making entire scene fade to grayscale
Or would you basically have to rewrite everything?
...
2
votes
1answer
214 views
Graphic hardware texture formats shaders relational speed
I'm interested to know, is there a direct correlation to the speed that a shader will run based on the bit depth of a texture upon which it is running. For example: If I have a 2 bit stencil texture ...
1
vote
3answers
753 views
iOS - pass UIImage to shader as texture
I am trying to pass UIImage to GLSL shader. The fragment shader is:
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
void main()
{
...
1
vote
1answer
373 views
Sampling from Normal Map and Diffuse Map in Pixel Shader
I'm having some issue changing a basic lighting shader to take a normal texture and a diffuse texture for a model and then using the normal texture for lighting.
The code is very simple and i can't ...
7
votes
5answers
2k views
What rendering techniques would I use to draw a drop shadow effect for cards in a card game?
What type of shading algorithm might be used to create shadows like these?
the one I'm making is similar but it is all done with a 2D drawing API powered by OpenGL so there is no Z coordinate.
In ...
2
votes
1answer
782 views
Why is a fully transparent pixel still rendered?
I am trying to make a pixel shader that achieves an effect similar to this video http://www.youtube.com/watch?v=f1uZvurrhig&feature=related
My basic idea is render the scene to a temp render ...
0
votes
2answers
1k views
How to achieve after-image pixel shader effect
How would one go about writing a pixel shader like this one in XNA 4.0?
http://www.youtube.com/watch?v=f1uZvurrhig&feature=related
1
vote
1answer
626 views
How to set TextureFilter to Point to make example Bloom filter work?
I have simple app that renders some particles and now I am trying to apply the bloom shader from the xna samplers ( http://create.msdn.com/en-US/education/catalog/sample/bloom ) to it, but I am ...
2
votes
1answer
250 views
How to access the nth element in a 2d texture from a pixel shader in XNA
How can I access the nth element in a texture2d from a pixel shader? For example if I wanted to get the 5th vector4 from 10 x 10 texture2d
0
votes
2answers
231 views
What does tex1D do with a 2d texture?
If I call tex1d from my pixel shader on a texture that has been initialized as a texture2d will it treat the data as a one dimensional array and then just take the element at whichever position you ...
6
votes
1answer
213 views
How do texture lookups for trig functions work?
I have a pixel shader that calculates a mandelbrot fractal. It uses the standard formula:
z = z2 + c
I'd like to extend it so the power z is raised by varies. To do this i have the following ...
1
vote
1answer
736 views
XNA - Getting HLSL pixel of current render target?
I'm setting a render target in XNA using the following lines of code:
Game.GraphicsDevice.SetRenderTarget(physicsTexture);
Game.GraphicsDevice.Clear(Color.White);
...
