Hello and  welcome back to the next step
in our ice shader tutorial series.
In our Last Episode, we showed you how to iterate a simple
parallax shader and use a custom function node in the shadergraph.
In this episode, we will show you
how to randomize the parallax output
and create more variation in the cracks inside the ice.
First, we need another noise texture.
In this case, we can reuse the one we used earlier
in our tutorials to create bubbles or clouds
under the ice surface.
Feel free to experiment with other noises to generate different effects.
Next, we create new Parameters for our shader,
noiseScale and noiseDepth.
This will allow us to control the influence of the noise texture.
It is time to revisit our Code function.
As a small adjustment, we multiply our ParallaxOffset
by 0.01 and subtract it
instead of adding the value.
Since the values tend to be very small and negative,
this makes adjustments in the Editor much easier.
Now we add the new texture and noise control vaiables
(noiseScale and noiseDepth) as input to our shader.
We also have to use parallax offset for the noise,
since we want it to be measured exactly where the cracks are.
NoiseScale acts as a tiling offset for the noise.
Now we multiply  the parallax result with the noise strength.
We can use the material Editor to finetune our values.
In this Example, we use a parallax offset
of 0.2, 16 iterations,
noiseScale of 16 and noise depth of 2.5
As you can see,
you can now get more variations among the cracked ice lines.
Feel free to experiment with the material values
until the result suits your needs.
As a nice visual addition we are now going to add
some fake seethrough transparency.
First we set our PBR material to transparent,
and leave the alpha values at one to get an opaque material.
Next we add two screen position nodes,
Screen Position in Default mode and Screen position in Raw mode.
For the Raw Screen Position, we use a split node
to isolate the alpha channel,
then subtracting a new parameter called iceDepth from it.
As the name suggests, this will be used to simulate the thickness
of the ice layer.
For the default screenPosition,
we sample the scene Depth in linear values
and multiply it by the camera far plane value.
These two results get subtracted,
and the result is fed into a one minus node.
For the next step,
the value is clamped and fed into our output emmission control.
This is our first visual result.
To get a better control we add Color,
multiplying it with the SceneColor, and multiplying both
to an adjustable brightness value.
The result is then multiplied
with the depth values from the previous step.
To get some refractions into our material we use the High Definition Render Pipelene.
First You need a scene representing the surface under the ice.
Here we use a Terrain on top of our rocks from earlier.
In our scene graph,
we create a new Lit Master node.
Set its surface type to transparent,
the refraction model to sphere,
and check receive SSR is on.
Now for the alpha channel,
we use the non inverted smoothness map we created earlier,
and add 0.7 to it.
Feel free to experiment with other values.
For the refraction index, we just use  a simple noise node,
set a very high scale
1024 in this case
and bias its value by multiplying it with 0.05
to get variations on a really small scale
and adding 1 which is the initial Index of Refraction value.
Next, we connect the depth color to the refraction color input
As an additional effect we can use the false transparency as emission.
You can adjust the setting by altering color
and setting the falsetransparency brightness until you are satisfied with the result
This concludes the tutorial.
Using the color and parameters for the 'fake' transparency and the refraction,
we can see whats hidden under the ice.
Thank you for watching!
And as always, if you liked it, feel free to subscribe to our channel
and leave us a comment
