Questions tagged [hlsl]
A proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.
92
questions with no upvoted or accepted answers
16
votes
0
answers
1k
views
SSAO and normal issues
I'm using a SSAO alghorithm called "SAO", seen here: Scalable Ambient Obscurance.
I'm currently having issues with "smooth" normals, for example when using normal/height maps.
To ...
8
votes
2
answers
454
views
Why isn't my cbuffer updating?
I am really frustrated because my cbufer isn't updating.
This is my VS:
...
5
votes
0
answers
102
views
How inefficient is my ray-box-intersection algorithm?
One of the most critical parts of my raytracer is the calculation of a collision between ray-box which is done following way:
...
4
votes
0
answers
208
views
How do you fix wobbling shadow edges?
I've implemented an omni-directional shadow map and I've noticed a rather unwanted behaviour on the shadows. It seems like when the angle between the occluded points and the light source is really ...
4
votes
0
answers
2k
views
How do I sample a cubic shadow map in DirectX 11?
I've implemented a cubic shadow map for dealing with omni-directional light sources in my scene. By defualt it produces hard shadows
Obviously a shadow map with higher resolution (currently using ...
4
votes
1
answer
732
views
HLSL Buffer<> Data Type
I'm working on converting a dx11 shader from a .fx file for use in Unity3D and I'm a little puzzled by the HLSL Buffer<> type declared in the shader. More specifically, what are these and how can I ...
3
votes
0
answers
194
views
Generate a 2D field-of-view cone
I have a bunch of randomly generated boids flying around on my screen, but I want a function that can give them a field-of-view where they can "see" other boids or obstacles.
The code I ...
3
votes
0
answers
367
views
Trying to get Vertexshader to work Monogame 2D
If I don't use the vertex shader, it gives me white textures which is what the default color is. Once I add the vertex shader, the screen is black.
I figure it is something wrong with the Matrices I ...
3
votes
0
answers
314
views
Reading depth buffer result in only two values
I am attempting to add an SSAO post processing shader to my deferred rendering engine. I am running into problems with reading from the depth buffer. In the images linked below you can see the depth ...
3
votes
0
answers
213
views
Perspective division by zero yields unexpected results
Usually, this is how a shape in clip space is defined:
[0.25, 0.25, 0.0, 1.0]
[0.25, 0.75, 0.0, 1.0]
[0.75, 0.75, 0.0, 1.0]
[0.75, 0.25, 0.0, 1.0]
After ...
2
votes
0
answers
250
views
Creating the Vertices and Triangle Indices for Voxel Generated Mesh
I am running into a problem with a compute shader I am writing to generate the vertices and triangle indices for a voxel generated mesh.
Currently, I am creating an ...
2
votes
0
answers
145
views
DirectX 11 - Problem with low resolution decals
I'm trying to add a decal system in my DirectX engine but i'm facing some problems with the quality of the textures projected. Every other no decal texture look fine, but these ones look really bad.
...
2
votes
0
answers
109
views
Texture shader using model's texture
I'm trying to get a model rendered in monogame using a texture shader. I'm using the code from this tutorial project: http://kgiannakakis.github.io/MonoGameEffects/
I created a simple textured cube ...
2
votes
0
answers
4k
views
How to rotate a 3D instance using an HLSL shader
I'm experimenting a little with HLSL shaders. I have the following code for a vertex shader, it is used to render a few instances of a 3D model. Let's say I want to rotate these instances on their Y ...
2
votes
0
answers
1k
views
tex2Dlod to limit max mip level to use for a texture (atlas)
I'm developing a 3D multitexturing terrain engine in C# on Monogame (XNA) plateform. I would like my engine works on Windows XP or upper, so on DirectX 9c minimum.
Monogame allow me to build a DirectX ...
2
votes
0
answers
761
views
XNA 4.0 Pixel Shader 3.0 Exact Texture Lookup/Sample Issue
I am stuck on trying to solve this problem. I originally had some shaders written that worked for XNA 3.1, but after converting to XNA 4.0 they would no longer compile due to instruction counts, flow ...
2
votes
0
answers
183
views
Stereo 3D: drawing 2D elements at apparent screen depth
I'm developing an application making use of DirectX11's stereoscopic features. At such I am not relying on nVidia's automatic implementation. That means I have to replicate a way to render 2d elements ...
1
vote
0
answers
79
views
How to calculate geometry term from "Multi-Scale Global Illumination in Quantum Break"?
In presentation "Multi-Scale Global Illumination in Quantum Break" from SIGGRAPH 2015, on slide 105, they present concept of geometry term, which is used to help with light leaks in volume ...
1
vote
0
answers
95
views
Generating Shader Includes via script at compile time
I'm experimenting with compute shaders in Unity. A pretty typical thing you wanna do is marshal a buffer of structs back and fourth between C# and HLSL land. Ordinarily you'd have to manually define ...
1
vote
0
answers
49
views
Faster Alternatives to Jacobi Pressure Solving in Navier Stokes Simulation
While Jacobi itself is quite simple it needs at least 10 iterations to produce acceptable results. However that results in a higher total time cost than the rest of the Navier Stokes Simulation ...
1
vote
0
answers
92
views
Setting an array in the HLSL shader
I have a array of six float4x4's in my shader.
cbuffer pseudeocb
{
float4x4 Mypseudo[6];
};
I need to set these in my code.
...
1
vote
0
answers
250
views
In HLSL script, why does random function produce negative values?
I'm currently learning shader scripting with Unity HLSL language and this awesome resource: https://thebookofshaders.com
I created my random method and a zeroOrOne method which just return 0 or 1 ...
1
vote
0
answers
144
views
How can I unpack texture data following a 16 * 8-bit pattern?
Is possible to unpack texture data following a specific bit packing scheme?
I have read that texture data in HLSL can be read in as 4 floats of 32 bits each totaling 128 bits. The packing scheme I'm ...
1
vote
0
answers
217
views
HLSL DXGI_FORMAT_A8_UNORM Texture - dark colors appear less opaque than white
I am trying to render a DXGI_FORMAT_A8_UNORM texture (precisely, a font bitmap) in multiple colors by specifying the color per vertex and then apply the alpha value ...
1
vote
0
answers
75
views
Alpha is not working in diffuse light shader
I am following this tutorials series on rastertek.com and I got a bit stuck on the Diffuse Lighting Tutorial. Particulary, the part that does not work for me is alpha channel of the light color. Here ...
1
vote
0
answers
305
views
Hard coded triangle in CG geometry shader doesn't show on screen
In Unity I'm planning on using a geometry shader for processing points into quads and can't quite figure out why I'm not getting output from my geometry shader. I've edited it down to a minimum ...
1
vote
0
answers
560
views
Is there a quick-reference card for HLSL (DX9 or DX11)?
Does anyone know of a DX9 or DX11 counterpart to the GLSL quick-reference card from Khronos? The GLSL card is pages 8-11 here, and lists preprocessor directives, operators, types, and builtin ...
1
vote
0
answers
159
views
Effective way of transferring data to HLSL shader in MonoGame and storing it
I'm toying around with HLSL shaders in monogame. Lets say I want to use a structure in my shader which is like this:
...
1
vote
0
answers
147
views
dx Shader Model 3.0 break, continue, and loop attributes not recognized
I've been stuck on this problem for just too long. Long story short, the compiler returns "syntax error: unexpected token" for break, continue, [loop], [unroll] and pretty much every other attribute.
...
1
vote
0
answers
66
views
Can sampling an input texture in shader return values updated in same pass?
In my hlsl, (I am using Direct2D helpers which I guess just call tex2D), can D2DSampleInputAtOffset() return a pixel value that was only updated in that same pass ...
1
vote
0
answers
1k
views
How do I set the UV coordinate from a texture value in HLSL?
I have a UV render pass, where RG is the image and B is always set to 255:
I want to set the UV pass texture value to UV Coordinate; when I test it, the result should pixelate noise, like the below ...
1
vote
0
answers
519
views
Logical operations per component in GLSL
According to the OpenGL spec in GLSL, the logical operators: &&, || etc work between booleans, not vectors of booleans.
...
1
vote
0
answers
570
views
HLSL screen-space to world-space
I'm trying to use RenderDoc to understand how a DirectX11 game engine's vertex shader works, and ultimately recover the world-space positions of vertices. I have captured a frame using RenderDoc, and ...
1
vote
0
answers
88
views
Applying two Vertex shaders on two models with the same pixel shader
I want to apply two HLSL vertex shaders on two different models but with the same pixel shader. What I've done is wrong but I don't know how I can use both vertex shaders with one pixel shader (and I ...
1
vote
0
answers
125
views
Open Borders in Fluid / Smoke Simulation
I am trying to adopt a fluid / smoke simulation based of the source files of this video to my needs but came across a few problems when trying to make it open at the borders (flows into the void).
...
1
vote
0
answers
320
views
Issues with 2D raycasting lighting under limitations of HLSL 3.0 pixel shader
I've been writing my own HLSL pixel shader for dynamic lighting using raycasting. Unfortunately, since I'm using this out of XNA, I can only use up to ps_3_0. As ...
1
vote
0
answers
55
views
converting HSLS gives error
I'm using the following parser:
https://github.com/unknownworlds/hlslparser
I also have the following code:
...
1
vote
0
answers
362
views
Blending Lightmaps and Dynamic Texture Shadows in HLSL/GLSL
I'm using Gile[s] as my lightmapper and my engine can execute GLSL/HLSL scripts.
I would like to accomplish something like this for performance reasons. I was told that this technique can only be ...
1
vote
0
answers
549
views
Geometry shader: Dynamic output?
I'm currently using a geometry shader to generate grass blades out of single root points that are layed out in a grid. For each root point, I generate a grass blade with, right now, a constant number ...
1
vote
0
answers
631
views
HLSL - Binary operations
I'm trying to do binary operations with integers in the hlsl code. For example:
int n = 10 & 15;
Binary value of 10 = 1010 and Binary value of 15 = 1111.
...
1
vote
0
answers
158
views
Multi Pass Blend
I am seeking the simplest working example of a two pass HLSL pixel shader.
It can do anything really, but the main idea is to perform "ping ponging" to take the output of the first pass and then send ...
1
vote
0
answers
293
views
XNA HLSL UV Mapping
I was testing my hlsl lighting shader, I've copied it from a tutorial and it works perfectly, but all the meshes in the model needs to have texture coordinate, I guess this is because this part:
<...
1
vote
0
answers
272
views
Pixel Shader : Backbuffer is 'Black'
After Fiddling around I am pretty sure this is not a Shader issue.
Edit 4:
The only diference I can see is that BasicEffect calls these methods before drawing:
...
1
vote
0
answers
1k
views
Using custom functions in HLSL shaders generates extra insructions?
We use forward rendering so our main shader is pretty big (342 instructions). Recently I tried substituting every single custom function I call in the shader with the actual code from that function ...
1
vote
0
answers
2k
views
How does this bezier curve rendering shader determine if a curve is concave or convex?
I have read an article about rendering quadratic splines on a GPU with a shader.
The algorithm is explained like this:
For each quadratic Bézier curve we use Bézier control points of the curve to ...
1
vote
0
answers
289
views
Radiosity using a hemisphere
I'm working on a radiosity processor. I'm projecting scene geometry onto a hemisphere at a high order of tessellation during a visibility pass onto a 1024x1024 render target. The problem is that the ...
1
vote
0
answers
829
views
write to depth buffer while using multiple render targets
Presently my engine is set up to use deferred shading. My pixel shader output struct is as follows:
...
1
vote
0
answers
1k
views
How can I convert between float3 and float2 in HLSL?
I want to offload some 3D calculations to the GPU without raising my requirements to DX10. Specifically, I am generating densities in 64x64x64 3D blocks, which fit nicely into 512x512 2D textures. I ...
1
vote
0
answers
1k
views
Need help transforming DirectX 9 skybox hlsl shader to DirectX 11
I am in the middle of implementing a skybox to my game. I have been following this tutorial http://rbwhitaker.wikidot.com/skyboxes-2. I am using MonoGame as a framework and in order to support both ...
1
vote
0
answers
362
views
Outline Shader Effect for Orthogonal Geometry in XNA
I just recently started learning the art of shading, but I can't give an outline width to 2D, concave geometry when restrained to a single vertex/pixel shader technique (thanks to XNA).
the shape I ...