top of page

04. Shaders

  • Writer: Bence Nagy
    Bence Nagy
  • Dec 4, 2022
  • 3 min read

The next topic is about the shaders used in this project to create visually appealing effects. Shaders are executed on the GPU to alter the pixels and create different rendering effects. In this project, all shaders were created using the Unity HDRP Shader Graph, which eliminates the need for additional shader programming. It's worth noting that this is not a tutorial session, but if you're interested in learning more about how the shaders were achieved and want to know more details, feel free to send me a message and I'd be happy to help."


It's important to note that the Unity HDRP Shader Graph is a powerful tool that allows for the easy creation of shaders without the need for programming. This means that even non-programmers can create visually appealing shaders. However, it's also worth noting that HDRP shaders are more demanding on the GPU and can have a higher performance impact, especially on lower-end hardware.


Fire shader variants

The first shader in the project is the fire shader, which is currently a temporary solution but can easily be adapted to create variants for campfires, torches, or candles. Fire effects are typically created using particle systems, but I sought out alternative solutions and developed this shader as an option. However, it's worth noting that I might still opt to change it to use particle systems in the future.

The foundation of the fire effect is a drop-shaped mesh, to which the shader is applied. By using an alpha cutoff, the top portion of the mesh becomes transparent. The shape and variation in color of the fire are achieved by combining two Voronoi noise patterns and separating the black and white values, then coloring them with different hues. This creates the desired fire shape and coloration.


Part of the fire shader graph

The beauty of shaders is the ability to use the same noise nodes to create a variety of different effects. As previously mentioned, I used Voronoi noise to create the fire effect, but it can also be used to create other effects, such as waterfalls. In this case, I've created two separate waterfall shaders. The first one simulates a waterfall, while the second one is the foam created by the force of the falling water. The ability to reuse the same noise nodes and tweak them to create different effects is a powerful feature of shaders and allows for a more efficient workflow. It's worth noting that it's not only Voronoi noise, there are various types of noise such as Perlin, Simplex, etc. that can be used to create different effects with different characteristics.


Waterfall and ripple shader with additional particle effect (foam and water splash)

The foam shape on both the waterfall and water ripple is created by scaling the Voronoi noise. For added realism, I also incorporated particle effects to simulate water splashes and rolling foam at the base of the waterfall. The shaders are fully customizable, allowing for changes to be made to the color, shape, and tiling. The shaders also follow the mesh UV, making it possible to create waterfalls of different shapes.


Simple Water Shader with foam

The water shader is relatively straightforward, using Scene depth to create the underwater fog and foam effects. It includes a basic water refraction, but due to its simplicity, the effect is visible both above and below the water surface. However, this can be mitigated by adjusting the strength of the distortion effect, making it less noticeable outside of the water.


Interactive Grass shader

The final shader in the project is the interactive grass shader, which adds a dynamic element to the game. By default, the grass sways in the wind, but when the player steps on it, the blades of grass move to the side, providing more visibility for the player and adding a touch of realism. This interactive grass shader is a nice way to immerse the player in the game and make the environment more dynamic. It's worth noting that this shader can be further customized by adjusting various settings such as wind strength, swaying amplitude, and more, to fine-tune the appearance of the grass to suit the game's aesthetic.


Some short videos from the shaders in movement:





Thank you for reading!


- Bence (Oliminor)


Comments


©2022 - 2023 by Oliminor. Created with Wix.com

bottom of page