Questions tagged [hlsl]

HLSL(High Level Shader Language) is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API

HLSL is a C-like language developed by Microsoft and it's used in Direct3D API to define shaders. HLSL is used by Direct3D 9, and is required by the unified shader model in Direct3D 10+.

HLSL can be used to define pixel shaders, vertex shaders, geometry shaders, compute shaders, tessellation shaders, raytracing shaders and mesh shaders. It is analogous to for OpenGL.

Vulkan SDK and DirectX Shader Compiler also supports compiling HLSL shaders into SPIR-V, enabling its use in Vulkan applications.

Resources

1642 questions
0
votes
1 answer

HLSL correct pixel position in deferred shading

In OpenGL, I am using the following in my pixel shaders to get the correct pixel position, which is used to sample diffuse, normal, position gbuffer textures: ivec2 texcoord = ivec2(textureSize(unifDiffuseTexture) * (gl_FragCoord.xy /…
KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199
0
votes
1 answer

Convolution filter outputs wrong color values

I've just started to learn DirectCompute and for learning purposes, I want to make a simple convolution filter that blurs a texture. I've written the following compute shader to blur the texture: Texture2D inputTex; RWTexture2D
Krienie
  • 611
  • 1
  • 6
  • 14
0
votes
1 answer

Selecting a constant buffer dynamically

If I have a load of constant buffers full of data cbuffer1, cbuffer2, cbuffer3 etc in my shader. Is there any way in hlsl that I can access a specific constant buffer dynamically at runtime? Something like this... cbuffers[1].MyValue Or is the only…
Dean North
  • 3,741
  • 2
  • 29
  • 30
0
votes
1 answer

Dynamic branching in HLSL Shader Model 4.1

I can't seem to find a conclusive answer to this anywhere, so perhaps someone here can help. I am building a vertex shader (HLSL Shader Model 4.1) for Direct3D 11, and to reduce the number of draw calls I need to do, I want this shader to execute…
d7samurai
  • 3,086
  • 2
  • 30
  • 43
0
votes
1 answer

HLSL/GLSL Find range for integer

Assuming I have a few hundred varying size adjoining ranges 0-100,101-300,301-1000,1001-2000 etc. What would be the fastest way for me to find which range a given integer falls into using HLSL/GLSL? The ranges will be stored in a constant buffer and…
Dean North
  • 3,741
  • 2
  • 29
  • 30
0
votes
0 answers

Is it possible to get the interface name (Dynamic Shader Linkage)?

I am currently working on implementing dynamic shader linkage into my shader reflection code. It works quite nicely, but to make my code as dynamic as possible i would like to automate the process of getting the offset into the dynamicLinkageArray.…
puelo
  • 5,464
  • 2
  • 34
  • 62
0
votes
0 answers

DirectX Conservative depth

I want to use conservative depth in my fluid renderer to use hardware optimizations. I want to change depth value in my pixel shader here is Pixel output type struct PShaderOutput { float4 targetRender1 : SV_Target0; float depth :…
Alatriste
  • 527
  • 2
  • 6
  • 21
0
votes
1 answer

How to draw a border at the side of the triangle

I'm researching to draw a map route by the D3D. So I have created vertex buffer and fill it by the points: {-0.5, 0.5}, {-0.5, -0.5}, {0.5, -0.5}, {0.5, 0.5}. The Indexes buffer if: {0,1,2, 2,3,0}. So the rectangle is drown, now I need to draw a…
Viacheslav Smityukh
  • 5,652
  • 4
  • 24
  • 42
0
votes
1 answer

Shaders ambient occlusion for a voxel engine

I am trying to achieve ambient occlusion in my game through Monogame's VertexPositionColorTexture. An image of the current ambient occlusion I have come up with is this, but it's not entirely complete: I am not using shaders to achieve this effect…
0
votes
0 answers

How to remove Blur halo effect

I'm trying to blur my depth buffer and then get surface normal for my fluid simulation here is my hlsl pixels shader Bilateral Filter float depth = depthTexture.Sample( defss1, pin.Tex).x; float blurDepthFalloff = 2.0f; float radius = 4.0f; float…
Alatriste
  • 527
  • 2
  • 6
  • 21
0
votes
1 answer

Issue with progress bar shader in XNA

I'm create a simple shader for drawing progress bar in XNA. Idea is simple: there are two textures and value and if X texture coord less then value use pixel from foreground texture, else use background texture. /* Variables */ texture…
user1722351
0
votes
2 answers

Mul function in HLSL: Which one should be the first parameter? the Vector or the Matrix?

I am learning HLSL shading, and in my vertex shader, I have code like this: VS_OUTPUT vs_main( float4 inPos: POSITION, float2 Txr1: TEXCOORD0 ) { VS_OUTPUT Output; Output.Position = mul( inPos, matViewProjection); Output.Tex1…
Noah
  • 135
  • 3
  • 11
0
votes
0 answers

SharpDX Pixel shaders need different parameters for different SpriteBatches vs DrawQuad. Fixable?

I'm new to building graphics engines and kinda stumped on a particular issue. I have an issue getting pixel shaders to work using the same set of parameters for both. Causing me to have to create 2 different techniques for each method. If I try to…
corylulu
  • 3,449
  • 1
  • 19
  • 35
0
votes
1 answer

HLSL 2D Pixel Shader Recursion Help? (XNA)

I am using the latest version of XNA. I am attempting to write a lighting pixel shader for my 2D game. (Thinks Starbound's lighting system) To do this, I need to implement a recursive function to spread light onto the texture. Unfortunately, when I…
ben
  • 133
  • 13
0
votes
1 answer

Reading effect file always returns no technique

I have a very simple test effect file that I try to load with the following code: using D3D = Microsoft.WindowsAPICodePack.DirectX.Direct3D10; ... var DxDevice = CreateDevice(D3D.DriverType.Hardware); var stream =…
Gábor
  • 9,466
  • 3
  • 65
  • 79
1 2 3
99
100