Skip to content

safwansatil/3d-Renderer-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

3d render engine

3D Renderer in Java

A 3D renderer written in pure Java with no external libraries — just Swing, math, and a lot of triangles!

This project builds a rotating, shaded sphere using triangle subdivision, z-buffering, and basic flat shading.


Features

  • Renders 3D triangles onto a 2D panel
  • Sphere-like shape using triangle inflation
  • Real-time rotation using sliders
  • Flat shading based on light angle
  • Z-buffering for correct depth sorting
  • All rendering handled pixel-by-pixel using BufferedImage

Preview

Preview


How It Works

  • Tetrahedron → Sphere:
    A basic tetrahedron is subdivided multiple times using the inflate() function to approximate a sphere.

  • Matrix Transformations:
    Rotation is applied via 3x3 matrix multiplication (Matrix3) based on slider values.

  • Flat Shading:
    Calculates light intensity using surface normals and simple dot product.

  • Z-buffer:
    Keeps track of depth values for each pixel to render the closest triangle only.


Controls

  • Horizontal Slider (Bottom): Rotate left/right (rotates around XZ plane)
  • Vertical Slider (Right): Rotate up/down (rotates the object around YZ plane) The 3D shape updates in real-time as you drag the sliders.

Dependencies

None!
Built only with core Java:

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;

Open to feedback, constructive criticism, and collaboration!

Feel free to fork, suggest improvements, or just reach out — I'm always learning and happy to connect.

About

A 3d renderer made with Java without any external dependencies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages