Questions tagged [hlsl]
A proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.
666 questions
0
votes
1
answer
111
views
URP Maximum Sample Index (16) with Light Cookie Input
I just recently imported a new asset package, all of the materials use the URP lit shader, no custom shaders. However, now I can't build the game because I keep getting the same errors:
...
0
votes
0
answers
35
views
HLSL Automatic Root Signature Creation
I know of two different ways to specify a root signature in DX12, and those are:
Creating one with D3D12_VERSIONED_ROOT_SIGNATURE_DESC and ...
0
votes
1
answer
218
views
Decompiling a DXBC - why is an integer operation working with a massive float?
I'm decompiling a game's shaders with RenderDoc in an effort to understand them, and I encountered this segment:
...
0
votes
1
answer
113
views
What is the proper way to write a pixel shader that only outputs depth?
I have an effect that I want to only write to depth.
commandList->OMSetRenderTargets(0, nullptr, FALSE, &m_mainDepthStencilDescriptorHandle.getCpuHandle());
...
0
votes
0
answers
40
views
Can we use geometry shader to allow or not the drawing based on a stencil value?
I have a forward reflexion protocol producing a reflexion map used for final scene rendering. I can have several heights of ground we can defined as "mirrors". In order to have only one map ...
0
votes
0
answers
54
views
How does SamplerCmp works compared to Sample (PCF shadow blur)
I'm doing 3x3 PCF blur with either Texture.SampleCmp (from CascadedShadow demo in DX11) or Texture.Sample (DX11 SM5) like this
...
0
votes
2
answers
225
views
Difficulty for using asfloat/asuint
I'm trying to convert a RGB color to a RGB555 format to be saved as a float in a R16F or R16UNORM texture.
I have a method that works quite well using only float maths for both types of surface but I ...
0
votes
1
answer
88
views
Advice on how to best use if possible 4 GatherCmpRed to emulate a 4x4 PCF sampling for shadowmap blur
In a part of my level I have shadows close to the camera where a good blur is important. Currently I have implemented a 4x4 PCF, thus requiring 16 texture samplings.
I'm trying to see if the ...
0
votes
1
answer
74
views
Shadow artifact with cubemap shadow for pointlights
I am facing some difficulties with the use of a cubemap shadow associated to a poinlight (represented as the yellow bicone in the picture). The shadow map itself is generated properly (see picture).
...
0
votes
1
answer
82
views
Generate Frustum from Clip Rectangle after Projection
I have an arbitrary Clip Rectangle, ranging from -1 to 1 which was obtained by min/maxing vertices after projection.
I want to cull triangles in a compute shader against this particular rectangle.
...
2
votes
1
answer
224
views
How to sample a R8_UINT texture in hlsl?
I'm a newbie in DX12 and trying to visualize Stencil buffer onto screen. I've been copied stencil plane slice into a DXGI_FORMAT_R8_UINT texture, but when HLSL samples this texture it just returns 0, ...
0
votes
0
answers
110
views
Blending/gradient/smoothing between textures in Texture2DArray in HLSL shader
Well, I have this triplanar shader:
...
0
votes
1
answer
264
views
How to check input/output data for shaders in Renderdoc?
How can I check whether my vertex and pixel shaders' input and output have data in Renderdoc?
I have a problem with my pixel shader when I try to include input color. I get a black screen. When I ...
1
vote
1
answer
498
views
Use DirectX 11 & HLSL in SDL
I saw Lazy Foo using OpenGL & GLSL in SDL, but I want to use DirectX 11 & HLSL in SDL.
Is there a way to do this, and how?
1
vote
0
answers
80
views
Incorrect Screen Space Reflection help
I'm leaving a question because I ran into a problem while implementing screen space reflection.
The way I do it is by sampling the position and normal map saved with deferred rendering, changing it to ...
2
votes
1
answer
159
views
Why do you use logarithmic curve to fix distortion of texture?
I'm a noob shader learner, and I came across this question about animated shaders in Unity: Animated textures for models; How to write a shader?
After reading the answer, I kind of understood the ...
0
votes
1
answer
212
views
GLSL ported shader not working in HLSL
I have been working on an Infinity Grid shader for my engine.
It was already implemented to Vulkan’s GLSL, so it worked great with OpenGL’s (4.6) GLSL.
Here's a reference.
This basic shader with ...
0
votes
1
answer
309
views
Shader to give the effect of a 2D character covered in oil
I have a 2D pixel art game where characters can be covered in a flammable black oil-like substance and I am looking for a simple way to depict that visually.
Simply tinting the character black won't ...
0
votes
0
answers
397
views
Depth Map doesn't work in 2D URP
This is a further question from my last, originally I was trying to change the way the depth map is rendered per-pixel. However, through more testing, I've found that actually it has nothing to do ...
0
votes
0
answers
61
views
1
vote
1
answer
152
views
Issues with binding structure layout in the shaders which translated from glsl to hlsl
I have a small issue with my shaders. Sorry if it is not the right place for this question. In general, the essence is that for my application on dx12, I have shaders in glsl (I'm too lazy to rewrite ...
1
vote
0
answers
129
views
Can you append values to an appendbuffer and then immediately read from that same buffer?
I am looking to achieve the following: I have a compute shader that receives a Texture2D as input, where a small percentage of the pixels in the texture are white. ...
4
votes
0
answers
144
views
Simple shader to draw lights on a skyscraper
I have some basic shapes in the background of a scene that represent a small city. There is a stage where the scene becomes a nights scene. I would like to have the city come to life at night with ...
3
votes
1
answer
363
views
How would I generate mipmaps for a 3D texture in Unity (at runtime)?
I have been trying to create a voxel cone tracer for Unity (in Universal Render Pipeline 16).
I have this (unoptimized) C# code that turns the [CubeScale] area around 0,0,0 of the scene into a 3D ...
0
votes
1
answer
603
views
How to use gather offsets
I have this situation where I have parts of the same scene in each 4 half squares of a rendertarget rendered with the same view projection matrices. In my deferred pipeline I would like to sample with ...
0
votes
1
answer
462
views
Iterating through every pixel in a shader - skipping pixels
I made the below shader to draw a mesh for every pixel on a texture, and color it with that pixel.
It iterates through the pixels, correctly drawing and coloring the mesh instances. However it skips ...
2
votes
1
answer
2k
views
How to support Texture Tiling + Offset for custom shader
I've written a custom shader (with help) and I'm not sure why it does not have tiling & offset capabilities. What is the simplest way to add that feature to my shader?
current shader code
...
1
vote
2
answers
445
views
How to use unconventional texture format
I would like to use a texture that could have more than 4 channels.
I have seen a post where they use a single channel R8 texture to store string chars.
I'm thinking of using something like that with ...
0
votes
0
answers
414
views
How to calculate the world position of pixels in an HLSL script?
I want to make a simple ray marching loop in the fragment shader. I think the main issue is that I'm not giving the correct world position input.
Here is my current attempt:
...
0
votes
1
answer
100
views
Weird result whe nusing OMSetRenderTargetsAndUnorderedAccessViews
My render pass consist in four passes.
3 first have 2 rendertargets and two unordered access view.
RTV0 = RG88 //store normal.xy
RTV1 = R32 //store depth
UAV0 = R32UINT //store color1
UAV1 = R32UINT//...
0
votes
1
answer
153
views
Screen position in Deferred Shading
I am trying to implement a program in Direct3D 11 which uses techniques like deferred shading and shadowmapping, but when I create my gBuffers, the position looks strange. After researching a bit I ...
0
votes
0
answers
59
views
using texture as variable
I was trying to use a texture as a variable in my shader (DX11 VS/PS 5.0). Can't get it.
I have recently find this piece of code here where a texture is passed as a function parameter.
Is that ...
0
votes
1
answer
240
views
Noise in compute shader related to threadsPerGroup
I have been working on a metaball compute shader for roughly 3 months now, and the only issue I have to resolve is noise in the output Dest[id.xy]. I also asked GPT 4 about the crux of the issue and ...
0
votes
2
answers
897
views
How to convert from object space to clip space
I want to animate foliage with vertex animation but I have wrong output because I can't correctrly transform from object space to clip space, and my foliage goes off the model. How Can I convert in ...
0
votes
0
answers
221
views
How to deform mesh's actual vertices, based on shader waves code?
I am using a shader that is applying a visual deformation that looks like Gerstner waves.
It works great, but I need the mesh's actual vertices to deform based on these formulas as well.
How can this ...
1
vote
2
answers
536
views
Pack 4 textures into one channel
Can I pack 4 grayscale textures into one channel by converting the textures into uints and packing them?
...
1
vote
1
answer
394
views
D3D11 ERROR ("invalid arguments") from HLSL shader
I am using MonoGame 3.8.1.303 with Windows/DirectX.
I am just rendering a TriangleList using DrawIndexedPrimitives, but I am ...
0
votes
1
answer
588
views
Putting two R16_UNORM in a R32_UINT
With my hardware limitation for CS5 I'm using R32_UINT in my shaders to store compacted colors and normasl as 555 bits each. My packing is using uint3 and the result is of poor quality.
I'm planning ...
0
votes
1
answer
220
views
Looking for an advice on how to possibly boost my compute shader
I have 4 rendertargets R10G10B10A2 each being used to store color and normal in a compact double RGB 555 bits format. When I'm doing the lighting pass I'm obliged to have extra rendertargets because ...
0
votes
1
answer
559
views
Reliably addressing compute buffer when using large numbers of threads
I'm trying to move a 262,144 [2^18] points (stars) in a compute shader and am struggling to reliably address the data in a buffer.
I understand that there's a 3-dimensional array ...
0
votes
1
answer
252
views
Problems with normal recovery from storage as two floats and normal from depth buffer
In my app I’m producing for my deferred shading 4 layers of data to show up occluded parts of the scene during screen space reflection (SSR) pass. I need normal maps with bumpiness of these layers for ...
0
votes
1
answer
844
views
error X4532 Cannot map expression to gs_5_0 instruction set
Using DX11 I have this line starting with TC = txDiffuse in a geometry shader that generates the error message. Can someone explain me the problem or if it is not possible to sample in geometry shader ...
0
votes
0
answers
365
views
How to add inverted hull outline to desired objects in HLSL?
I am currently trying to edit a Vertex Shader of a game and want to add inverted hull outlines to the desired objects, but there are a lot of tutorials on the inverted hull for Unity, Blender, and ...
0
votes
1
answer
2k
views
Difficulties in converting RGBA to float and back
I can't get my colors back.
What I'm using to encode/decode:
...
0
votes
2
answers
373
views
Shadowmapping in view space
UV coordinates for shadow mapping are usually calculated from world position. I want to make it compliant with my screen space reflection (SSR) pipeline which works in view space.
Is it possible to ...
0
votes
2
answers
1k
views
0
votes
0
answers
412
views
How do I make a shader that simulates acrylic paint being smeared on a surface?
I know something about shaders, I have written some very basic shaders. This is the most advanced shader I have written so far.
It's been several days since I conceived the idea of trying to recreate ...
0
votes
1
answer
920
views
24bit float to RGB
There's solutions to convert float to RGBA but I would like to encode a float depth value in RGB format and save the three components in three separated unused alpha channels and recompose when needed....
0
votes
1
answer
3k
views
How do I cast a float4 to a float[4]?
I've a RGBA16F texturecube for 4 pointlights shadows rendered in one pass. Each color channel stores the object to light distance for one pointlight shadow (e.g red channel is for light 0 and so on). ...
0
votes
1
answer
368
views
How do I offset a texture pointer in order to store an array of D3D11_SUBRESOURCE_DATA?
I'm attempting to load a sequence of frames from a GIF into a Texture2DArray using stbi_load_gif_from_memory which returns a ...