Skip to content

CGS-IITKGP/fog-shader

Repository files navigation

Contributors Forks Stargazers Issues MIT License


image

Fog Shader

Volumetric fog shader using GLSL

Table of Contents

About The Project

This project is a C++ and OpenGL implementation of a volumetric fog shader. It demonstrates a common computer graphics technique used to add depth, atmosphere, and mood to a 3D scene.

(back to top)

Project Overview

  • Procedural Noise and Fog - Dynamic, atmospheric fog is created using multiple layers of procedural noise, making it appear turbulent and natural. The fog's density realistically increases with distance and decreases with altitude, adding depth to the scene.

  • RayMarching - This technique renders the procedural landscape by casting a ray for each pixel and "marching" it through the scene. The final color is determined by where this ray intersects with the terrain surface.

  • Terrain Formation - The terrain's shape is procedurally generated using layered sine waves to create rolling hills and valleys. The surface is then shaded by calculating its normals for realistic lighting and applying a base texture color.

  • Main Execution - This function serves as the entry point, setting up the animated camera's position and view for the scene. It then coordinates the raymarching and shading processes for every pixel to produce the final image.

Getting Started

To set up a local instance of the application, follow the steps below.

Prerequisites and Installations

The environment needed is just the shadertoy (Available online, so no further installations required)

(back to top)

Usage

This shader is designed to run directly in a web browser on the Shadertoy platform. No local installation or setup is required.

  1. View the shader live:

  2. Experiment with the code:

    • The shader is interactive in the sense that you can edit the code directly on the Shadertoy website to see real-time changes.
    • Try modifying these constants at the top of the code to see how they affect the visuals:
      • density_fog: Increase this value for thicker, more opaque fog, or decrease it for a lighter haze.
      • height_fog: Adjust this to control how the fog settles in the valleys versus on the hilltops.
      • lightdirn: Change the vec3 values to alter the direction of the light source and see how shadows and highlights are affected.

(back to top)

Contact

Maintainer(s)

The currently active maintainer(s) of this project.

Creator(s)

Honoring the original creator(s) and ideator(s) of this project.

(back to top)

Additional documentation

(back to top)

About

Volumetric fog shader using GLSl

Resources

License

Contributing

Stars

Watchers

Forks