{"id":21253064,"url":"https://github.com/abhaskumarsinha/nirvana","last_synced_at":"2025-07-11T01:33:18.296Z","repository":{"id":260053088,"uuid":"878371808","full_name":"abhaskumarsinha/Nirvana","owner":"abhaskumarsinha","description":"\"Dispel the ignorance of the illusionary world; transcend the game engine!\": presenting a Game Engine written on Python, extending support across multiple GPU devices with 3D rendering, PBR Renderer and much more!","archived":false,"fork":false,"pushed_at":"2024-10-29T08:49:17.000Z","size":267,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-29T09:20:43.673Z","etag":null,"topics":["3d","3d-game-engine","3d-graphics","3d-rendering","3d-rendering-engine","game-engine","gamedev","lambert","lambertian-shading","pbr","pbr-shading","python","rendering"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abhaskumarsinha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-25T09:13:02.000Z","updated_at":"2024-10-29T08:49:20.000Z","dependencies_parsed_at":"2024-10-29T09:43:10.517Z","dependency_job_id":null,"html_url":"https://github.com/abhaskumarsinha/Nirvana","commit_stats":null,"previous_names":["abhaskumarsinha/nirvana"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhaskumarsinha%2FNirvana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhaskumarsinha%2FNirvana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhaskumarsinha%2FNirvana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhaskumarsinha%2FNirvana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhaskumarsinha","download_url":"https://codeload.github.com/abhaskumarsinha/Nirvana/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225669616,"owners_count":17505386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","3d-game-engine","3d-graphics","3d-rendering","3d-rendering-engine","game-engine","gamedev","lambert","lambertian-shading","pbr","pbr-shading","python","rendering"],"created_at":"2024-11-21T03:49:49.741Z","updated_at":"2025-07-11T01:33:18.278Z","avatar_url":"https://github.com/abhaskumarsinha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nirvana-3D\n![nirvana-3d-high-resolution-logo-transparent](https://github.com/user-attachments/assets/ed1438f3-f74d-424c-b770-0ef1b60a0346)\n##### [[`LOGO CREDITS`]](https://logo.com) [[`LICENSE`]](https://github.com/abhaskumarsinha/Nirvana-3D/blob/main/LICENSE) [[`Container Model Artist: jrgubric`]](https://free3d.com/user/jrgubric)\n*Dispel the ignorance of the illusionary world; transcend the game engine!*: presenting a Game Engine written on Python, extending support across multiple GPU devices with 3D rendering, PBR Renderer and much more!\n# The Engine is Currently WIP!! ⚠️\n\n## Abstract\n**Nirvana 3D** is an experimental 3D graphics and game engine written in Python, built to explore the fundamentals of 3D rendering and engine design. Designed initially for offline rendering, Nirvana 3D can import and render 3D OBJ models with basic materials and lighting. The engine currently focuses on educational purposes, providing a platform for understanding and developing essential 3D engine components before transitioning to real-time rendering.\n### Features\n- **3D Model Import**: Supports importing 3D OBJ models with UV mapping for texture and material rendering.\n- **Rendering Techniques**: Renders scenes using solid face rendering and Lambert shading, simulating diffuse lighting.\n- **Camera Systems**: Supports both orthographic and perspective cameras, offering flexibility for various visual perspectives.\n- **Basic Lighting**: Implements sunlight-based directional lighting to simulate environmental lighting.\n- **Transformations**: Supports transformations like translation, rotation, and scaling for models and objects within the scene.\n- **Visualization**: Renders directly to Python’s `matplotlib`, allowing easy visualization of 3D scenes even in environments without a dedicated graphics API.\n### Future Development\nNirvana 3D is in its early stages, with plans to enhance performance and extend its capabilities, including:\n\n- **GPU Acceleration**: Shift from CPU-bound rendering to GPU-based processing for real-time rendering performance.\n- **Physically Based Rendering (PBR)**: Introduce advanced shading models and PBR for realistic lighting and material rendering.\n- **Additional Lighting Types**: Expand beyond directional lighting to support point, spot, and area lights.\n- **User Controls**: Add advanced interactivity with camera and object manipulation controls.\n- **Collision Detection**: Incorporate collision detection for basic physics interactions within the engine.\nNirvana 3D aims to eventually evolve into a versatile, Python-powered 3D engine for educational and experimental purposes. Contributions and suggestions are welcome to help shape its future!\n\n## Screenshots\nhttps://github.com/user-attachments/assets/a5e81ef1-5c15-4556-bc50-1b70789a2dce\n\n*3D Models interacting with lights in Lambertian mode.*\n![nirvana_renderer](https://github.com/user-attachments/assets/3cf0f478-010d-47b7-9864-de012877af18)\n![nirvana_renderer (1)](https://github.com/user-attachments/assets/dec865a0-f39e-484b-945b-ffa407046d82)\n*Rendering a 3D Cube with Nirvana-3D logo on it.*\n![container_rendering](https://github.com/user-attachments/assets/f2173d4f-0cd1-47a6-9b93-fe6dfb07f883)\n*A 3D rendering container Model imported in Nirvana and being rendered with solid face.*\n\n![output_video (3)](https://github.com/user-attachments/assets/5b8d3a95-b954-4eb4-9753-23fef85d074b)\n\n![PBR_demonstration in Nirvana 3D](https://github.com/user-attachments/assets/ac829491-4962-472f-b644-f73a570b8f69)\n![PBR_demonstration in Nirvana 3D](https://github.com/user-attachments/assets/854f8df7-5b3c-422a-9114-96a504a1a470)\n![PBR_demonstration in Nirvana 3D](https://github.com/user-attachments/assets/f93e606b-de1b-4709-a4bb-ccff49a462a2)\n\n*PBR Solidface rendering for fresnel values = 0.5, 0.4, 0.4 above.*\n\n\n*A 3D rendering video of a Container Model being rendered frame wise in Nirvana 3D.*\nModel source: https://free3d.com/3d-model/container-169022.html\nArtist Credits: [[`jrgubric`]](https://free3d.com/user/jrgubric)\n\n\n\n## Getting Started\n\n#### 1. Render a cube with a diffuse texture and lambert shading on CPU\n```python\n# Importing core classes for objects, lighting, camera, scene, and materials\nfrom Nirvana.objects import *\nfrom Nirvana.lights import *\nfrom Nirvana.camera import *\nfrom Nirvana.scene import *\nfrom Nirvana.material import *\n\n# Initialize a base material with a texture\nnirvana_texture = BaseMaterial('./nirvana.png')\n\n# Create a cube object and apply transformations\ncube1 = cube.Cube()\ncube1.rotate(10, 'x')               # Rotate cube by 10 degrees along the x-axis\ncube1.rotate(10, 'y')               # Rotate cube by 10 degrees along the y-axis\ncube1.triangulate()                 # Convert cube faces into triangles for rendering\ncube1.calculate_tangents()          # Calculate tangents for proper texture mapping\ncube1.set_material(nirvana_texture) # Apply the texture material to the cube\n\n# Create light sources to illuminate the scene\nsunlight = light.LightSource(orientation=(-0.5, -1, 0), color=(135, 206, 235))  # Primary sunlight with color\nsunlight2 = light.LightSource(orientation=(0.5, -1, 0.5), color=(1, 1, 1), intensity=0.2)  # Secondary light with low intensity\n\n# Set up the camera for the scene\ncamera_ = camera.Camera(d=10, f=30)  # Position the camera with specified distance and focal length\n\n# Create and configure the scene\nscene = scene.Scene()\nscene.register_object(cube1, 'defaultCube')  # Add cube to the scene with an identifier\nscene.register_object(sunlight, 'light')     # Register the main light source\nscene.register_object(sunlight2, 'light2')   # Register secondary light source\nscene.register_object(camera_, 'cam')        # Register camera in the scene\nscene.set_active_camera('cam')               # Set the active camera for rendering\n\n# Configure rendering settings and render the scene\nscene.pixel_density = 50                      # Set pixel density for render resolution\nscene.render('lambert').savefig('nirvana_renderer.jpg', dpi=500)  # Render in lambert shading mode and save as image\n```\n\n#### 2. Rendering an *.obj model file in solidface mode\n```python\n# Import core modules for camera, lights, materials, 3D objects, and scene setup\nfrom Nirvana.camera import *\nfrom Nirvana.lights import *\nfrom Nirvana.material import *\nfrom Nirvana.objects import *\nfrom Nirvana.scene import *\n\nimport numpy as np  # Import NumPy for possible transformations or calculations\n\n# Initialize 3D objects to represent containers in the scene\ncontainer = Object3D()          # First container object\ncontainer_2 = Object3D()        # Second container object\n\n# Load 3D model and apply transformations to the first container\ncontainer.load_obj('Container.obj')    # Load OBJ file for the container model\ncontainer.translate(5, -50, 500)       # Position the container in 3D space\ncontainer.rotate(10, 'y')              # Rotate the container around the y-axis\ncontainer.calculate_tangents()         # Calculate tangents for texture mapping\n\n# Load and transform a second instance of the container model\ncontainer_2.load_obj('Container.obj')  # Load the same OBJ file for second container\ncontainer_2.translate(150, -50, 300)   # Position second container differently\ncontainer_2.rotate(-10, 'y')           # Rotate the second container around the y-axis\ncontainer_2.calculate_tangents()       # Calculate tangents for consistent texture mapping\n\n# Define lighting sources to illuminate the scene\nsunlight = LightSource(orientation=(-0.5, -1, 0), color=(135, 206, 235), intensity=0.3)  # Main directional light\nbacklight = LightSource(orientation=(0.5, -1, 0), intensity=0.7)                        # Secondary light for depth\n\n# Set up the camera for scene framing and perspective\ncamera = Camera(f=20, d=30)            # Define camera with focal length and distance\n\n# Create the scene and register objects, lights, and camera\nscene = Scene()\nscene.register_object(container, 'container')       # Register first container with identifier\nscene.register_object(container_2, 'sec_container') # Register second container\nscene.register_object(sunlight, 'sunlight')         # Register main light source\nscene.register_object(backlight, 'backlight')       # Register secondary light source\nscene.register_object(camera, 'cam')                # Register camera in the scene\n\n# Set the active camera for rendering\nscene.set_active_camera('cam')\n\n# Render the scene using solid face rendering and save the output image\nscene.render('solidface').savefig('./container_rendering.jpg', dpi=500)  # Save high-resolution render\n```\n\n#### 3. PBR Rendering on GPU (OpenGL 2.x) using HDRi Lighting\n\n```python\n# Importing core classes for objects, lighting, camera, scene, and materials\nfrom Nirvana.objects import *\nfrom Nirvana.lights import *\nfrom Nirvana.camera import *\nfrom Nirvana.scene import *\nfrom Nirvana.material import *\n\n# Download the material from Free PBR website: https://freepbr.com/product/ravine-cliff-pbr/\n# Use blender format and extract the contents of the zip `ravine-cliff-bl` in the script folder.\n\n# Initialize a base material with a texture\nnirvana_texture = BaseMaterial(diffuse_path = 'ravine-cliff-bl/ravine-cliff_albedo.png', \n                               normal_path = 'ravine-cliff-bl/ravine-cliff_normal-ogl.png', \n                               ao_path = 'ravine-cliff-bl/ravine-cliff_ao.png',\n                               roughness_path = 'ravine-cliff-bl/ravine-cliff_roughness.png',\n                               metallic_path = 'ravine-cliff-bl/ravine-cliff_metallic.png',\n                                load_all_channels = True)\n\n# Create a cube object and apply transformations\ncube1 = cube.Cube()\ncube1.rotate(10, 'x')               # Rotate cube by 10 degrees along the x-axis\ncube1.rotate(10, 'y')               # Rotate cube by 10 degrees along the y-axis\ncube1.scale(2)\ncube1.triangulate()                 # Convert cube faces into triangles for rendering\ncube1.calculate_tangents()          # Calculate tangents for proper texture mapping\ncube1.set_material(nirvana_texture) # Apply the texture material to the cube\n\n# Create a cube object and apply transformations\ncube2 = cube.Cube()\ncube2.rotate(10, 'x')               # Rotate cube by 10 degrees along the x-axis\ncube2.rotate(-10, 'y')               # Rotate cube by 10 degrees along the y-axis\ncube2.scale(2)\ncube2.translate(2, 0, 0)\ncube2.triangulate()                 # Convert cube faces into triangles for rendering\ncube2.calculate_tangents()          # Calculate tangents for proper texture mapping\ncube2.set_material(nirvana_texture) # Apply the texture material to the cube\n\n# Create light sources to illuminate the scene\nsunlight = light.LightSource(orientation=(-0.5, 1, -1), color=(135, 206, 235), intensity = 2)  # Primary sunlight with color\nsunlight2 = light.LightSource(orientation=(0.5, -1, 0.5), color=(1, 1, 1), intensity = 1.5)  # Secondary light with low intensity\n\n# Set up the camera for the scene\ncamera_ = camera.Camera(d=10, f=30)  # Position the camera with specified distance and focal length\n\n# Create and configure the scene\nscene = scene.Scene()\nscene.register_object(cube1, 'defaultCube')  # Add cube to the scene with an identifier\nscene.register_object(cube2, 'Cub2')\nscene.register_object(sunlight, 'light')     # Register the main light source\nscene.register_object(sunlight2, 'light2')   # Register secondary light source\nscene.register_object(camera_, 'cam')        # Register camera in the scene\nscene.set_active_camera('cam')               # Set the active camera for rendering\n\n# Get HDR image file *.hdr from https://polyhaven.com/a/rogland_moonlit_night and place the file rogland_moonlit_night_2k.hdr\n# in the same script as the code location. Note, Nirvana supports ONLY *.hdr for now and no *.exr yet!\nscene.import_lights_to_scene(scene.load_lights_from_hdr('sky_light.hdr', intensity_factor=0.5, color_tuner = 0.6))\n\nscene.render_gpu('pbr')\n```\n\n## Project Name and Slogan\n### Nirvana\nThe name \"Nirvana\" signifies the quest for enlightenment and liberation from the complexities of traditional game development. It reflects our mission to empower developers to explore the fundamentals of 3D rendering and engine design without the usual barriers.\n\n### Slogan: \"Dispel the ignorance of the illusionary world; transcend the game engine!\"\nOur slogan captures the very idea to simplifying 3D graphics and provide a deeper understanding of rendering techniques. We aim to help developers go beyond conventional game engines, encouraging exploration and innovation in the realm of 3D graphics.\n\n\n\n# References\n- Akenine-Moller, Tomas, Eric Haines, and Naty Hoffman. Real-time rendering. AK Peters/crc Press, 2019.\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhaskumarsinha%2Fnirvana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhaskumarsinha%2Fnirvana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhaskumarsinha%2Fnirvana/lists"}