Skip to content

adityablaze/VR_ChemLab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VR_ChemLab

VR_ChemLab is an interactive, educational Virtual Reality simulation designed to replicate a chemistry laboratory environment. This application allows users to perform experiments, handle apparatus, and observe chemical reactions in a safe, virtual space.

🎥 Demo

Watch a short video demonstration of the laboratory capabilities:
🔗 LinkedIn Post Demo
🔗 Full Demo Video (Drive)

🎓 About The Project

This project was developed as a Minor Project for the 5th Semester.

It is important to note that this is primarily an educational application rather than a game. The goal was to create a modular system where students or anyone can interact with chemicals without the physical risks or costs associated with a real lab.

⏳ Development Timeline

This project was developed in a little bit of a short timeline. It took me about 1-2 months to complete the project alongside regular classes and other academic coursework. Even though the project was a little bit rushed, the core systems were designed to be modular and scalable. Because of this, I did make some use of AI to do things faster which otherwise would have taken longer for me to complete.

⚗️ Features

  • Interactive Apparatus: Users can pick up and manipulate standard lab equipment including Beakers, Erlenmeyer Flasks, Test Tubes, and Tongs.
  • Pouring Mechanics: A simple raycast based pouring system allowing transfer of fluids between containers.
  • Chemical Reactions: A dynamic reaction system where mixing specific chemicals triggers visual changes (color change, particle effects) based on defined rules using scriptable objects.
  • VR Locomotion: Implements standard VR movement (Teleportation and Continuous Move) and Snap/Smooth turning using the Unity XR Interaction Toolkit.
  • Educational Sandbox: A safe environment to experiment with volatile substances.

🛠️ Technical Details

1. Modular Chemical Rules (ScriptableObjects)

The core of the chemical interaction system relies on Unity's ScriptableObjects. Instead of hardcoding chemical properties into scripts, every chemical is an asset file.

  • Chemical Definitions: Each chemical (e.g., H2O, HCl, NaOH, etc.) is a ScriptableObject defining properties like Name, Color, Density, and pH.
  • Reaction Rules: Reactions are also defined as data. The system checks if Chemical A + Chemical B results in a valid Reaction C.

Inspector Workflow: This modularity allows for a "Swap and Play" workflow. We can change the liquid inside a beaker simply by dragging a different Chemical ScriptableObject into the inspector slot before running the application. No code changes are required to introduce new chemicals.

ezgif-89aa6a704860ef2c liq Wobble

2. Liquid Shader

To achieve a realistic look for the fluids, a custom shader was implemented. This shader handles:

  • Dynamic Surface Culling: The shader calculates a fill plane based on the fill amount and wobble parameters, discarding pixels above this plane to simulate the liquid's surface level dynamically.
  • Top Face Rendering: It renders the top surface of the liquid by rendering back-faces of the mesh that are below the fill plane, creating the illusion of a solid volume.
  • Fill Accuracy: Uses LocalYMin and LocalYMax properties, controlled via external scripts, to map the fill amount accurately to the physical bounds of the specific container mesh volume.
  • Wobble/Slosh: The shader exposes WobbleX and WobbleZ parameters which are driven by external scripts calculating velocity and angular velocity to simulate liquid movement.
  • Purely Visual: The shader does not handle chemical logic it receives color and fill properties from the C# scripts which manage the reaction state.

Shdergraph

3. XR Implementation

The project utilizes the Unity XR Interaction Toolkit (3.2.1). I have implemented both Telepotation and Contuious Move for locomotion, and Snap turning for rotation. I also implemented grabing and other simple interactions using the toolkit's built-in components.

📚 References & Credits

The development of the Liquid Shader and specific VR mechanics was heavily inspired by the following resources. Huge thanks to these creators for sharing their knowledge:

Shader References:

📦 Assets Used

  • 3D Laboratory Environment: Models for the interior props (shelves, tables) and apparatus (Beakers, Flasks, Bunsen Burners) were sourced from the "3D Laboratory Environment with Apparatus" pack.
  • XR Interaction Toolkit: Unity Technologies.

Developed by Aditya Nayak

About

A VR based Chemistry lab

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors