{"id":17038223,"url":"https://github.com/bchao1/go-render","last_synced_at":"2025-04-12T13:52:01.993Z","repository":{"id":113819547,"uuid":"286937504","full_name":"bchao1/go-render","owner":"bchao1","description":"🎦 3D renderer in Go.","archived":false,"fork":false,"pushed_at":"2020-08-18T09:42:46.000Z","size":70067,"stargazers_count":19,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T08:37:05.412Z","etag":null,"topics":["3d","3d-graphics","camera","computer-graphics","geometry","go","golang","light","rasterization","rendering","texture"],"latest_commit_sha":null,"homepage":"","language":"Go","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/bchao1.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-12T06:40:56.000Z","updated_at":"2024-10-02T19:24:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"913bd7b2-022c-4faf-900e-97ea88d68bf5","html_url":"https://github.com/bchao1/go-render","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/bchao1%2Fgo-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchao1%2Fgo-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchao1%2Fgo-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchao1%2Fgo-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bchao1","download_url":"https://codeload.github.com/bchao1/go-render/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248575961,"owners_count":21127301,"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-graphics","camera","computer-graphics","geometry","go","golang","light","rasterization","rendering","texture"],"created_at":"2024-10-14T08:56:17.725Z","updated_at":"2025-04-12T13:52:01.972Z","avatar_url":"https://github.com/bchao1.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-render\n\nA simple renderer (rasterization-based) written in Go.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg width=\"400\" src=\"./results/light3/light3.gif\"\u003e\n    \u003cimg width=\"400\" src=\"./results/camera2/camera.gif\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg width=\"800\" src=\"./results/dragon.png\"\u003e\n\u003c/p\u003e\n\nThe OG [tinyrenderer](https://github.com/ssloy/tinyrenderer) project helped me alot. It's amazing stuff, and I highly recommend everyone check it out.\n\n## Usage\nThe code is pretty self-contained. I only used a 3rd-party library `imaging` to flip images vertically. \n\u003cbr\u003e\n\u003cbr\u003e\nTo do your custom render:\n```\ngo run render.go \u003cpath to .obj file\u003e \u003cpath to texture file\u003e\n```\nFor example, see `run.sh`:\n```\ngo run data/obj/bunny_2.obj data/textures/bunny_texture.jpg\n```\n\nOf course, you can first build `render.go`, and then run the executable:\n```\ngo build render.go\n./render \u003cpath to .obj file\u003e \u003cpath to texture file\u003e\n```\n\n### Customization\nYou could also play with some other parameters (light direction, camera position, spectral lighting, and etc) in `render.go`.\n- `eye`: The camera position. Default is (0, 0, 1).\n- `center`: Position the camera is looking at Default is (0, 0, 0).\n- `up`: The vertical axis of the camera. Default is (0, 1, 0), which is the y-axis.\n- `lightDir`: Light ray direction. Default is (0, 0, -1), which means the light is parellel to user's eye.\n- `specCoeff`: Weight of spectral lighting. (For the shiny dragon above, I used 20.0)\n- `imageHeight`: Pixel height of output image.\n- `background`: Whether to color output image background black. If not, then output image has transparent background.\n- `outFile`: Render output file path.\n- `defaultFill`: If no texture is specified, use this color.\n\n## Demo \n\n\u003e Basics\n\n|||\n|--|--|\n|Wireframe|Triangle rasterization|\n|![img](./results/basic/wireframe.png)|![img](./results/basic/triangle_color.png)|\n\n\u003e Shading\n\n|Flat shading|Gouraud shading|Phong shading|\n|--|--|--|\n|![img](./results/shading/flat.png)|![img](./results/shading/gouraud.png)|![img](./results/shading/phong.png)|\n|![img](./results/shading/flat_detail.png)|![img](./results/shading/gouraud_detail.png)|![img](./results/shading/phong_detail.png)|\n\n\u003e Perspective\n\n|||||\n|--|--|--|--|\n|![img](results/project/project_5.0.png)|![img](results/project/project_2.0.png)|![img](results//project/project_1.5.png)|![img](results/project/project_1.0.png)|\n\n\u003e Textures\n\nKudos to the author of [this article](https://blenderartists.org/t/uv-unwrapped-stanford-bunny-happy-spring-equinox/1101297) for providing custom Stanford bunny texture files.\n\n|Colored|Terracotta|\n|--|--|\n|![img](./results/textures/bunny_color.png)|![img](./results/textures/bunny_terracotta.png)|\n\n\u003e Camera\n\n|||||\n|--|--|--|--|\n|![img](./results/camera/1.png)|![img](./results/camera/2.png)|![img](./results/camera/3.png)|![img](./results/camera/4.png)|\n|![img](./results/camera/8.png)|![img](./results/camera/7.png)|![img](./results/camera/6.png)|![img](./results/camera/5.png)|\n\n\u003e Light\n\n|||||\n|--|--|--|--|\n|![img](./results/light/-10.png)|![img](./results/light/-5.png)|![img](./results/light/-2.png)|![img](./results/light/-1.png)|\n![img](./results/light/10.png)|![img](./results/light/5.png)|![img](./results/light/2.png)|![img](./results/light/1.png)|\n\n\u003e Specular lighting\n\nThe stronger specular lighting is, the more \"glossy\" the object surface becomes. I simply used uniform power for each pixel since specular intensity is not specified in my texture files.\n|No specular|Some specular (used)|Intense specular|\n|--|--|--|\n|![img](./results/specular/none.png)|![img](./results/specular/moderate.png)|![img](./results/specular/strong.png)|\n\n## `.obj` sources\n- https://www.prinmath.com/csci5229/OBJ/index.html\n- https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html\n- https://groups.csail.mit.edu/graphics/classes/6.837/F03/models/\n- https://casual-effects.com/data/\n- https://github.com/alecjacobson/common-3d-test-models\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbchao1%2Fgo-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbchao1%2Fgo-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbchao1%2Fgo-render/lists"}