HLSL Shader "Crystal"

HLSL Shader "Crystal"

school exam.

FEATURES :

Transparency: the object to which the shader is applied must be transparent. The observer must be able to see through the material.

Refraction: the environment visible through the crystal appears distorted. The intensity of the distortion is adjustable through a property.

Rim light: a highlight is visible at the edges of the object to which the shader is applied. The intensity and color of the highlight are adjustable through a property.

Project info

Descrizione dell'immagine 1

1 School exam

Descrizione dell'immagine 2

may 14th - may 28th, 2024, two weeks

Descrizione dell'immagine 3

Unity

Descrizione dell'immagine 4

Built-in

Home Repository

Shader Overview

The Diamond Shader is a custom-built shader developed in Unity for the final shading module exam. It utilizes refraction, distortion, and rim lighting effects to create a dynamic and realistic diamond-like material. The shader employs a grab pass to distort background reflections while maintaining a visually appealing edge glow.

Shader Goal

The shader aims to simulate the optical properties of a diamond-like surface, using refraction and rim lighting. By modifying distortion and hollowness values, the effect can be fine-tuned for different material appearances, adding flexibility and realism.

Key Features

The shader manipulates the grab pass texture to achieve a refraction effect. The distortion is influenced by the normal vector and user-defined hollowness values. Additionally, a rim lighting function blends the object’s color with the rim color, based on the viewing angle.

Features

  • Refraction & Distortion: Implements a grab pass to distort the background based on surface properties.
  • Rim Lighting: Uses a Fresnel-based effect to highlight the edges of the object dynamically.
  • Dynamic Surface Control: Adjustable hollowness and distortion parameters influence the refraction intensity.
  • Customizable Material: Provides user-defined properties to tweak the shader's visual output.

Shader Mechanics

The Diamond Shader utilizes a combination of refraction, distortion, and rim lighting to achieve a visually striking effect. By leveraging GrabPass sampling, the shader distorts background reflections dynamically, creating a realistic glass-like material. Additionally, rim lighting enhances the edges of the object based on the viewing angle, while optimized color blending ensures smooth transitions. Below are the key mechanics that define how the shader functions.

Additional information:

  • GrabPass Sampling: Captures the scene behind the object to create a refraction effect.
  • Distortion Calculation: Modifies the texture coordinates based on surface normals and hollowness values.
  • Rim Light Effect: Uses Fresnel equations to highlight object edges.
  • Color Blending: Dynamically mixes the base color with the rim color for a smooth transition.
  • Performance Optimization: Ensures efficient execution with minimal overhead.

Let's get in touch!

Feel free to reach out! Whether you have a question, a project idea, or just want to chat about game development, I’d love to connect.

Email:

Discord: Lollo48#2497

*Based on : work illustrations @iluskaland 2024

*Thanks for the illustration: work illustrations byStoryset

*Thanks for the icons: flatart, font awesome, microsoft, chanut is indurstries, kalash on Iconfinder