Tagged Questions
3
votes
0answers
66 views
Custom sampling points for anti-aliasing
I'm trying to write an anti-aliasing shader in HLSL, but I can't find any way to rasterize at a custom point. (in between pixels on the screen, but not orderly like supersampling)
Is there any way to ...
1
vote
0answers
102 views
tex2dlod and tex2d giving different values [closed]
I've been having trouble with vertex texture fetch for a terrain system I am implementing. I'm using C++/DirectX9.
I have already implemented exactly what I want as a prototype in C#/XNA and now ...
3
votes
1answer
123 views
Constant Buffer size mismatch on PS, fine on VS and GS
I have the following C/C++ struct:
struct ShadowMapCB {
Math::Matrix4 cropMatrix[4];
Math::Matrix4 textureMatrix[4];
float splitPlane[4];
};
and my HLSL constant buffer:
...
3
votes
2answers
172 views
Which will be faster? Switching shaders or ignore that some cases don't need full code?
I have two types of 2d objects:
In first case (for about 70% of objects), I need that code in the shader:
float2 texCoord = input.TexCoord + textureCoord.xy
But in the second case I have to use:
...
0
votes
0answers
96 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 ...
1
vote
1answer
106 views
Texture the quad with different parts of texture
I have a 2D quad. Let say it's position is (5,10) and size is (7,11).
I want to texture it with one texture, but using three different parts of it.
I want to texture the part of quad from x = 5 to x ...
9
votes
4answers
497 views
Avoid if statements in DirectX 10 shaders?
I have heard that if statements should be avoid in shaders, because both parts of the statements will be execute, and than the wrong will be dropped (which harms the performance).
It's still a ...
5
votes
1answer
424 views
Dealing with alpha for 2D per pixel lighting
Right now I've got a simple light shader. Every bitmap I draw goes through it to make up the scene. I only draw quads.
texture tex;
sampler2D s = sampler_state {
texture = <tex>;
...
4
votes
3answers
313 views
Finding out what pixel on the screen the fragment falls on
In my 2D game, I render tiles. I want to do lighting without needing an extra buffer the size of the screen.
Either in glsl or hlsl, what could I feed to the shader each time I render a bitmap so ...
1
vote
0answers
198 views
Full screen shader causes performance hit
I basically want to have a shader run that can do something like toon shading, or grayscale the whole screen, or radial lighting.
To do this, I create a new bitmap each time the display resizes that ...
0
votes
1answer
117 views
How would I write a shader that supports 2 different texture coordinates?
Hi I am not very good with writing shaders. How would I make a shader that simply supports 2 texture coordinates so I can load up 2 different textures to be used at the same time but on different ...
0
votes
1answer
113 views
My blur gets ugly when radius too high
I have the following h and v blur:
Horz
texture tex;
sampler2D s = sampler_state {
texture = <tex>;
};
int tWidth;
int tHeight;
float blurSize = 9.0;
float4 ...
2
votes
2answers
512 views
My hlsl shader cannot unroll a loop?
I have this shader:
texture tex;
sampler2D s = sampler_state {
texture = <tex>;
};
int tWidth = 1;
int tHeight = 1;
int blurLength = 3;
float4 ps_main(VS_OUTPUT ...
0
votes
0answers
139 views
Porting simple FFP bumpmapping to HLSL
I'm trying to port some antiquated D3D8 Dot3 bumpmapping code from fixed function calls to an HLSL shader. The original code looks like the following:
dev->SetTextureStageState (0, D3DTSS_COLOROP, ...
1
vote
1answer
230 views
screen coordinate not working with pixel values
I have a very simple effect file shown below. I am using this to draw 2D lines, however it is not behaving how I expected and I can't seem to get my head round why.
If I draw a line that goes from ...
4
votes
3answers
1k views
Loading and using an HLSL shader?
I've been looking everywhere and all I can find are tutorials on writing the shaders. None of them showed me how to incorporate them into my scene.
So essentially:
Given an hlsl shader, if I were to ...
13
votes
4answers
2k views
how does HDR work?
I'm trying to understand what HDR is and how it works.
I understand the basic concepts and have an slight idea of how it is implemented with D3D/hlsl.
However it's still pretty foggy.
Say I'm ...
1
vote
1answer
651 views
downsampling algorithm
what are the steps to perform downsampling on a texture ?
I've got as far as rendering the scene to a render target, but I'm not sure as to how to then render that to a smaller texture in order to ...
4
votes
3answers
2k views
Inverting matrix in HLSL
I've got an object in HLSL and I'm using hardware instancing to render multiple copies. But I've come a bit of a cropper when it comes to the vertex normals. Currently I am not using normal mapping ...