I'm excited to share the process behind creating a dynamic texture effect using Unity's Shader Graph. This README outlines each step I took to achieve the animation similar to the script-based shader I developed in the Custom Shader assignment:
I began with a UV node to get the default UV coordinates from the geometry. This is essential as the basis for all subsequent texture manipulations.
To manipulate the U and V coordinates independently, I used a Split node. This allowed me to apply effects separately to each component, enhancing control over the distortion effects.
The dynamic aspect of the shader comes from applying time-based changes:
- Time Node: I utilized the Time node to access Unity's continuously updating time value.
- Sine and Cosine Functions: I applied these functions to the time values to create naturalistic, oscillatory distortions across the UV map.
To fine-tune the distortion:
- Multiply Nodes: I controlled the frequency and amplitude by multiplying the time values before applying the sine and cosine functions. This step was crucial for matching the visual style and behavior seen in the original shader.
After obtaining the modified wave outputs, I added them back to the original UV coordinates using Add nodes. This effectively combined the base texture placement with dynamic distortions.
I then recombined the adjusted U and V components using a Combine node. This reassembled UV vector was crucial for the subsequent texture sampling, ensuring the distortions affected the final output.
Using the Sample Texture 2D Node, I sampled the texture with the dynamically modified UVs. This is where the modified UVs were used to fetch the texture colors based on the dynamic distortions.
Finally, I directed the sampled texture color to the PBR Master Node. This step integrated the shader's visual effects into Unity's physically-based rendering pipeline, affecting how the material interacts with scene lighting and environmental factors.
This shader graph setup exemplifies how to leverage Unity Shader Graph’s capabilities to create visually dynamic textures. By manipulating UV coordinates with time-based functions and adjusting parameters like frequency and amplitude, I achieved a visually appealing effect that enhances the realism and artistic flair of 3D objects in Unity.