8000 GitHub - AlexNewtown/light2d: Light rendering in 2D
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

AlexNewtown/light2d

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
< 8000 /td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

light2d

This project illustrates light rendering in 2D with C.

All samples output PNGs with svpng.

License: public domain.

Basic

Use Monte Carol integration and ray marching of signed distance field (SDF) to render a emissive circle.

Source code: basic.c

Uniform sampling (64 samples per pixel):

Uniform sampling with different number of samples per pixel:

Stratified sampling (64 samples per pixel):

Jittered sampling (64 samples per pixel):

Various sampling method side-by-side comparison (64 samples per pixel)::

Constructive Solid Geometry

Source code: csg.c

Use union operation for creating multiple shapes:

Various CSG operations on two circles:

Shapes

Source code: shapes.c

Examples of various shapes defined by SDF:

Reflection

Source code: reflection.c

Test scene with two boxes:

Visualization of SDF gradient, which is approximated by central difference:

Reflection via recursive tracing:

Concave mirror scene generates caustics effect:

Refraction

Source code: refraction.c

Applying Snell's law to compute refraction direction. Total internal reflection is also handled.

Test scenes:

Fresnel Reflectance

Source code: fresnel.c

Applying Fresnel equation to compute reflectance of dielectric medium.

Without Fresnel:

With Fresnel term:

Beer-Lambert

Source code: beerlambert.c beerlambert_color.c

Applying Beer-Lambert law to simulate absorption of light in medimum.

About

Light rendering in 2D

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 76.0%
  • TeX 13.6%
  • C++ 9.5%
  • Makefile 0.9%
0