Learn by example
August 26, 2024 · View on GitHub
Note
This page is still very much in development. There's already a fair amount of content, but nowhere as much as I'd like. The accessibility and immediacy also need to be severely improved. Please have some leniency.
This is a list of Kage shaders that you may use as references or in order to learn specific techniques. It's recommended that you have some basic knowledge about shaders and / or Kage before diving into this, but we have no bouncer at the door.
The shaders are roughly sorted from simple to complex, and they include tags that indicate what topics they touch on. Here's the full list of tags, which you may use to ctrl + f if you are looking for anything in particular:
geometry, 3D, lighting, triangles, deformation, projection, masking, animation, UI, FX, screen, sprite, image, color, artistic.
We have also created a page for community contributed examples. Check those out too and feel free to contribute your own!
Tip
Run the examples directly from the terminal!
go run github.com/tinne26/kage-desk/examples/learn/{example-folder-name}@latest
go run github.com/tinne26/kage-desk/examples/learn/filled-circle@latest
Here we go!
- Filled circle: geometry.
- Unfilled circle: geometry.
- Gamma correction: color.
- Filled triangle: geometry.
- Unfilled triangle: geometry.
- Filled rounded rect: geometry, UI.
- Unfilled rounded rect: geometry, UI.
TODOFilled polygon: geometry.TODOUnfilled polygon: geometry.- Black and white: image, color.
- Simple tint: image, color.
- HSL hue rotation: image, color.
- Oklab chroma shift: image, color.
TODOPixelize: FX, image.TODOPixelize (sampled): FX, image.TODOBlur: FX, image.TODOGrain: screen, FX, animation.TODOVignette: screen, FX, ¿animation?.TODONoise: FX.- Sphere intersect dist: geometry, 3D.
- Sphere Phong: geometry, 3D, lighting.
TODOComplex wave: geometry, animation.TODOBézier conic curve: geometry.TODOBézier cubic curve: geometry.TODOComplex polygon: geometry.TODOSimple glow: sprite, FX.TODOSimple outline: sprite, FX.TODOBehind obstruction: masking, sprite.TODOBehind wall: masking, sprite.TODODynamic motion blur: FX, image, animation.TODOBreathing: sprite, animation, FX, deformation.TODOCharacter boost: sprite, FX, animation.TODOCharacter poison: sprite, FX, animation.TODOWindmill transition: image, animation.TODODestroy (disintegrate + spread): sprite, animation, FX.TODODestroy (cut + vanish): sprite, animation, FX.TODODestroy (spiral collapse): sprite, animation, FX.TODODestroy (radial crystal): sprite, animation, FX.TODOChromatic aberration: image, FX, color.TODOHit (pixelize + wave): sprite, animation, FX.TODOWater reflection: image, FX, projection, deformation, animation.TODOInside water: image, FX, deformation, animation.TODOHeat shimmer: image, FX, deformation.TODOCube: geometry, 3D, lighting.TODOAnimated cube: geometry, 3D, lighting, animation.TODOEbiten model: geometry, 3D, lighting, animation.TODORing loader: UI, projection, animation.TODOCylindrical HUD: UI, projection.TODOHemispherical HUD: UI, projection.TODOSMAA (antialiasing): screen, FX. https://github.com/iryoku/smaaTODOSubpixel antialiasing: screen, FX, color.TODOSimple moon phases: geometry, masking, animation.TODOGeodesic dome: geometry, 3D, triangles, lighting.TODORotating geodesic dome: geometry, 3D, triangles, animation, lighting.
At this point, I feel it's important to highlight that many fancy effects can also be achieved without shaders. Keep this in mind and avoid shader tunnel vision!
- Hit effect: compress the sprite with regular
GeoMtransformations. - Morphing: saturate both images to white with
ColorMtransformations, and then scale the first down and the second up at the same center position. You can create "pokemon evolution" effects or other kinds of morphs between two sprites. - Skews and transitions: you can use
GeoMto skew images, combine color blending operators, masks and other tricks to create screen transitions and all kinds of animated effects. - Alter states: it's easy to create flashes of different colors on characters to represent alter states, like poison, paralysis and others. Often you can add custom small animations to make these effects even much better.
- Manual effects with game art: outlines, glows, glitches and others can be done directly with art and animations. If you need a cool effect only in one specific situation, sometimes making the art for it might be easier than coding the shader.