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
7
votes
1 answer

Windows Store apps Shader model 4_0_level_9_3 and VPOS

In order to build shaders for Windows Store apps (and Windows Phone 8) Shader model 4_0_level_9_3 you need to use the vs_4_0_level_9_3 and ps_4_0_level_9_3 . While all this sounds fine using the HLSL syntax designed for DirectX 10 and up, I'm unable…
RelativeGames
  • 1,593
  • 2
  • 18
  • 27
7
votes
2 answers

DirectX Shader Resource View in Shaders

I'm a bit confused right now and just want to ask you all to help me get a few ideas clarfied. In a HLSL shader (compute shader for example) I can declare a StructuredBuffer sb, right? Do I HAVE to bind it to a register, such as : register(t0)?…
l3utterfly
  • 2,106
  • 4
  • 32
  • 58
7
votes
2 answers

HLSL branch avoidance

I have a shader where I want to move half of the vertices in the vertex shader. I'm trying to decide the best way to do this from a performance standpoint, because we're dealing with well over 100,000 verts, so speed is critical. I've looked at 3…
Darrel Hoffman
  • 4,436
  • 6
  • 29
  • 41
7
votes
1 answer

HLSL buffer stride and threading - what is happening here?

I'm really new to DirectCompute technologies, and have been attempting to learn from the documentation on the msdn website, which is.. dense, to say the least. I'd like to make a basic hlsl file that takes in a 4x4 matrix and a 4xN matrix and…
Zach H
  • 469
  • 5
  • 18
6
votes
1 answer

Blending multiple textures in GLSL

This is long but I promise it's interesting. :) I'm trying to mimic the appearance of another application's texturing using jMonkeyEngine. I have a list of vertices, and faces (triangles) making up a "landscape mesh" which should be textured with…
Manius
  • 3,594
  • 3
  • 34
  • 44
6
votes
1 answer

Sequence of transformations: Projective Texturing (HLSL)

When I was reading this article on Projective Texturing (9.3.2) on nvidia, I came across this graph: (source: nvidia.com) The order in which the transformations are written confused me. This is because I learned to read matrix multiplication from…
6
votes
2 answers

Efficient storage for a sparse octree?

Can anyone suggest a fast, efficient method for storing and accessing a sparse octree? Preferably something that can be easily implemented in HLSL. (I'm working a raycasting/voxel app) In this instance, the tree can be precalculated, so I'm mostly…
3Dave
  • 28,657
  • 18
  • 88
  • 151
6
votes
2 answers

Dot product vs Direct vector components sum performance in shaders

I'm writing CG shaders for advanced lighting calculation for game based on Unity. Sometimes it is needed to sum all vector components. There are two ways to do it: Just write something like: float sum = v.x + v.y + v.z; Or do something like: float…
Crabonog
  • 423
  • 3
  • 12
6
votes
1 answer

Why "Warning X4000: use of potentially uninitialized variable" shows for more than one usage of common method?

I have a common method in hlsli /// RendererShaderTypes.hlsli /// static inline float4 OverlayColor(float2 texOverlay, float4 videoColor) { float4 texColor = float4(imageMixTexture[4].Sample(imageMixSampler[4], texOverlay)); if…
6
votes
1 answer

directx/HLSL what are input and output semantics for?

i was wondering what those input and output semantics in HLSL are for? i.e. why do i have to write that TEXCOORD0; struct VS_OUTPUT { float2 tc : TEXCOORD0; }; when the type and the name are already given?
clamp
  • 33,000
  • 75
  • 203
  • 299
6
votes
1 answer

How to copy an array in HLSL?

In HLSL I have two arrays: int arr1[2]; int arr2[2]; I need to copy contents of arr1 to arr2. Should I iterate through every element? arr2[0] = arr1[0]; arr2[1] = arr1[1]; Is there any specific HLSL tool (like memcpy() in C/C++)? Or could I…
Oliort UA
  • 1,568
  • 1
  • 14
  • 31
6
votes
5 answers

Shader framebuffer readback

I was wondering if there is support in the newer shader models to read-back a pixel value from the target framebuffer. I assume that this is alrdy done in later (non-programmable) stages in the drawing pipeline which made me hope that this feature…
ronag
  • 49,529
  • 25
  • 126
  • 221
6
votes
1 answer

How to share a struct between C++/DirectX and HLSL?

I'm in the process of learning C++ and DirectX, and I'm noticing a lot of duplication in trying to keep structs in my HLSL shaders and C++ code in sync. I'd like to share the structs, since both languages have the same #include semantics and header…
berwyn
  • 986
  • 7
  • 23
6
votes
1 answer

HLSL: Empty fx file: X3000: unexpected token '{'

The following error appears: Test.fx(1,1): error X3000: syntax error: unexpected token '{' Text.fx contains this: Nothing. I also tried it with an effect file that works fine in another test project: float4x4 mWorld; struct TInputVertex { …
Tony
  • 417
  • 4
  • 11
6
votes
1 answer

How to achieve smooth tangent space normals?

I'm trying to add bump mapping functionality to my application but I'm getting very faceted models: The reason it is happening is because I'm calculating tangent, binormal and normal on per face basis and completely ignoring the normals I'm getting…
jaho
  • 4,852
  • 6
  • 40
  • 66