Real time preview for HLSL shaders.
- DirectX 11 HLSL syntax pixel and vertex shaders live preview
- Automatic parameters (uniform variables) detection via reflection
- Configurable entry points
- Compiler error reporting
- Mesh preview
To open the preview select Preview HLSL
in editor tab context menu or in command pallete.
To create a custom shader parameter declare a global variable or use // INPUTS(type): name
comment and it will automatically appear in preview settings window as soon as the shader compiles.
float4x4 modelMatrix
float4x4 modelViewMatrix
float4x4 projectionMatrix
float4x4 viewMatrix
float3x3 normalMatrix
float3 cameraPosition
float iTime
- seconds since preview startedfloat2 iResolution
- viewport size in pixelsfloat4 iMouse
iMouse.xy
- cursor relative location in viewportiMouse.z
- seconds left mouse button held down or < 0.0iMouse.w
- seconds right mouse button held down or < 0.0
- Virtual camera matrices available in 2D preview mode:
iVirtualProjectionMatrix
iVirtualProjectionInverseMatrix
iVirtualModelViewMatrix
iVirtualWorldMatrix
iVirtualWorldInverseMatrix
uint
s are not supported.- bitwise operations are limited.
- Textures can not always be used as function parameters.
The extensions includes WebAssembly versions of compilers and does not require external binaries to work. Using external binaries greatly improves preview startup time and eliminates loading screen.
Installation:
-
DirectX Compiler
- Compile or download a build of DirectX Shader Compiler: https://github.com/Microsoft/DirectXShaderCompiler.
- Add
dxc
executable toPATH
or sethlsl.preview.dxc.executablePath
. - Add your shader include directories to
hlsl.preview.dxc.includeDirs
. (Optional)
-
SPIRV-Cross
- Compile or download a build of SPIRV-Cross: https://github.com/KhronosGroup/SPIRV-Cross.
- Add
SPIRV-Cross
executable toPATH
or sethlsl.preview.spirv.executablePath
.
-
Set
hlsl.preview.useNativeBinaries
totrue
.