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
5
votes
3 answers

Identify mip map levels by coloring different screen areas in GLSL

I don't wish to bombard this post with code. I've got a main file, fragment shader and a vertex shader file. I need to know the steps that I should take to color the screen according to mipmap level? I.e. where the loop should go that asks for…
Luke Evans
  • 93
  • 1
  • 10
5
votes
2 answers

How can I compile asm shader to fxo file?

I have a compiled fxo shader which I'm trying to edit slightly (just adjusting some constants). Using fxdis (https://code.google.com/archive/p/fxdis-d3d1x/) I can disassemble this shader, this is the output: # DXBC chunk 0: RDEF offset 52 size…
matthias_buehlmann
  • 4,641
  • 6
  • 34
  • 76
5
votes
2 answers

What is the difference between .hlsl and .hlsli?

Both seems to be HLSL shader language, but what is the difference between them? Does it matter to change .hlsl extension to .hlsli, or vise versa? One of the article I found says that .hlsli file is not going into compilation, is it correct? (Too…
adayoegi
  • 117
  • 10
5
votes
1 answer

Force field shader unwrap texture not working

I got this shader from somewhere which i forgot, the default is only use solid color for the effect being hit. so i try to modified it to make it support shield texture as well. Shader "TFTM/FX/Shield2" { Properties { _Position…
Tengku Fathullah
  • 1,279
  • 1
  • 18
  • 43
5
votes
1 answer

How to force GLSL branching?

I'm working on a fragment shader. It works, but it still needs some optimisation. As far as I know, most of the cases branches in GLSL are flatten, so both cases are executed. I've eliminated most of the if-else conditions, but there are some of…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
5
votes
0 answers

Suggestions for HLSL 2D shader tutorials?

I am looking for some resources for writing 2D shaders (not 3D, so please no references to vertex shader code or anything like that). I'm using HLSL, but having a lot of trouble finding good tutorials. Any suggestions?
RCIX
  • 38,647
  • 50
  • 150
  • 207
5
votes
0 answers

HLSL Render To Texture / Stream Output in Unity

I am trying to implement an HLSL Shader in Unity 5 which displaces the vertices of a sphere. What I'm trying to work out is how do I effectively pass information from one frame to the next so that I can 'save' the calculated velocities of each…
Zze
  • 18,229
  • 13
  • 85
  • 118
5
votes
2 answers

Vertex position relative to normal

In a surface shader, given the world's up axis (and the others too), a world space position and a normal in world space, how can we rotate the worldspace position into the space of the normal? That is, given a up vector and a non-orthogonal…
5
votes
1 answer

What does the printf function in HLSL do?

The MSDN HLSL reference states this about printf: "Submits a custom shader message to the information queue." https://msdn.microsoft.com/en-us/library/windows/desktop/ff728755%28v=vs.85%29.aspx What is the information queue and how can I see the…
SvinSimpe
  • 850
  • 1
  • 12
  • 28
5
votes
1 answer

CreateComputeShader returns E_INVALIDARG when using doubles

I need double precision for some GPGPU calculations using DirectCompute. When I make everything a float, the shader compiles and runs just fine. However, when I try to use doubles anywhere in my shader, it will compile, but calling…
NmdMystery
  • 2,778
  • 3
  • 32
  • 60
5
votes
2 answers

Sort algorithm with fewest number of operations

What is the sort algorithm with fewest number of operations? I need to implement it in HLSL as part of a pixel shader effect v2.0 for WPF, so it needs to have a really small number of operations, considering Pixel Shader's limitations. I need to…
luvieere
  • 37,065
  • 18
  • 127
  • 179
5
votes
1 answer

Specular reflection in HLSL

I'am trying to understand specular reflection in HLSL and DirectX11 cbuffer ConstantBuffer : register( b0 ) { matrix World; // Матрица мира matrix View; // Матрица вида matrix Projection; // Матрица проекции …
user2872568
5
votes
3 answers

Format of compiled directx9 shader files?

Is the format of compiled pixel and vertex shader object files as produced by fxc.exe documented anywhere either officially or unofficially? I'd like to be able to read the constant name to register assignments from the shader files. I know that the…
jcoder
  • 29,554
  • 19
  • 87
  • 130
5
votes
3 answers

Optimization of HLSL shader

I have the problem that the below pixel shader (HLSL) compiles to 68 instructions (with the below suggested optimizations). However, I would like to use it with shader model 2 and therefore unfortunately I can only use up to 64 instructions. Does…
ares_games
  • 1,019
  • 2
  • 15
  • 32
5
votes
2 answers

How can I use VS2012's automatic HLSL compiling in a C# project?

http://blogs.msdn.com/b/chuckw/archive/2012/05/07/hlsl-fxc-and-d3dcompile.aspx The above link states that "Note: This automatic integration only works for C++ projects, not C# projects.". I'm using SlimDX and surely there's a way to make it so…
Levi H
  • 3,426
  • 7
  • 30
  • 43