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:01:47 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsReturn of the Obra Dinn [Releasing Oct 18]
Pages: 1 ... 22 23 [24] 25 26 ... 44
Print
Author Topic: Return of the Obra Dinn [Releasing Oct 18]  (Read 934510 times)
ReverendTed
Level 0
**



View Profile
« Reply #460 on: March 12, 2015, 04:35:41 PM »

working hard... researching hammocks... Smiley
I wasn't going to say anything, but I think Crawl would have been vastly improved if a little more attention had been paid to the hammock physics.  Wink
Logged
dukope
Level 3
***


View Profile WWW
« Reply #461 on: March 15, 2015, 09:02:06 PM »

[...]Out of curiosity, have you tried talking to a historian about the game? I'm sure there must be some out there willing to help...[...]

I've thought about it off and on. Actually it's a great idea that I'll probably follow up on a little later. If Panurge isn't careful I might hit him up for a few things.


Have you read the Master & Commander series of historical fiction novels? Apart from being super reading they are also set in the same time period & go into lots of carefully-researched detail.

So far I've tried to stay away from fiction. Everywhere I look these novels come up though so I'm currently teetering on the edge of reading at least the first one.


working hard... researching hammocks... Smiley
I wasn't going to say anything, but I think Crawl would have been vastly improved if a little more attention had been paid to the hammock physics.  Wink

Logged

dukope
Level 3
***


View Profile WWW
« Reply #462 on: March 28, 2015, 07:54:54 PM »

Performance

Working on the lower decks, some performance problems have been building up for awhile now. Even though the game's resolution is super low and there's no obviously fancy surface shaders going on, the geometry/object count is pretty high. Normally that wouldn't be a problem but since the 1-bit rendering technique requires two passes, sending all the geometry to the GPU twice eats up a lot of frame time. Yesterday I decided to sit down and see if I could get all the rendering done in a single pass (plus post-processing). 


The Old Way

The original technique required rendering the scene in two passes:

Scene Pass 1: Sectioning 

The sectioning pass just draws the vertex colors, which have been pre-processed to define areas that should be separated by edges. Wireframe lines are later drawn along these edges in post. 


Old method: Sectioning pass


     RED = Tool-generated random hash (lower bits)
     GREEN  = Manually-set adjustment color
     BLUE = Tool-generated random hash (upper bits)
     ALPHA = unused

Scene Pass 2: Lighting/Texturing

Lighting/texturing runs the full Unity SurfaceShader pipeline to generate lightmaps + dynamic light + textures. Dithering and other logic is applied to these results in post.


Old method: Lighting/texturing pass


     RED = Light value
     GREEN = Markup value (0: normal, 0.5: ordered dithering, 1:dust)
     BLUE = Texture value
     ALPHA = unused

Post-processing Combiner

These scene passes are written to two render textures which are then combined in a post process to make the final buffer. Having the light and texture in separate channels from the lighting/texturing buffer enables me to adjust their gradient ramps separately, which I use to make the hard shadows and blown-out textures that help with legibility.


The final post-processed output, 30fps


Separating the two passes like this makes sense for a couple reasons:

  1. Easy to visualize the two main features of the rendering style: wireframe lines and dithered 1-bit surfaces
  2. Two 32-bit RGBA buffers gives plenty of space for the data.

Both of those reasons aren't worth the framerate hit though. Unity's not very good at reusing scene data for subsequent passes, so even when the sectioning pass runs at +100fps, sending all the geometry twice bogs things down too much.


Combining

So the goal was to combine the two scene passes into one with the hope that performance improves on lower end video cards. That last bit is important because it precludes me from using MRT. For a single pass, everything has to fit in 32-bits.

One particular complication is that Unity's SurfaceShaders by default don't allow writing to the alpha channel, so you're effectively limited to just 24-bits in an RGBA buffer. I tried to be happy with that for a long time before finally tracking down a fix, which just became possible in Unity 5.


The problem. Alpha being "helped" to 1 for all surface shaders.


You can't easily edit the generated code directly, but you can redefine the offending macro in your own code, which is thankfully included after UnityCG.cginc:


The fix requires undefining the macro in your own surface shaders


With that, you have use of the full 32-bits and can write anything to the alpha as long as it's non-zero.

Single Scene Pass

So now I just had to pack 48 bits from the two separate passes into 32 bits for the single scene pass. The basic idea was to chop off the lower 8 bits of the sectioning hash (leaving 16 bits), reduce the lighting/texturing output to a single 8-bit channel, and use the alpha as a markup value to specify which "pass" the RGB values were coming from. Because the final output is dithered 1-bit, very few bits are actually required for the lighting/texturing. The result:


RGB


Alpha


I was also able to use Unity's shader Queue tags to control draw order: set the sky shader to "Queue = Background" and the dust shader to "Queue = Transparent". 

Post-processing Combiner

The post-processing step now just has to do the edge detection (with 2 channels instead of 3), the darkness check (to invert wireframe lines in darkness), the dithering (bluenoise or ordered based on the alpha bits), and the dust inversion. There is some extra cost to doing more of the lighting/texturing combination in the scene shader instead of the post processing shader. But the final output looks identical to the old two-pass method, and it runs significantly faster.


Single scene pass, 60fps


Optimizing Early

There's always a danger in doing optimizations like this before the game content is mostly done. Now that I have an extra 30fps to work with there's a good chance I'll paint myself back in to poor performance. A common trick for smarter programmers is to keep a few secret optimizations in their pocket until the very end. If you optimize too early, the artists will just fill up the scene again and you'll be in a spot where it's much harder to get in framerate. I'll have to rely on self-discipline instead.

I am glad this worked out ok though. There's a (justified) perception that a 640x360 1-bit game should not have framerate problems on any machine. There's a lot going on behind the scenes that makes the rendering more intensive than it looks initially, but I'd rather match the perception than make excuses.
Logged

eigenbom
Level 10
*****


@eigenbom


View Profile WWW
« Reply #463 on: March 28, 2015, 08:08:04 PM »

Very interesting dude! Love this stuff :D
Logged

plauk
Level 0
**



View Profile WWW
« Reply #464 on: March 31, 2015, 10:33:18 PM »

This devblog keeps making me think of Clarke's third law. You are performing magic as far I can tell.
Logged
marcgfx
Level 8
***


if you don't comment, who will?


View Profile WWW
« Reply #465 on: March 31, 2015, 10:55:13 PM »

great read. I'm always interested to see how other people handle shaders, I've spend quite some time on them myself. how much is significantly faster?
the ship is looking more and more polished, I love the detail work you are putting in.

what I was wondering: do you have night and day-scenes? does the sun position change in your flash-backs? If I recall correctly you are not always jumping back to the same day/time. the last composed image would have to be night, but the shadows are strong. I hope the moon is up Smiley
Logged

Ilmuri
Level 0
*

>:|


View Profile
« Reply #466 on: March 31, 2015, 11:41:14 PM »

Even though the game's resolution is super low and there's no obviously fancy surface shaders going on, the geometry/object count is pretty high. Normally that wouldn't be a problem but since the 1-bit rendering technique requires two passes, sending all the geometry to the GPU twice eats up a lot of frame time. Yesterday I decided to sit down and see if I could get all the rendering done in a single pass (plus post-processing). 
Are you changing the mesh geometry each frame? That's the only way you'd be sending a lot of stuff to the GPU. Mesh data resides on the GPU's memory after it's allocated by the driver. I'd say it's likely the slowdown was because of Unity dynamic batching breaking down due to your multi-pass shader, resulting in excessive draw calls.

Quote
Multi-pass shaders will break batching. Almost all unity shaders supports several lights in forward rendering, effectively doing additional pass for them. The draw calls for “additional per-pixel lights” will not be batched.
http://docs.unity3d.com/Manual/DrawCallBatching.html
Logged
dukope
Level 3
***


View Profile WWW
« Reply #467 on: April 01, 2015, 02:41:14 AM »

what I was wondering: do you have night and day-scenes? does the sun position change in your flash-backs? If I recall correctly you are not always jumping back to the same day/time. the last composed image would have to be night, but the shadows are strong. I hope the moon is up Smiley

The moon is up, but yeah I just now notice that the screenshots seem weird with the bright light and black sky when the moon is to your back. It feels ok when you're in the game when you can see a bit of the moon light source though.


Are you changing the mesh geometry each frame? That's the only way you'd be sending a lot of stuff to the GPU. Mesh data resides on the GPU's memory after it's allocated by the driver. I'd say it's likely the slowdown was because of Unity dynamic batching breaking down due to your multi-pass shader, resulting in excessive draw calls.

Except for a few small objects, all meshes are static and marked for static batching. There's not much room for dynamic batching to help. I render each pass with Camera.RenderWithShader, not as in-shader "Pass"es. I don't know even know how to do it in-shader with a render target switch between passes.

Also, the old sectioning pass used very fast forward rendering and the old lighting/sectioning pass used deferred. The new single pass is just deferred. So there might've been room for multipass optimizations, but it's hard to make guarantees about Unity's batching and it'd never be as fast as a single pass.
Logged

Pitxardo
Level 0
***



View Profile
« Reply #468 on: April 01, 2015, 03:19:07 AM »

The level of detail in this project is insane Crazy

I played the old demo and despite of taken art decision in colors and textures (almost a black & white game without textures), I really appreciate the hard work done in technical area, specially in lighting.

Now, with the physics, ropes and everything together looks exceptional  Beer!
Logged

Batowski
Level 0
***


Milan Batowski


View Profile WWW
« Reply #469 on: April 01, 2015, 03:34:28 AM »

Just chimed in to say that I have the utmost respect for you, Lucas, for tackling so many areas of game development single-handedly, and with such a high quality of artistic vision as well. You are a true inspiration.  Hand Clap

May I derail the thread a bit by asking how do you adjust your personal life to be able to work as much as you need/want? Did you have to make any sacrifices?
Logged

Thuby
Level 0
***



View Profile WWW
« Reply #470 on: April 08, 2015, 12:37:42 PM »

How much time do you think it will take/takes at this point to play through the entire game?
Logged

RefriedResearcher
Level 0
*


View Profile
« Reply #471 on: April 09, 2015, 07:34:02 AM »

Just dropping in to say, can't wait for the next playable build! I'm a big fan of your work and it's common tones of mystery and discovery, and this seems no exception. The 1-bit shading is a simply wonderful design choice for the game, and it's great that you were able to create such an impactful aesthetic using it.

Thanks for your work, and I'll be watching!
Logged
TopherPirkl
Level 0
***



View Profile WWW
« Reply #472 on: May 27, 2015, 09:50:35 PM »

Wow, I was just pointed to this devlog by a friend on another forum and I'm floored. Game looks fantastic, and it's a really cool concept. Looking forward to going back and digging through the devlog.
Logged

Sound Designer | @phantomfreq | Demo reel
dukope
Level 3
***


View Profile WWW
« Reply #473 on: May 27, 2015, 11:12:02 PM »

Hey guys! Still alive! Still working!

There've been a bunch of small things keeping me from posting here, biggest one being that a lot of my work in the last 2 months or so has been on tools and there's just not much to show. I'll make a post about some of those tools in a minute though.

How much time do you think it will take/takes at this point to play through the entire game?

Honestly I have no idea. I think in the end it depends on how streamlined I want to make traveling between all the different flashbacks. I could make that quick and easy or I could make it ponderous as in the current dev build. I prefer quick and easy even if it shortens the overall game time.
Logged

JobLeonard
Level 10
*****



View Profile
« Reply #474 on: May 28, 2015, 12:28:28 AM »

Hey guys! Still alive! Still working!
That's great! Also the part that you're still working on this.

What kind of tools?
Logged
dukope
Level 3
***


View Profile WWW
« Reply #475 on: May 28, 2015, 12:31:28 AM »

Tool Talk

Making this game by myself has been something. I like changing between the multiple tasks often but I've learned that in my heart I'm more of an engineer than an artist. Drarring n stuff is great but what really keeps me happy is writing code. Obra Dinn is overall a fairly straight-forward game technically so that itch doesn't get scratched as much. I often find myself making excuses to write code instead of model or draw.

One of the best ways to quench that thirst is by writing tools. A good tool can save a lot of time and given how over-my-head I am on this project art-wise, I need all the time savers I can get. Here's a couple Maya tools I've written to both keep my inner engineer happy and my inner artist lazy and unproductive.


Wrapped Ropes

More rope scripts. As I was filling some of the lower decks, I had a need to secure objects to keep them from moving around. As before, nothing gets used as much on a sailing ship as a good rope. You'll often see ropes wrapped around things to keep them in place. Unfortunately, wrapping ropes around things is not a well-supported feature of most modeling packages. I took a stab at using extruded splines, but lining up the points just right is a huge pain. And any adjustment to the objects being wrapped requires basically remodeling the ropes too.

Mel script and a fun technical challenge to the rescue again. In this case, I decided to specify rope-wrapping volumes that get intersected with a set of target objects to define a convex hull, which is then munged to get me a nice closed rope. Here's an example where I need to secure two galley stools to the fore mast:



Rope volumes used to generate wrapped ropes


In-game


If I move the stools around or add another object there that needs to also get wrapped, I just hit Ctrl-R twice and it drops me back to the original volumes and regenerates the ropes. A few more examples:



Wrap everything securely


There were a lot of little quirks to getting this working right, mostly due to Maya's totally worthless boolean operations. Boolean ops for arbitrary 3D models is a difficult problem - solved convincingly 30 years ago. That Maya's boolean ops don't just work in 2015 is some kind of criminal offense. Anyways, I lucked out that the rope volumes are always closed box shapes. I can just use plane slicing instead of actual boolean intersections for the operations I need.

What is nice about Maya is that this procedure was possible in Mel without any complex math programming. Mel is a pretty crappy language altogether, but it's very domain-specific and you're able to plug directly into all (most) of Maya's built-in features. So things that you'd normally write a big complex model editing function for can usually just be done with one or two Mel commands instead. Sometimes you need to get a little clever to get what you want but that's fun too.


Tiedown Ropes

The first cousin of wrapping things with ropes is tying them down with ropes. Actually tiedowns are probably more important than wraps, but I didn't have a need for these until later. The basic idea is to again have a rope volume that defines where a rope attaches (at two ends) and where it passes over to "tie down" something.



Generating tiedowns over a set of crates by script


This script re-uses some of the logic of the wrap rope script and integrates it with the rigging rope script. So the rope volumes here are used to first generate a convex hull over the target shapes. Then a spline is built along that hull down the center of the original rope volume. That spline is then passed through the rigging rope logic to extrude it and put anchors at the ends. The nice thing is that, once the anchor points are marked with two red vertices, the rope volume can encompass any shape and look ok.



These would be pretty laborious to model by hand


TBC...

I made a bunch of character tools too. Will post about those soon.
Logged

Fenrir
Level 3
***



View Profile WWW
« Reply #476 on: May 28, 2015, 12:38:11 AM »

Wow nice, thanks for those details! When I'll play the game I'll look differently to the ropes now. Smiley
Logged

deab
Level 2
**



View Profile
« Reply #477 on: May 28, 2015, 04:40:08 AM »

Excellent idea! Definitely worth the time to create tools.
Logged
thebarryman
Level 0
**



View Profile WWW
« Reply #478 on: May 29, 2015, 11:36:51 PM »

Love seeing your procedural art process. Keep it up!
Logged
ReverendTed
Level 0
**



View Profile
« Reply #479 on: May 30, 2015, 05:14:14 PM »

"The Ropes of the Obra Dinn" has a certain ring to it.  Looking great!
Logged
Pages: 1 ... 22 23 [24] 25 26 ... 44
Print
Jump to:  

Theme orange-lt created by panic