Hey Folks! Nothing pretty to show off today, unfortunately. Still wading through the Unity rendering system and trying to get acclimated.
So far, I've been able to get the scene's color information to write to a render texture. That part was pretty trivial. And you can see it covering most of the screen in today's screenshot. However, what I'd like to do next is turning out to be a bit tricky.
The next piece is to get this entire scene again, except the surface normal info instead of diffuse colors. I could theoretically just replace the code I used to get color info to get normal maps instead, but the trouble I'm having is getting both in the same frame.
Unity has a few tools that are supposed to help with this. Deferred rendering actually produces both of these automatically, which would be nice, except that render path is not compatible with orthographic (2D) cameras.
There's also a way to tell the camera to render the scene using a different shader, and spit that out into a render texture. And I tried hooking up parameters such that the camera would render tile normals instead of diffuse colors. It kind of works, as you can see in today's image. The gray "lighting mesh" radiating outward near the top right corner uses this normals render texture as a material.
However, one problem is that the normals move with the lighting mesh. I want the lighting mesh to show the tile below it, with normal info instead of diffuse info. This is probably not too hard to fix, as it's just a matter of local texture coordinates vs. world coordinates.
The second problem is that the normals appear to be in grayscale. I'd at least expect them to be 2-color, such as vertical info in the red channel and horizontal in the green channel (or similar). But we're seeing something more like all color channels showing the same thing. (And judging by that lower white rim along each tile, probably the surface's vertical direction info.)
There's also a third way to tackle this problem, involving command buffers, but my brief foray into that seemed similarly flawed, and also slower. I was likely doing something in a loot per-frame that caused a slowdown. But even if I ironed-out the performance, I think the command buffer might be overkill for what I'm attempting.
Most of my problem today stems from two things: first, I'm still a bit unfamiliar with Unity's "way" of rendering. There are a lot of moving parts, and a lot of it assumes you're either totally ignorant and happy with defaults, or totally hardcore and know graphics programming inside and out. The middle ground is strangely hard to navigate.
Second, my brain just seems really cooked today. I'm finding it hard to concentrate. Hard to grasp concepts. Hard to make decisions. Maybe it's good Thanksgiving is here :)
I always feel a bit guilty about spending time on rendering instead of gameplay. But once I crack this, there are a ton of really cool things I can do. Even Amandine, the programming consultant I hired a while back for a project assessment, was pretty clear that a custom renderer is the way to go on a project like this. It just does so many unique things that mix 2D and 3D concepts that there isn't any built-in stuff that handles it well. That, and the potential visuals it could produce would aid in marketing and awareness. A signature look and feel.
Anyway, I'm going to put this aside for the long weekend, and maybe take another look with a fresh brain. It feels like I'm so close to getting this thing under control, and once I do, things will pick up speed fast.
That's all for now. Have a good one, all!