Unity Rendering

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!

Tags: Ostranauts


matsy's picture

Maybe this is an example of something you could get someone else in to do for you? You've started that you aren't familiar with Unity, and not a graphics developer by trade. It maybe worth the money for you to get someone in to do it for you.

Obviously a costly venture but sounds like it is vital for the asthetics you are looking for and could take you some time to get there?

Rovlad's picture

Daniel is probably not sure it's worth it in the end himself.
Or maybe just wants to tinker with more techy stuff for a change. It happens to him sometimes. :D

We don't celebrate TD where I'm from, but I hope you guys enjoy it anyway! :)
PS. Dang it, it won't let me use a turkey emoji thingy in the comments! I thought it was just unicode?

dcfedor's picture

@matsy, I'm definitely considering it.

On one hand, I want to know this stuff. I was a tech artist at BioWare. I wrote the tool that mapped animation weights on face vertices across different mesh topologies. I prototyped cape and hair rendering. I even wrote a pretty darned good river bank shader back in the day.

I should be able to handle this stuff :)

But I recognize I might not. And I'm sort of watching for signs of stagnation. Signs I'm wasting too much time on something when a few (thousand) dollars might "just get it done."

@Rovlad, and yeah, that's part of it, too. Sometimes it's just guilty pleasure :)

Thanks for the well wishes! We ended up having dinner at a friend's parents' house, so it was a nice evening.

And emojis? Wha? What do you think this is, 2018? ;)

Dan Fedor - Founder, Blue Bottle Games