Log In or Create Account
Back to Blog
DEVELOPMENT

5

803
Figuring Out Shader Graphs for Prettier Dioramas
1 year ago1,143 words
Graphical improvements! Technical stuff! Wow!!

I started off this week intending to figure out some story stuff, but thought I'd give my subconscious mind a chance to digest some ideas - including some in comments on ∞ the previous post ∞, as well as some others of my own - before diving in further. I wanted to be productive while waiting, though, so I got to work on some technical improvements I described in some previous post(s).

(I need to get back to the story stuff, but switching between the very different mental processes used for that stuff and this stuff tends to be tricky, so I wanted to get as far as I could with this before switching back.)

In aforementioned previous post, I included this mock-up of a diorama, where all tiles just used pixel textures:



After a week of figuring out Shader Graphs, I have this:



(It's a 6.5MB video and may take a moment to load; you can get a better look if you right-click and open the video in a new tab, on PC at least. Might want to right-click the video and turn on Loop if you do!)

Shaders are programs that determine how the graphics should be displayed, essentially. These days they can do all kinds of fancy things! Maybe they're more commonly called 'filters' on the player side of things? So you could enable a 'filter' to turn everything monochrome or psychedelic or something, which would be done with shaders.

In the past, I dabbled in the text-based shader code that Unity uses (HLSL), though it was all 'lower-level' than I had the patience for so I wasn't able to work magic with it or anything. I mostly used it for things like generating outlines around character models.

Since then, I've become aware of something called the Shader Graph, which either didn't exist in the version of Unity I've been using for Atonal Dreams, or I just never knew about it. It allows you to create shaders using a node-based visual graph.

For example, here's the Shader Graph that transforms a simple cube (well, two faces of a cube anyway) into the water, which uses no other textures or code:


I wanted to make a version where you could actually zoom in and read the text in case it'd be useful to anyone, but the chances of that didn't seem high enough to justify the effort of tediously stitching together screenshots.


Pretty easy to understand, right??

I made shaders for the water, for the dissolve effect when switching dioramas, and for the grass, which waves around in the wind in a way I find very satisfying. Everything feels more alive now, in my opinion at least.

Seems like every indie game uses lush BotW-like grass fields these days, so I assumed there might be some shader I could find online that'd easily procedurally generate it or something, such that I could just apply it to the simple cube tiles I'm using and have the blades magically appear with minimal effort. I didn't find such a magic solution, and the stuff I did find wasn't really working for me, so I ended up just writing my own grass-generating code as part of the blocks that areas are made of, which already use procedurally-generated meshes.

It seems to be some kind of meme that programmers' jobs often involve just googling a problem and directly copying-and-pasting someone else's solution, and in my experience that's often at least partly true. Here, though, I tried to find solutions to a bunch of issues, but without much luck. I even tried speaking with ChatGPT, though the stuff it gave me wasn't any good and the whole thing was just a waste of time. I ended up coming to solutions through fiddling around and thinking things through.

So I'm really quite happy with what I achieved this week, considering how much of it was spent successfully figuring out the solutions to novel problems mostly by myself. I was able to just sit down and work - and really get lost in it - for hours at a time, which I haven't been able to do for a while.

(Turns out the way I've set things up is comically unoptimised though, so I'll need to look into that next week.)



Also, I own a Discord server exclusively for my Patreon patrons, which is usually quite dead. I barely engage socially at all these days, and I'm not interested in the group-ness or real-time ephemerality of Discord in particular (I'd prefer either one-on-one or a forum), so I tend to avoid it, including my own server.

I often feel lonely, though, or unmotivated, and I have this longing to form some new community again as I have done several times in the past...

But sigh. There seems to have been some drama or something in there this week, and while I know I really should have gone and got involved in some way, I have less than zero interest in returning to the cat herding aspects of the old Fig Hunter days. It's tough enough doing several jobs' worth of creative work for relatively negligible pay (not that I don't appreciate what people do donate!), and adding community moderator on top of that would just be too much. I want to make stuff, not manage people.

It seems to have calmed down now, though, I hope?



Also, I finished uploading 13 'Playable Piano Pieces' to the YouTube channel I set up recently-ish for my music, as described and included in ∞ this post ∞. The plan was to do one a day, but they ended up being every few days towards the end, and I didn't bother mentioning finishing them all earlier because the numbers suggest minimal interest. Though I can't say my own interest in those specific pieces is very high; they're old, and I feel like they're a lot less interesting than stuff I've composed more recently. But I don't want to upload pieces I really like while the channel's still so small because they'll barely be seen and it'll feel like a waste.

I've got a bunch of other stuff to upload there, though, when I can find the time and motivation. I wish I were able to just make music exclusively since it's way faster than making games, but... oh well!



Oh, also: I heard back from one of the two counselling services I'd contacted. I did an phone assessment and was told I qualify for it, and I'll now be put on a waiting list... which is at least five months long. SIGH.

Maybe I'll hear back from the other one again before that though.

5 COMMENTS

GrayNine35~1Y
I think the world is already looking better with your shader experiment. A bit of movement (like the the trees blowing in the wind and the NPC having an idle animation) and I think the world would be quite presentable! I really like how the water looks now, especially how the bottom of the diorama makes it clear the waves aren't just a texture.

I'm in a number of Patreon Discords, and the creator almost never needs to do any moderation work- usually one assigned moderator does the job, or a few more if the Discord is open to non-patrons (usually the paywall keeps out most of the trolls). Perhaps assigning one would help with future incidents, assuming there's someone you both trust and is willing to fill the role.

I've been listening to the piano pieces! I do agree that they're not your *best* work, but they're still enjoyable, and I've found myself coming back to re-listen to a few of them, so thank you for uploading them (and the Dreamons theme, I love the chaotic feel to it- almost circus-ey?)

Even if the waiting list is until December, you know you have *a* counseling opportunity in your future, so even if the other one falls through you have that going for you!
1
Tobias 1115~1Y
The grass is moving quite a bit, and the NPCs do have idle animations, so are those not perceptible in the example here? I suppose they'd be clearer if you were actually exploring the world yourself rather than just viewing an image/video.

I got thinking about how I really do need to choose a moderator, but I tried a while back and either people weren't interested (which is fair enough; I'm not either), or I worried they'd try and enforce rules motivated by political opinions I don't share. When I chose moderators for my communities in the past, I was more engaged and got more accustomed to how individual people thought and made decisions, but now I keep my distance and as such lack experience with anyone to assess their eligibility on. I'd need to engage more, which is what I'm avoiding in the first place.

I appreciate that you didn't hate the piano pieces! Also I always find it interesting how non-composers (I'm assuming you don't compose?) interpret music, by comparing it to familiar stuff. I'm guessing you're (maybe subconsciously) thinking of a piece called Entrance of the Gladiators, which is the stereotypical clown/circus music, which uses atonality/chromaticism in a way not dissimilar to the Dreamons piece I composed, and which I think is probably the most prominent well-known piece to do that?

[LINK] mentions almost exclusively classical pieces, apparently! (The whole-tone scale and atonality aren't the same, but are similar enough to be compared, I suppose.)
1
GrayNine35~1Y
Yeah, looking closer I can see the grass animated; it didn't show up very well on my phone at the time. And yeah, I don't compose; it's also possible that other media with circus music purposely draws on Entrance of the Gladiators, perpetuating the "circus" feel to chromaticism.
1
Tama_Yoshi82~1Y
Shaders are one of those aspects of programming that you can just not have any knowledge of despite being very familiar with code. It's very niche and really unlike other stuff, so it doesn't surprise me that finding details about it is hard.

I couldn't tell you how to make realistic water at all, I wonder how you came up with this (seemingly quite complex) algorithm. Every time I heard about simulated water, it was in the context of blender plugins and academic publications (e.g. TwoMinutePapers). But I don't think you can use blender plugins readily with Unity? Idk. Interconnectivity and technology!!!

I presume the grass algorithm mostly uses a random seed and some sort of thresholds and variations (angle, length, size). I can definitely imagine how to *eventually* do something that would work, though I've never done generative polygonal textures before.

You're only a few steps away from making generative landscapes like minecraft now!!!!
2
Tobias 1115~1Y
This stylised water I came up with uses a Voronoi pattern/tesselation/algorithm/whatever (the node's just called Voronoi) as the base for the surface patterns, does some subtle colour-related stuff like multiplying to accentuate some bits rather than others and to add a gradient over the whole thing based on the screen position, and it uses a noise texture (which there's also a shader graph node for) scrolling over time to add some vertical shifts to vertices to add 'waves'. Surprisingly, one of the most difficult parts to figure out was adding a thin bright line at the very top of the forward-facing face to mark the surface, which I eventually did by selecting between colours based on the UV value (with the line being the top 1% or something).

It's way different to the actual water simulations shown on TwoMinutePapers (which I follow), which actually simulate physics and interactions while this is basically just a fancified cube (or the top and front faces of one, anyway). If the player were to touch it, nothing would happen, but since they never will, what I have here is entirely adequate for my needs!

I took a lot longer figuring out how to generate meshes procedurally for the cube tiles a while back, so reusing some 'CreateTri' function I'd previously written for that to generate grass blades was fairly straightforward. I did have to use a random seed based on world position for position and height/angle variation (though it's not angle exactly, as the bottom two vertices are fixed and the top one has an offset, which I suppose creates an angle but is different to specifying an angle or something).

I've been wondering how much better off I might be if I'd just done stuff like this as a career path years ago, but... oh well. Doubt I'd be able to stay sane if coding-related stuff was all I did (not that I see shader graph work as coding exactly, but I suppose it's the closest category it could fall into). Because what I'm doing now is so much more conducive to my sanity, of course!
2
Log in to comment!