Questions tagged [hlsl]

A proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.

Filter by
Sorted by
Tagged with
0 votes
0 answers
23 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: ...
Nikhil Nair's user avatar
0 votes
1 answer
11 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//...
philB's user avatar
  • 99
0 votes
1 answer
58 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 ...
Charlie.Q's user avatar
0 votes
0 answers
29 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 ...
philB's user avatar
  • 99
0 votes
1 answer
37 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 ...
rasputin's user avatar
0 votes
2 answers
42 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 ...
Silz's user avatar
  • 39
0 votes
0 answers
30 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 ...
yukjaly7's user avatar
1 vote
2 answers
157 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? ...
Shiv-iwnl's user avatar
1 vote
1 answer
98 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 ...
codymanix's user avatar
  • 364
0 votes
1 answer
48 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 ...
philB's user avatar
  • 99
0 votes
1 answer
78 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 ...
philB's user avatar
  • 99
0 votes
1 answer
70 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 ...
Basic's user avatar
  • 876
0 votes
1 answer
44 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 ...
philB's user avatar
  • 99
0 votes
0 answers
39 views

Unity mix multiply shader passess together

Hi i want to create a shader with different passes, first pass has transmission second one has reflection, GI and PBR using surf and third one is outline around using unlit. How can i blend my ...
Cyclone's user avatar
  • 29
0 votes
0 answers
110 views

Compute Shader for loop always outputs last index in external variable instead of conditional setting

I want to use a Compute Shader to calculate the barycentric coordinates of a set of points with UVs from a mesh. For that, I loop over the meshes' UV-Coordinates in the order of the indices. This ...
DavidArcher's user avatar
0 votes
1 answer
130 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 ...
philB's user avatar
  • 99
0 votes
0 answers
11 views

Selective writing to multirendertarget with geometry shader

I have multirendertarget in my deferred pipeline. Curently I'm using independnt RTV blending to selectively output or not an object to these RTV using the alpha channel. Works fine. But I would like ...
philB's user avatar
  • 99
0 votes
0 answers
93 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 ...
Krish-fz's user avatar
0 votes
1 answer
338 views

Difficulties in converting RGBA to float and back

I can't get my colors back. What I'm using to encode/decode: ...
philB's user avatar
  • 99
0 votes
0 answers
36 views

Unreal HLSL semantics

We have some HLSL shader code that uses the predefined shader semantics TEXCOORDX to map input streams. We now want to support Unreal as rendering back-end and see ...
PetiteViking's user avatar
0 votes
2 answers
81 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 ...
philB's user avatar
  • 99
0 votes
0 answers
53 views

unity instanced shader can't get quads to look at camera

i'm almost using this code exactly: https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshInstancedIndirect.html the second shader "Instanced/InstancedShader". i've been trying to ...
megaultrahyperprocoder's user avatar
0 votes
2 answers
218 views

DirectX11 creating input layout throws error on input signature not matching shader (instancing)

The input layout ...
koreus737's user avatar
  • 131
0 votes
0 answers
134 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 ...
blablaalb's user avatar
0 votes
1 answer
205 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....
philB's user avatar
  • 99
0 votes
1 answer
773 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). ...
philB's user avatar
  • 99
0 votes
1 answer
126 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 ...
Casey's user avatar
  • 1,990
1 vote
1 answer
821 views

How to add antialiasing to my circle shader?

I made a circle shader by following this tutorial: https://www.youtube.com/watch?v=Ww1GbfnBH_Q. It is simple flat circle shader. The problem is that there are visible jigged lines on the circle edges. ...
Ivan's user avatar
  • 185
0 votes
1 answer
145 views

Why can't I use the "degrees" character in HLSL comments?

I was in the process of creating a function in my compute shader that converts a 180° angle to a 360° CCW angle like this: ...
Keheck's user avatar
  • 31
0 votes
1 answer
736 views

How to modify the z depth value inside the vertex function of a surface shader?

I wrote the following surface shader. The idea is to increase the Z depth value of vertices, after projection. ...
tigrou's user avatar
  • 3,172
5 votes
0 answers
193 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: ...
NHSH's user avatar
  • 51
0 votes
1 answer
713 views

Initializing a global variable array once for a shader without using CPU code to populate the array

I know I can initialize arrays via code written in C++, etc. to set arrays in a shader. What I want to know is if I can initialize the array in HLSL code instead. For example: ...
jjxtra's user avatar
  • 117
2 votes
1 answer
164 views

How to generate a correct RGB + Luminance histogram?

I am trying to create a debug tool that would help me visualize an image RGB and luminance histogram. I have created a compute shader where I gather the histogram data ...
GameDevNerd's user avatar
0 votes
0 answers
92 views

ComputeBuffer Values messed up when calling the dispatch many times in a row

I'm having a RWStructuredBuffer called AffectedVertices give me random data instead of 1 simple value to resultAffectedVertices, ...
TensaDev's user avatar
2 votes
0 answers
26 views

Where is this quad pattern coming from? [duplicate]

I'm rendering a map generated from noise. For debugging purposes, I'm just using the normals as color. I'm not sure how good/correct my calculated normals are, either way, I'd expect a smooth colored ...
tkausl's user avatar
  • 1,860
0 votes
1 answer
87 views

What is wrong with my terrain lighting?

I've just implemented a simple algorithm to calculate terrain vertex normals and I'm using diffuse and ambient light currently, but for some reason the squares that make up my terrain are visible when ...
Rafael Ferreira's user avatar
0 votes
0 answers
33 views

shader can't read data except position, texcoord, normal

i want to read bone's weight but shader can't read data this is my vertex type ...
문형준's user avatar
1 vote
0 answers
218 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 ...
Charly's user avatar
  • 733
1 vote
0 answers
66 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 ...
HellGate's user avatar
0 votes
0 answers
43 views

Why my output image is not seamless?

I offset a region of an image but when I tried to restore it using same method it doesn't look right. here is my input and output: And this is the code I used to restore : ...
Mary Jane's user avatar
0 votes
0 answers
80 views

In a shader, what is the meaning of l()?

For instance, l(2.000000) or l(1.000000, 1.000000, 1.000000, 1.000000). This is in HLSL. Example in use: ...
Justin's user avatar
  • 1
0 votes
0 answers
280 views

Marching cube terrain generated by compute shader gives strange error

I'm creating my own terrain terrain system for Unity using marching cubes but I've run into a problem I'm stumped on. First I'll explain how it works: A compute shader creates an array of points ...
Leo's user avatar
  • 1
2 votes
2 answers
645 views

How to evaluate a binary expression tree in HLSL without recursion or a stack?

I'm currently working on a dual contouring implementation for which I want to create procedural terrain based on layers of noise. Both, the terrain generation and the mesh creation via dual contouring ...
Tuntenfisch's user avatar
0 votes
1 answer
155 views

How to synchronize reads and writes to a StructuredBuffer across warps in HLSL?

I'm currently trying to implement smooth voxel terrain (using dual contouring) with mesh generation happening on the GPU and I'm struggeling with chunked level of detail creation. My approach is as ...
Tuntenfisch's user avatar
0 votes
0 answers
148 views

How to raycast octree for closest leaf node?

So I need to raycast a octree for closest leaf node as efficient as possible. I will be doing it on compute shader (hlsl), but I think it doesn't matter because first I need to understand the approach ...
Janis Taranda's user avatar
0 votes
1 answer
87 views

Moving the bulk of a recursive ray tracer function to the gpu, using DirectX12 not DirectX 12 DXR HLSL

So I'm wanting to generate images by ray tracing. I've done so, but the main ray function is recursive. I know one can make a non recursive function out of a recursive function using a stack, but is ...
jaysonpowers's user avatar
1 vote
1 answer
1k views

How to sample a TextureCube texture

I'm converting old shader code to be a bit more modern. So far this works out great, but I'm having a though time figuring out how to convert shader code that works with cubic textures. In the old ...
Roy T.'s user avatar
  • 10.2k
3 votes
0 answers
377 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 ...
Elstadt's user avatar
  • 31
0 votes
0 answers
118 views

How to include a FX shader to my game?

I have an old game source from 2004, the game runs DirectX9, and I want to improve the graphics. I downloaded NVIDIA FX Composer 2.5, and I created a “...
Cosma Eduard's user avatar
2 votes
1 answer
334 views

Splitting up HLSL code into separate functions causes the number of needed temporary registers to increase

EDIT Per request I've provided a simple compute shader that reproduces the problem. The compute shader below is kind of a contrived example meant to compute the rolling average over an input ...
Tuntenfisch's user avatar

1
2 3 4 5
13