https://github.com/selimanac/defold-3D-outline-shader
https://github.com/selimanac/defold-3D-outline-shader
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/selimanac/defold-3D-outline-shader
- Owner: selimanac
- Created: 2024-09-05T15:21:46.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-05T15:30:05.000Z (9 months ago)
- Last Synced: 2025-02-05T02:11:20.550Z (4 months ago)
- Language: Lua
- Size: 15.6 MB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-defold - 3D Outline Shader
README
# Defold 3D Outline Shader


Simple outline shader for 3D models using STENCIL and INVERTED HULL techniques.
The outline vertex shader uses 'normal' to move the vertices along their [normal vector](https://github.com/selimanac/defold-3D-outline-shader/blob/0ddf4f56a6edabda76f0257634acf72f7e8b4d81/outline-shader/outline.vp#L22). For objects with sharper corners, such as cubes, you may notice visible gaps in the outline. Any model with sharp angles will display these kinds of artifacts.
If you want better results, including sharper corners, consider using vertex color attributes. To use vertex colors, you can comment out [this line](https://github.com/selimanac/defold-3D-outline-shader/blob/0ddf4f56a6edabda76f0257634acf72f7e8b4d81/outline-shader/outline.vp#L22) and uncomment [that one](https://github.com/selimanac/defold-3D-outline-shader/blob/0ddf4f56a6edabda76f0257634acf72f7e8b4d81/outline-shader/outline.vp#L23).
More info can be found here: https://ameye.dev/notes/rendering-outlines/
There are better methods available if you're interested: https://roystan.net/articles/outline-shader/
Additionally, there's a simple Lua helper module for easy integration with your render script.