{"id":13692947,"url":"https://github.com/miloyip/light2d","last_synced_at":"2025-04-04T12:08:37.157Z","repository":{"id":54308295,"uuid":"109523949","full_name":"miloyip/light2d","owner":"miloyip","description":"Light rendering in 2D","archived":false,"fork":false,"pushed_at":"2022-01-08T10:51:29.000Z","size":11017,"stargazers_count":863,"open_issues_count":4,"forks_count":125,"subscribers_count":61,"default_branch":"master","last_synced_at":"2025-03-28T11:09:04.596Z","etag":null,"topics":["constructive-solid-geometries","global-illumination","graphics-programming","graphics2d","monte-carlo-integration","signed-distance-field"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miloyip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-04T19:27:15.000Z","updated_at":"2025-03-26T13:25:14.000Z","dependencies_parsed_at":"2022-08-13T11:40:14.409Z","dependency_job_id":null,"html_url":"https://github.com/miloyip/light2d","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miloyip%2Flight2d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miloyip%2Flight2d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miloyip%2Flight2d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miloyip%2Flight2d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miloyip","download_url":"https://codeload.github.com/miloyip/light2d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174423,"owners_count":20896078,"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":["constructive-solid-geometries","global-illumination","graphics-programming","graphics2d","monte-carlo-integration","signed-distance-field"],"created_at":"2024-08-02T17:01:03.793Z","updated_at":"2025-04-04T12:08:37.139Z","avatar_url":"https://github.com/miloyip.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# light2d\nThis project illustrates light rendering in 2D with C.\n\nAll samples output PNGs with [svpng](https://github.com/miloyip/svpng).\n\nLicense: public domain.\n\n# Basic\n\nUse Monte Carol integration and ray marching of signed distance field (SDF) to render a emissive circle.\n\nSource code: [basic.c](basic.c)\n\nUniform sampling (64 samples per pixel):\n\n![ ](basic_a64.png)\n\nUniform sampling with different number of samples per pixel:\n\n![ ](basic_varyingn.png)\n\nStratified sampling (64 samples per pixel):\n\n![ ](basic_b64.png)\n\nJittered sampling (64 samples per pixel):\n\n![ ](basic_c64.png)\n\nVarious sampling method side-by-side comparison (64 samples per pixel)::\n\n![ ](basic_varyingsampling.png)\n\n# Constructive Solid Geometry\n\nSource code: [csg.c](csg.c)\n\nUse union operation for creating multiple shapes:\n\n![ ](csg_scene.png)\n\nVarious CSG operations on two circles:\n\n![ ](csg_ops.png)\n\n# Shapes\n\nSource code: [shapes.c](shapes.c)\n\nExamples of various shapes defined by SDF:\n\n![ ](shapes.png)\n\n![ ](m.png)\n\n# Reflection\n\nSource code: [reflection.c](reflection.c)\n\n![ ](vector_reflect.png)\n\nTest scene with two boxes:\n\n![ ](reflection_boxscene.png)\n\nVisualization of SDF gradient, which is approximated by central difference:\n\n![ ](reflection_boxgradient.png)\n\nReflection via recursive tracing:\n\n![ ](reflection_box.png)\n\nConcave mirror scene generates caustics effect:\n\n![ ](reflection_concavemirror.png)\n\n# Refraction\n\nSource code: [refraction.c](refraction.c)\n\nApplying Snell's law to compute refraction direction. Total internal reflection is also handled.\n\n![ ](vector_refract.png)\n\nTest scenes:\n\n![ ](refraction_box.png)\n\n![ ](refraction_concavelens.png)\n\n![ ](refraction_convexlens.png)\n\n![ ](refraction_semicircular.png)\n\n![ ](m2.png)\n\n# Fresnel Reflectance\n\nSource code: [fresnel.c](fresnel.c)\n\nApplying Fresnel equation to compute reflectance of dielectric medium.\n\n![ ](vector_fresnel.png)\n\nWithout Fresnel:\n\n![ ](refraction_montage.png)\n\nWith Fresnel term:\n\n![ ](fresnel_montage.png)\n\n# Beer-Lambert\n\nSource code: [beerlambert.c](beerlambert.c) [beerlambert_color.c](beerlambert_color.c)\n\nApplying Beer-Lambert law to simulate absorption of light in medimum.\n\n![ ](beerlambert_montage.png)\n\n![ ](beerlambert_color.png)\n\n![ ](heart.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiloyip%2Flight2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiloyip%2Flight2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiloyip%2Flight2d/lists"}