I've been stuck on the grid problem for some time now. I think it's time for another wall of text of very little value to everyone else besides me. Hopefully writing about it clears things up.
In fact, I discourage you from reading any further into this post. Just stop. Go read other devlogs. I promise I'll come back with fun posts with gifs later.
The problem: The sole reason for giving up on this game for more than a year and eventually restarting development was visual communication. People would play the demo and even beat all levels without fully grasping the main gameplay element. So drawing a grid is not just simple cosmetic luxury, it's important as it is part of my main strategy for addressing the problem, together with making space actually deform. And it's giving me a lot more trouble than I expected.
Here are some possible solutions I thought in no particular order.
A very easy to implement solution, but that might be more time consuming in the long run, is like this: After finishing the level mesh I 'bake' the uvs to a texture, then I duplicate the level mesh and apply the uv texture to one of them. Simple. But I would have to do this to every level mesh. That could be fine but right now I don't have a fixed workflow for making level meshes, and currently I'm doing small tweaks to the mesh and its uvs inside unity using Probuilder, which messes up the idea of baking the UVs in a 3D editor. It sounds like a lot of back and forth.
Another solution would be a wireframe shader. I found one online and it's the one in the previous screenshots. But it's pretty bare bones and ugly. This is my strongest candidate so far. It works and requires very little effort, even if it's ugly and uninteresting.
I tried coding my own shader to make something prettier but gave up. I'll leave black magic to Prinsessa. I could shell out a few bucks for one of those paid assets but I had bad experience with paid assets and I usually end up not using any of it.
Eventually I decided to see what could be done with the shadergraph, so I switched the entire project to the lightweight rendering pipline, which converts every material in the project and makes the editor considerably more sluggish and unstable with an obvious memory leak that requires closing and opening the editor every 30 minutes. And of course I forgot to back up the project before doing that so if I want to go back now it's gonna be a long and boring afternoon. But anyway, I played around with the shadergraph thing. It can do some pretty nifty stuff with very little effort, but it can't do wireframe lol. I did however managed to make a shader that creates transparency ripples around a given position (which can be the player position) and that can be paired up with a grid texture. However, since parts of the level are not the same scale, the grid is not aligned by default and there is no simple way to achieve that.
So the above solution requires a grid texture that is aligned across all sections of the level mesh. A baked UV would achieve that. Another solution, which I tried and failed, is to rearrange the UVs of the level mesh (not the original, of course) to make all triangles have its vertices on (0,0) (0,1) (1,1) and the grid texture would be just a triangle. That might work but I didn't have any luck with my quick jabs at it.
Another possibility is to not use shaders at all. Instead I draw the lines of the mesh with something like LineRenderer, which creates billboards following a set of points. I haven't tried it but my gut tells me this isn't efficient. Besides, I don't really know how to define the lines. There are no 'lines' in the mesh definition, we have vertices and triangles (list of indices of vertices). But I'm sure there's a solution here, if I feel like taking a stab at this.
Yet another solution is to not do the grid on the 'real' space, not on the level mesh. I think some of the screenshots above are also using this method. The main difficulty with this approach is the the grid of each Room is a different object, so if I wanted to add ripple effects and the like I would have to face the problems of Room communication. You know, all those portals problems that made me wanna die for the past few months? yeah, I'm not eager to jump right back on them. They work and that's all that matters.
Jeez, I finished writing this wall of text without a single eureka moment. The main problem seems to be making it look pretty. If I lose the pretty requirement then the problem is already solved in two different ways. I guess I have to face the facts and just accept that I should move on with an ugly solution. At least not make beauty a priority, and continue to work on the game until another solution for this pops up.
Hey look, it wasn't an eureka moment but I did organize my thoughts and made a decision. Big wall of text works all the time.
Crap, I'm gonna have to roll back the render pipeline thing, aren't I? Doesn't look like it adds anything to the project, I tried just to see if I could do a decent wireframe and that didn't work. And since it's still in preview (I think) I'm experiencing a lot of crashes now. Maybe I did upload the project to the cloud.
I bet you thought the wall of text was about to end 3 paragraphs above. And by 'you' I mean me, who the hell reads this drivel? No, it's still going on. But I just want to organize the conclusions and next steps:
- Wireframe won't be pretty for now
- Roll back LWRP
- Get back to the demo (which I didn't really start)
Oh yeah (wall of text not over yet) player controller is in a presentable state now. Not perfect by any means but decent.
OK, NOW wall of text is over. If you read this far, how could you? I asked so nicely. If you cheated and only read the final line that's better.