Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 20, 2024, 02:19:54 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsReturn of the Obra Dinn [Releasing Oct 18]
Pages: 1 ... 26 27 [28] 29 30 ... 44
Print
Author Topic: Return of the Obra Dinn [Releasing Oct 18]  (Read 934512 times)
dukope
Level 3
***


View Profile WWW
« Reply #540 on: October 26, 2015, 06:20:40 AM »

Didn't Work, Try Again

Unfortunately my super clever layered lightmap system didn't work out that well. Implementation-wise everything's fine and on a small level with a few lights/receivers it works great. But the realities of the Obra Dinn brought it to its knees. First 60 crew and now a boss lightmapping system. That ship is plain bad news.

The ship has ~30 lanterns spread around the decks, ~15 of them swing back and forth with the motion of ocean, and all 30 can be switched on/off by the player. Each of these generates their own personal set of lightmaps which receivers composite together in real time. 

The problem is that because of the density of the ship's geometry it's not unusual for one receiver mesh to get lit by many lanterns. Even when the lanterns are contained in light-proof rooms, the meshes making up the walls can easily be lit from both sides by different lanterns. Combine that with the need to separate receiver groups based on material and things got way out of hand. The end result was that lighting the Obra Dinn with dynamic lightmap layers generated over 600 new materials, with a max of 8 compositing layers.

This breaks Unity's batching system badly, the sheer number of new material assets basically destroys the editor, and it exceeds my sensible limit of 4 layers per receiver. Conclusion, I had to scrap that system and work out an alternative.


Dynamic Lights

I briefly experimented with just using dynamic shadow-casting lights - switching them on and off based on proximity/doors/etc. This works ok and looks good but even the slightest performance hit here is painful, since I know it can be done statically. One possibility is to generate each lantern's shadow depth map once (the slow part) and just reuse it every frame afterwards. This would allow rotating the light cookie and adjusting the intensity in realtime, which is 90% of what I need. There are performance penalties with this due to the added passes so I'd still want some way of occluding lights that were far away or not visible.

Still, this is objectively a good solution and probably the most reasonable way to handle this. So instead I went back to the lightmapper and tried something else.


Global Lightmapping, Dynamic Compositing

Under the old system, each lit receiver was responsible for maintaining unique lightmap uv coordinates for each light layer, and for compositing these layers together in the shader. Memory-wise this is great and with just a few light layers to worry about for each receiver it's also fast. On the downside there's a lot of extra complexity due to how multiple lightmap uvs are stored, and having to muck with the shader complicates the asset pipeline.

Instead of doing it per-receiver like this, an alternative is to use only a single global lightmap that gets dynamically updated. So each lit receiver just samples one lightmap with one set of uvs and the compositing task gets moved to the entire global lightmap.

The complexity now comes from how to A) build a global lightmap that incorporates all the light layers dynamically and B) how to composite the dynamic light layers into the global lightmap in realtime. Fortunately neither of these is too bad.

To start, all the dynamic layers are generated individually as before. For each dynamic light you get a packed lightmap and a set of atlased uvs for each receiver. Once all of these dynamic layers are built, you then re-atlas every receiver's uv into one huge atlas that represents the global lightmap.



Mapping each light's local lightmaps to the global lightmap atlas


At this point for each receiver you know where it is in any light's local lightmap, and where it is in the global lightmap. That position in the global lightmap becomes the receiver's lightmap uv. Then, the local lightmap data has to be copied into the global lightmap (per frame). 

You could just have a version of each local lightmap that's already been atlased to the global lightmap, but that would waste a fantastic amount of memory. Instead, it's possible to create a 2D mesh with the local lightmap as a texture that remaps all the rectangles to their new positions in the global lightmap. Compositing the global lightmap then just requires rendering each local lightmap mesh into it, adjusting alpha as necessary.


Compositing local lightmap meshes into the global lightmap


Costs

Because this system uses both the global lightmap and the local lightmaps at runtime it does require a lot more memory than the old technique. As a small compensation though, the local lightmaps don't need to be power-of-two any more since their mips are never accessed. Also, the final global lightmap is often comprised of many pages. To save time it's possible to composite just one page per frame - light fades/transitions are a little less smooth but it's not that noticeable.

Beyond actually working properly, this system is also way, way simpler on the runtime/shader/asset side. That probably makes me the happiest. Performance is important but I'm strongly biased towards less complexity in the actual implementation.


Bonus Glitch

While testing the fades without a proper 1-bit conversion:



Perfect
Logged

JobLeonard
Level 10
*****



View Profile
« Reply #541 on: October 26, 2015, 01:15:54 PM »

TIL my migraine auras are 1 bit
Logged
Franklin's Ghost
Level 10
*****



View Profile WWW
« Reply #542 on: October 26, 2015, 11:07:06 PM »

Always so interesting to read about your development and how you approach problems you run into. Also looking forward to seeing gifs of what you decide to go with in the lighting.

That bonus glitch almost looks like something I'd expect in a Daredevil game with his blindsight interpretation of the world around him.
Logged

oahda
Level 10
*****



View Profile
« Reply #543 on: October 27, 2015, 03:23:21 AM »

Agh! I don't check this amazing dev log often enough. It's so insightful and interesting. The game too is interesting, of course.

You should seriously consider making the black and white shader some sort of bonus or w/e because your work on textures and so on is really good and it seems to look great that way as well.
Logged

MrElmo
Level 0
*



View Profile
« Reply #544 on: October 27, 2015, 07:05:40 AM »

If you pay close attention to the glitched gif, you can see the dithering mode change from Blue Noise to Bayer on some of the surfaces. I bet that's because the dithering mode is stored in the "color" of the surface before the shader processes it into 1-bit.
If you go back to this post: http://forums.tigsource.com/index.php?topic=40832.msg1124342#msg1124342
Yep, that's exactly what he did. Dithering mode was stored in the green channel as of that post.
Shining a light on the surface "without a proper 1-bit conversion" would gradually increase the value in the green channel, which eventually changes the bit that the shader uses to determine the dithering mode.
I just thought that little detail was neat.
Thanks for sharing, Lucas.
« Last Edit: October 27, 2015, 07:11:02 AM by MrElmo » Logged
plauk
Level 0
**



View Profile WWW
« Reply #545 on: October 28, 2015, 07:10:13 PM »

You should seriously consider making the black and white shader some sort of bonus...

I've been thinking this for a while, but didn't want to flat out say it. Shaders are way too hard, and school is way too expensive, and my job takes up way too many hours. I guess I was also hoping for a "shaders included" sticker on the cover when I suggested Lucas publish a book.
Logged
dukope
Level 3
***


View Profile WWW
« Reply #546 on: October 29, 2015, 08:03:29 PM »

If you pay close attention to the glitched gif [...]

Yup, that's exactly what's happening. Nice deduction!

You should seriously consider making the black and white shader some sort of bonus...
I've been thinking this for a while, but didn't want to flat out say it. Shaders are way too hard, and school is way too expensive, and my job takes up way too many hours. I guess I was also hoping for a "shaders included" sticker on the cover when I suggested Lucas publish a book.

I'm kinda surprised that people are asking for the exact shaders I'm using. There's enough info in the thread to reproduce the code. The hard part is that the overall effect requires coordination with the asset creation and lighting. You can't just drop a post effect on the main camera and get a good result.

Also, I've had to make numerous tweaks over the project to fit with exactly what the game needs. I imagine any other usage will need the same level of tending. You're much less prepared for that level of tweaking if you're just handed the shaders outright.


Inverse Kinematics

What I really want to do.... is dance!



Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #547 on: October 29, 2015, 08:05:11 PM »

full blown vocation for a future star of music hall
Logged

coah
Level 1
*



View Profile
« Reply #548 on: October 30, 2015, 02:21:52 AM »

That is one nice looking rigging job.
Logged
Cranktrain
Level 4
****


making gams


View Profile WWW
« Reply #549 on: October 30, 2015, 03:51:36 AM »

Having read through this devlog, I'm really quite amazed at the graphics engineering magic that's been required. I struggle to write the most basic shaders, so this is really very fascinating, and I really appreciate all your detailed write-ups. This is one very unique looking game.
Logged

DiddumsJ
Level 0
*


View Profile
« Reply #550 on: October 31, 2015, 02:00:42 AM »

I just felt I had to sign up and let all of you know how interesting it is to just sit back and watch how you go about circling problems that I really don't even understand. Never programmed anything (and I had to do some googling to register for the forum!  Embarrassed ) but I really enjoy what your'e doing (and how) with this game, dukope!  Gentleman
Logged
plauk
Level 0
**



View Profile WWW
« Reply #551 on: November 03, 2015, 10:35:01 PM »

There's enough info in the thread to reproduce the code.

Believe me, I've been trying for months. I'm still at the point where shader code is confusing and mysterious to me and I probably shouldn't be starting by attempting to replicate this style. Whenever I think I understand it, I realize I've been looking at it backwards. A dozen tutorials later, I'm about where I started. Of course, that's not your problem. I'll get there eventually.
Logged
oahda
Level 10
*****



View Profile
« Reply #552 on: November 03, 2015, 11:22:17 PM »

You should seriously consider making the black and white shader some sort of bonus...
I've been thinking this for a while, but didn't want to flat out say it. Shaders are way too hard, and school is way too expensive, and my job takes up way too many hours. I guess I was also hoping for a "shaders included" sticker on the cover when I suggested Lucas publish a book.

I'm kinda surprised that people are asking for the exact shaders I'm using. There's enough info in the thread to reproduce the code.
Eh, was that how you interpreted my post? Me, I just meant including a mode to play the game in black and white instead of 1D, not actually including the shader code for others to copy. Huh?
Logged

dukope
Level 3
***


View Profile WWW
« Reply #553 on: November 14, 2015, 06:51:53 AM »

I'm kinda surprised that people are asking for the exact shaders I'm using.
Eh, was that how you interpreted my post? Me, I just meant including a mode to play the game in black and white instead of 1D, not actually including the shader code for others to copy. Huh?

Actually I wasn't sure what you meant and plauk's quote led me to assume you were (also) talking about the shader code. Now I gotcha. The big problem with adding another rendering mode is that, unless I spend a long time tweaking it, it just won't have the care that the 1bit mode has. There's so many tricks and hacks to get the 1-bit looking good that work directly against straight greyscale.
Logged

dukope
Level 3
***


View Profile WWW
« Reply #554 on: November 14, 2015, 06:57:38 AM »

Music

I've hit something of a snag in the narrative/story implementation and decided to take a break from that frustration to do some music. There's nothing audible to share but I thought it worth a post about the tools I'm working with.

Obra Dinn's music uses an orchestral theme and the dev build (released over a year ago, jesus) has a few short pieces in it. For previous projects I almost always used a hardware workstation keyboard for music composition. It's nice to get away from the computer screen and not have to mess around with a mouse when writing music. 


Previous weapon of choice


Keyboard workstations work great for electronic or bread&butter instruments but unfortunately orchestral voicing in hardware synths is way behind the multi-gig sample libraries you can run on a desktop PC. I used Logic Pro's builtin orchestral instruments for the dev build but even those are a little flat. A few months ago I sprang for Kontakt Komplete 10 and Sonokinetic's Da Capo symphonic orchestra library.


Current weapons of resigned convenience


What I'm still missing is any proper knowledge about orchestral instrumentation. Violins apparently can't play from C0 to C5 and a big part of making orchestral music sound right is getting each instrument to play within range and in the right way. I'll try not to get too hung up on this, and Da Capo does a decent job of handling a lot of that complexity automatically.

The basic musical structure of the game is luckily pretty simple: Short, one minute pieces that play only during the flashbacks. I have a bunch of those composed already and I need to eventually pick one as the game's theme song. None of them really stand out as quite right for that yet though.


Random Hangups

Back in the programming, I ran into a small bug with the rendering that emphasized one of the pitfalls of using a big mature popular engine like Unity. Basically, I have a shader effect that uses world position coordinates for each pixel (it's the distance blur effect mentioned earlier). There are a lot of Unity resources for sample code and tips on how to do this sort of thing. When using a popular engine like this it's really easy to, instead of fully understanding everything that's going on, just find and use some shader/script source you find online.


Debug display of the shifting world position calculation


If you look closely, you can see the concentric circles (which should be planted beneath the characters) shifts slightly as the camera moves away. I spent hours trying different screen space -> world space techniques, hoping to stumble on to one that works out of the box. 


Nope, back in the box


In fact, all of these techniques work fine and the problem was somewhere else. It took me awhile to pull my head out though and actually figure out what was wrong. This sort of thing has happened to me before in Unity and it'll probably happen again. There are just so many resources so readily available that it's easy to get stuck on autopilot and unconsciously avoid proper understanding of the systems and my own code.


Fixed


Anyways, the problem is that I was changing the camera's far plane distance between rendering the scene and applying the post effect. That screwed up the depth -> world position calculations by a hair and resulted in sliding values.

I do kinda like that debug concentric circle effect though.


Hotline Dinn
Logged

Cranktrain
Level 4
****


making gams


View Profile WWW
« Reply #555 on: November 14, 2015, 07:21:34 AM »

Still very pretty, even with debug lines. Looking forward to hearing what the audio for the game sounds like.
Logged

azdak
Level 0
**


View Profile
« Reply #556 on: January 02, 2016, 12:03:26 PM »

YAAAS MOAR TECHNICAL DETAILS Coffee That mazesolving-to-depth of field interlude was fascinating- and I love the slight claustrophobia of the final result. Really appreciate you taking the time to put this devlog together, man- it's both a great read and incredibly inspiring.

Quote
Obra Dinn 2: Miami Nights
Logged
wizardfu
Level 2
**


Nathanael Weiss


View Profile WWW
« Reply #557 on: January 07, 2016, 09:42:59 PM »

So sweet! I really dig the 1bit style. And congrats on being one of the best devlogs on Tigsource.
Logged

Quicksand-T
Level 4
****


@Quicksand_T


View Profile WWW
« Reply #558 on: January 07, 2016, 11:10:13 PM »

You need to use that concentric circle effect for a dream sequence or drug trip level or something.
Logged

Koloth
Level 0
*


View Profile
« Reply #559 on: January 15, 2016, 05:16:47 PM »

Hey there!  So this is a bit of an odd post, but you mentioned early on in this thread that you'd love to be able to run Atkinson type dithering in a shader so that you could have a greater level of detail on your models.  So I'm a mathematician, so the question got my mind going and so I've and created a method that produces error diffusion dithered images in shaders at >100fps speeds (even with truly and deliberately incompetent coding on my part!).  Here is a quick comparison gif where both the "Atkinson Like" and "My Own" run in the shaders:


Despite the obvious quality gains (look at the face folds on both characters, and the cheek scar on the right character in particular), the method is not without its drawbacks of course.  In particular, since errors diffuse across the image small changes in the image can cause large changes in the dithering.   This results in a bit of shimmering as can be seen in this larger (~6mb) gif: https://media.giphy.com/media/xTcnT51LPmN6GfaNVe/giphy.gif.  This could make it a non-starter for YouTube compression reasons, but I felt like posting this anyway.

An unexpected benefit is that you can tune the diffusion coefficients for various fun artistic effects.  Here I made it have a preferred direction so that that it produces a striped woodcut like dither which also exhibits a bit less shimmering: https://media.giphy.com/media/l0K7o6Tn4JsJtvDMc/giphy.gif

You can message me if you'd like to drop it into your current build (it is a couple of glsl shaders that shouldn't be too hard to add to your graphics pipeline) to see if it makes things better or worse. In any case, it was a blast to play around with and I've been loving the DevLog!
Logged
Pages: 1 ... 26 27 [28] 29 30 ... 44
Print
Jump to:  

Theme orange-lt created by panic