This week’s post is entirely about shaders.
My partner has been out of town for the past week so I found myself with a lot of free time in the evenings to work on the game. Usually, though, by the time the evening comes I’ve already been working on the game for 10+ hours. To try and combat fatigue and burnout I’ve spent the time working on shaders that can later be used in the game but also can stand on their own.
This so far has worked out great since it allows me to do something creative and semi-disconnected from the main game but still creates usable content.
ScanAfter
posting last week’s water shader bug to the Beautiful Fails thread and getting some positive feedback I tried to recreate the effect in a more controlled fashion with its own shader. Having genuine rather than accidental control over an effect really gives you the ability to take it further and experiment with variations. The gif on the
left is the base attempt at trying to recreate the effect and the gif on the
right is after some experimentation.
Scanningggggggg It’s a fairly simple effect using the difference between the world Y-position of each fragment and a scrolling world value that has been modulus’d (modulated?). I got some questions on Twitter about how it syncs across objects without using UVs. I made this gif to show that it's a world space effect so it will sync across anything assigned that shader in world space.
Transforms don't do nothin' I also wrote
a quick and dirty 2D version on ShaderToy for those who were interested. All that’s needed to use it in a 3D space is to swap out uv.x and uv.y for vertex world positions.
EmissiveThis is an effect that started as a shader but is now more of a game object system.
I’ve gotten really into
the art of Beeple these days and I’m always envious of the beautiful stuff he does with emissive volumes/materials in his renders.
I don't like posting other peoples work in my devlog, but this is too cool. While I knew I wouldn’t achieve the same quality as a Cinema4D render, I wanted to see how easily I could get emissive volume objects working in real-time.
My approach was to create a volume and fill it with point light sources that attempt to match the volume as closely as possible. This would allow me to experiment using only pre-existing engine systems. I also knew I wanted to be able to warp the shape in interesting ways, so I settled on a procedurally generated tube. It’s a shape that can be warped easily with sine waves and can be represented convincingly by a strip of point lights.
First emissiveExperiments As you may notice all these gifs are monochrome. To get objects around the emissive to respond correctly to the bulging and shrinking of the tube I had to send an extra bit of information with each light when binding values to the lighting shader. Since this didn’t fit in with my existing lighting shaders I had to write a new one from scratch. It was pretty basic: didn’t account for directional or ambient lights, no specular term, no texturing. It also meant I had to work with objects which had been specially tagged as “lit by emissive” which isn’t well integrated into my tools so I would have to restart the game every time I wanted to spawn a new object.
The next night I folded and I modified the base lighting shaders to accept the new lighting information. This opened up a lot of possibilities now that I could light any object and scene with the emissive tube. This also meant that it wasn’t really a shader anymore, just a series of lights moving in a prescribed fashion and a mesh.
The White WhaleArt.gifSwamp
Like I said earlier none of these effects were built with any specific purpose in the game, but you can be sure I will be absolutely filling the game with them now that they’re up and running.
Thanks for checking out the post and if you want to see any new cool stuff I’m cooking up, come
follow me at @owendeery!