17
votes
Accepted
How to create a spiral brightness gradient
It looks to me like you want something like this:
...
7
votes
Accepted
How does the following code generate a full screen quad?
it doesn't generate a quad, instead it generates a fullscreen triangle.
The outputs end up as:
...
5
votes
Accepted
How can I roll up a plane with a vertex shader?
Here I'm going to assume your geometry is set up like so:
It's a ribbon of quads extending from z = 0 to z = end
The z = 0 line will be the outer lip of the roll, and z = end will be the part tucked ...
4
votes
2D Blizzard/Snowstorm Effect
Making Snow by particle system
as you mentioned in your question you need some noisy windblown.
particle system have part that called noise that you can moving your particles based on noise.
2D Snow
...
4
votes
Accepted
Why do these DirectXMath functions seem like they return column-major matrics?
You posted a column-major version of the translation matrix for (1,1,-1):
1.0 0.0 0.0 1.0
0.0 1.0 0.0 1.0
0.0 0.0 1.0 -1.0
0.0 0.0 0.0 1.0
...
4
votes
Accepted
HLSL MipMap sampling in pixel shader
Sample calculates the mip level to sample based on screen space derivatives of the texture coordinates provided. Derivatives of texture coordinates can be computed as follows:
...
4
votes
How to create a spiral brightness gradient
You can analytically generate the same shader effect. This isn't unity or HLSL code, but you should be able to translate this easily to HLSL, plus it runs in shader toy and you can play around with ...
4
votes
Accepted
How to write shaders that can be compiled for DirectX, OpenGL, and Vulkan
This problem is often solved through the use of a transpiler, a program that can translate a shader written in one language into another.
HLSL2GLSL is one such example that was used in Unity up until ...
4
votes
Accepted
Shader to give the effect of a 2D character covered in oil
I'd like to propose taking some inspiration from the 3D graphics / PBR world. From that perspective, the problem here is that your sprite image combines into a single color value, two different ...
3
votes
Sampled texture from bitmap font produces blue glow
So in true programmer fashion, I solved the issue after being frustrated with it forever. BITMAPINFO stores in ARGB format, not RGBA like I was expected. The solution is just changing the alpha ...
3
votes
What does declaring a const float within a function do? (CGFX)
A const value is never changed after it is initialized. By declaring a const the compiler can do certain optimizations, like calculating the const value at compile time instead of at runtime and ...
3
votes
Accepted
Constant Buffer Alignment issues
Review the HLSL cbuffer packing rules here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules
HLSL packing rules are similar to performing a #pragma pack 4 ...
3
votes
Accepted
Sending light data from Vertex Shader to Pixel Shader?
It's valid, but you have a limited number of interpolators between the two shader stages, and depending how much data you're sending you may bump into that limit. You'll almost certainly need to split ...
3
votes
Accepted
How to sample a TextureCube texture
This doesn't work the way you're expecting because texture slots and sampler slots are decoupled in D3D10/SM4+. So unlike legacy code, you can have a texture at slot x, a sampler state at slot y (and ...
3
votes
Why can't I use the "degrees" character in HLSL comments?
The issue was with the encoding of the file, as it was not encoded in UTF8. Setting it to the UTF8 encoding in VS solved the issue.
If you want to know how to set the encoding in a file in VS, follow ...
3
votes
DirectX11 creating input layout throws error on input signature not matching shader (instancing)
The problem was I was not calculating the number of elements in the CreateInputLayout call. It was fixed at 2 elements.
Incorrect
...
3
votes
Accepted
How would I generate mipmaps for a 3D texture in Unity (at runtime)?
I finally figured out the issue. Unity will automatically generate mipmaps if the fourth parameter of:
...
3
votes
Accepted
Why do you use logarithmic curve to fix distortion of texture?
This comes from trying to make each tile of the image maintain the same width:height aspect ratio as we reduce in size toward the center of the funnel.
Let's take a swatch of this endless pattern, and ...
3
votes
Accepted
What is the proper way to write a pixel shader that only outputs depth?
You don't need to return anything. This is a valid pixel shader:
struct VS_OUTPUT
{
float4 position: SV_POSITION;
};
void main(VS_OUTPUT input)
{
}
2
votes
How do I write to a 16-bit depth buffer using Monogame and HLSL?
First of all, I am not very familiar with monogame specifically, but what I say apply to DirectX 11, which I expect Monogame is using under the hood.
Now, for most cases, you don't need to expicitly ...
2
votes
Run Simple HLSL Pixel Shader with DirectX 9
Since this question has been viewed 1000 times, I might as well post a follow-up.
This is the code I ended up with, processing Avisynth video scripts through pixel shaders.
https://github.com/...
2
votes
Unwanted darkening at polygon edges when using normal maps with SSAO
This is something of a cold case, but I thought I'd take a crack at it.
My answer to the original question "Is there anything obvious wrong with the normals?" is that there does appear to be ...
2
votes
Why doesn't my simple HLSL shader work?
I'm not an expert on semantics (I usually work from templates that have everything I need), so I may be barking up the wrong tree...
But I notice that, for instance, Unity's unlit shader defaults to ...
2
votes
Accepted
2
votes
Accepted
DirectX 11 Compute Shader error DXGI_ERROR_DEVICE_HUNG
This is called a Timeout Detection and Recovery (TDR) error which by default happens whenever the GPU stops responding for 2 seconds or longer--technically when a single driver packet takes longer ...
2
votes
Accepted
Raymarching signed distance function resulting in holes on surface - step size required?
After messing with the Shadertoy link (thank you for that, by the way), I have discovered that most of your problem comes from the line ...
2
votes
Accepted
HLSL float bitfield
Figured it out. The trick is you can clamp an integer between 0 and 1 by dividing 1 by it, to "unpack" it you divide 1 by the result and the way that floats work I think you could technically use all ...
2
votes
Problems implementing shadow maps in directx
When rendering a shadow map, you are rendering the scene geometry from the perspective of the light and the only thing you are trying to get from it is the depth of the scene.
Your pixel shader is ...
2
votes
Figure out why vertices are clipped
Thanks to Ernie for pointing me in the right direction. It was indeed frustum culling that was the problem.
I am using CDLOD and built a quadtree from the heightmap to cull with. All I needed was to ...
2
votes
Convert shader that uses a texture array to ShaderGraph
ShaderGraph generates sourcecode which you can view, copy and paste into a code-based shader, so converting or integrating a ShaderGraph shader into a code-based one is possible. However, the other ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
hlsl × 666shaders × 251
directx × 151
xna × 138
directx11 × 136
c++ × 83
c# × 68
unity × 65
glsl × 52
fragment-shader × 52
textures × 47
monogame × 46
opengl × 31
directx9 × 28
lighting × 24
xna-4.0 × 20
shadow-mapping × 19
compute-shader × 19
sharpdx × 18
graphics × 16
mathematics × 15
geometry-shader × 13
cg × 12
2d × 11
graphic-effects × 11