Uploaded August 2024 | Updated September 2026, 2 weeks ago
In this video we take a look at 3 very simple ways to optimize your HLSL code.
1. Avoiding Branches/If Statements
2. Constant Variables
3. Low Precision Variables
Technical Summary:
If/Statements can introduce branching whereas step will avoid branching, in this simple example its not going to make a difference really.
The main point was just to show how you could use a step to avoid using a If/Statement if there was significant branching/divergence.
GPUs use multiple threads to process data, and these threads are grouped into clusters (Warps/Wavefronts). If one of those clusters hits a if statement that has varying results, sometimes passing the condition, other times not. This introduces divergence, where the whole group of threads has to wait while all possible branches are processed.
Whereas when you use a step function, it will avoid branching. It just performs the operation across the threads.
Of course there may be some situations where if there's no significant branching/divergence it won't matter much. Optimizations can also be dependent on gpu architecture or the compiler optimizations. Generally the best way is to benchmark the performance with profiling tools.
HLSL Tutorial Series:
youtube.com/playlist?list=PLoHLpVCC9RmMMmW5eP1aAyJrTjxd46rx_
Patreon:
patreon.com/renderBucket
Discord:
discord.gg/BxsersBPQc
In this video we take a look at 3 very simple ways to optimize your HLSL code.
1. Avoiding Branches/If Statements
2. Constant Variables
3. Low Precision Variables
Technical Summary:
If/Statements can introduce branching whereas step will avoid branching, in this simple example its not going to make a difference really.
The main point was just to show how you could use a step to avoid using a If/Statement if there was significant branching/divergence.
GPUs use multiple threads to process data, and these threads are grouped into clusters (Warps/Wavefronts). If one of those clusters hits a if statement that has varying results, sometimes passing the condition, other times not. This introduces divergence, where the whole group of threads has to wait while all possible branches are processed.
Whereas when you use a step function, it will avoid branching. It just performs the operation across the threads.
Of course there may be some situations where if there's no significant branching/divergence it won't matter much. Optimizations can also be dependent on gpu architecture or the compiler optimizations. Generally the best way is to benchmark the performance with profiling tools.
HLSL Tutorial Series:
youtube.com/playlist?list=PLoHLpVCC9RmMMmW5eP1aAyJrTjxd46rx_
Patreon:
patreon.com/renderBucket
Discord:
discord.gg/BxsersBPQc
![Subway Caution Stripe - Substance 3D Designer - Intro To Procedural Surfacing [3/3]
Summary:
Part 3/3
Learn how to create surfaces/textures procedurally in Adobe Substance 3D Designer/Substance Designer.
This video we export our textures from Substance Designer and use Blender to turn our heightmap into a high quality 3D asset using displacement and decimation.
Patreon:
https://patreon.com/renderBucket
Discord:
https://discord.gg/BxsersBPQc Subway Caution Stripe - Substance 3D Designer - Intro To Procedural Surfacing [3/3]](https://i.ytimg.com/vi/xa3Y6nKsazA/mqdefault.jpg)





