WEEKLY UPDATE - shaders shaders AGAIN. but this time better. (Patreon)
Content
THEY4RE FUCKING WORKING
(after this very happy message, here's how I ended up doing it)
here's our real reactions
I made a reddit post asking for pointers & help (https://www.reddit.com/r/godot/comments/1tiwghz/shader_creation_help/ ) and a user named Silrar helped me out A LOT.
after his first comment, I applied what they said. and ended up here:
which is pretty cool, but something was weird. and after fiddling with it for a bit I noticed I needed to add an offset based on the position of the sprite, which I then figured out on my own how to calculate. which felt awesome (even if it's a pretty simple addition)
and after some more fiddling, here's how the scene tree looks.
but Silrar (again) suggested it would be more efficient to "just" render the sprite directly as stitches and build the game from there, that way we can bypass the entire "double viewport, one for the stitches layer and one for the colors" and do everything within a lil shader. So that's what I tried to do. (spoilers: it didn't take that long, shaders are easy (no))
BUT. now I have a shader that creates a beautiful stitched character, how do I align that character (and the scenery & other stuff) to the grid that's in another place entirely?
The solution was a simple 2d scene. And then you just stretch it over the main mesh with a viewport that gets read by the grid shader thing.
I felt pretty powerful by then. I had fixed a deadline, and beating it by a full week. So time to expand and try to figure out a 2D CAMERA SYSTEM. (yes, hubris struck).
First: I had to go digging on how to hook up a 2D camera to a viewport. Because there's apparently no direct option for it. And after several days of trying different things (and moving back and forth between the first and second method of rendering the entire game) I found a thread about people trying to do the same thing, and a dev making a custom extension of the viewport class that added the functionality. It felt like magic when it immediately worked (on ONE of the 2 rendering systems. The one deemed more efficient by famed reddit user Silrar
And then:
WHY NO ALIGN??? (you'll notice the character is fine, it's just a vertical offset, but the tree is completely misaligned). After MORE digging I found it was the CAMERA following the character not snapping to pixels. But the camera follow menu doesn't tell me much about how the following is working. and I NEED it to snap to pixels.
The route I'm going is : custom camera movements that move the camera instead of the world, or however godot uses the camera2d movement stuff. The camera position can be snapped to pixels. And it gives us quite a lot of control. Now we can just set up an area somewhere and when the player enters the area, the camera transitions to that new position. It seems pretty simple, but it wasn't as straightforward as I thought it was going to be at first. BUT it works. All thanks to the "snapped" function
And that's it for this week! Shader code is (mostly) done! I'll have to figure out the normal maps stuff at some point. But I think that's going to be pretty simple? (famous last words).
I've done some other bits & bobs, but nothing is working for real yet, so they'll be posted over here over the coming weeks, when I've had more time to make them work.
Anyway, thanks a lot for reading! See you soon!