My Journey With HLSL
This page follows my learning of HLSL. Some of the sections are from following tutorials , some of them are adaptations / blends of a few tutorials or even coming up with my own stuff.
Some of the resources I've found very useful for learning are:
- Render Bucket YouTube: https://www.youtube.com/@renderbucket
- Michael Walczyk Blog: michaelwalczyk.com/blog-ray-marching.html
- Inigo Quilez blog: https://iquilezles.org/
HLSL: Trigger Custom Prim Data for Materials
HLSL: Ripple Distortion
To get a gradient across our UV's "length(uv)" will produce the image on the left. "length(uv-0.5)" will created a centred radial gradient. this will be used as a base for the rest of the calculations.
To map the ripple density onto the gradient the ripple number (user specified) is multiplied by 2π. This will determine how many wavelengths there are in 1 frequency. This is then multiplied with the radial gradient.
The ripple frequency is (2π * userInput) *time. This will determine the speed which it repeats the UV tile range.
The result of the ripple density and the frequency are added together. To get undulating pattern the result needs needs to then be modulated through sin().
This can look like: float3(sin(distortedUV.x)*amplitude, sin(distortedUV.y)*amplitude, 0);
To produce the effect of distorting the background a reflect function where the camera position is defined but the surface vertex normal is 0 will give the result of "looking through" the object. If a reflection is needed you can use the vertexNormal node to pass into the reflection vector.
The reflection vector X and Y values are manipulated with the modulated wave pattern and the W is an untouched result.
HLSL: Functions
Following on from Render Bucket tutorial.
HLSL: Ray Marching UV's
Following on from Render Bucket tutorial.
HLSL: Ray Marching - Specular Component
Following on from Render Bucket tutorial.
HLSL: Ray Marching - Diffuse Shading
Following on from Render Bucket tutorial.
HLSL: Intro To and Optimizing Ray Marching
Blend of Render Bucket tutorial and Michael Walczyk Blog.
HLSL: Animated 2D Dots - For Loop
Following a Render Bucket tutorial.
HLSL: Tiling 2D Grid - If Statement
Following a Render Bucket tutorial.
HLSL: Tiling 2D Circles
Following a Render Bucket tutorial.