Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411421 Posts in 69363 Topics- by 58416 Members - Latest Member: timothy feriandy

April 18, 2024, 01:15:55 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsLovers in a Dangerous Spacetime - Devlog #11: Timing is Everything
Pages: 1 ... 3 4 [5] 6
Print
Author Topic: Lovers in a Dangerous Spacetime - Devlog #11: Timing is Everything  (Read 41731 times)
gamedev123
Level 0
**


...it's alright. Really...


View Profile WWW
« Reply #80 on: January 23, 2014, 10:22:29 AM »

This is some great reference.  More please!
Logged

Visual designer, gameplay and game content designer based in New York City.  I done work\'d on iPhone, Web, casual downloadable and handheld console games.
rocket5tim
Level 0
***


outside the frame


View Profile WWW
« Reply #81 on: January 23, 2014, 01:01:17 PM »

DevLog #5: Making Friends

I recently had a chance to assemble this screen-cap footage from earlier last year showing our modeling/rigging/animation process for Lovers:

Holy shit, Matt! This is sooo good!
Logged

matthammill
Level 0
**


Designer/Artist


View Profile WWW
« Reply #82 on: January 24, 2014, 08:47:31 AM »

Thanks guys. And happy GIFriday!

Logged

Reilly
Level 2
**


14/f/tx


View Profile WWW
« Reply #83 on: January 24, 2014, 09:34:52 AM »

lolololol
Logged

Reilly
Level 2
**


14/f/tx


View Profile WWW
« Reply #84 on: January 24, 2014, 09:44:03 AM »

So I was listening to your interview on BigSushi the other day and it was mentioned that you guys do contract work 2 days of the week. Is that individual freelance or are they projects all 3 of you work on?
Logged

Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #85 on: January 24, 2014, 12:42:39 PM »

I love you guys , and all of you guys's work
Logged
matthammill
Level 0
**


Designer/Artist


View Profile WWW
« Reply #86 on: January 24, 2014, 12:57:48 PM »

So I was listening to your interview on BigSushi the other day and it was mentioned that you guys do contract work 2 days of the week. Is that individual freelance or are they projects all 3 of you work on?

Some of our gigs were independent, and some we'd work on together, depending on the project. Though going forward we'll be diving into the game full-time, which is exciting...!
Logged

Bandreus
Level 3
***


View Profile WWW
« Reply #87 on: January 25, 2014, 04:28:22 AM »

Sexy Lovers in a Sexy Spacetime  Kiss
Logged

tuckertuck
Level 0
**


Man-child


View Profile WWW
« Reply #88 on: February 04, 2014, 09:19:36 AM »



Following up on Matt's last devlog, I'm going to wrap up our character creation process by discussing how we are rendering the characters in Lovers in a Dangerous Spacetime. Warning: It's very Unity-y.

When creating the assets in Maya, we typically use multiple quads that are each skinned to the animated rig. If we were to import this model directly into Unity, we would get just that – each quad would have it's own Skinned Mesh Renderer and would account for 1 draw call individually. With this method, we would be looking at between 20 - 40 draw calls per character on screen. Additionally, for our game we needed to be able to use the Unity callback OnBecameVisible/OnBecameInVisible, which uses the GameObject's Mesh Renderer to test camera visibility. Since a character would be made of many meshes, there was no single mesh we could use the callback to check on.

Our solution was simple. In Maya, we would combine all the quads into a single mesh and that would solve all of our problems.


Here is the JellyBomber with the default Transparent/Diffuse shader.

As you can see, that is not exactly the result we wanted. Unity isn't properly Z-sorting on the vertices within the mesh, so quads are being drawn on top of each other in the wrong order. But lo! Unity provides another shader just for this: Transparent/Cutout/Diffuse.



Unfortunately, this also fails to give us the desired look because it cuts off anything that doesn't have an alpha value higher than the cutoff value. A major contributing factor to the look of our game is the bloom around each object. We accomplish this by 'baking' it into our textures in Photoshop, so we don't want our shader's discarding the semi-transparent bloom.


Dat bloom!

What we need is a multi-pass shader that combines both of these qualities to properly render our single mesh characters. We want the first pass to sort the geometry, and the second pass to render the bloom. I made a little shader that accomplishes this, which you can get here.





It is a very basic vertex-lit shader I implemented using just shaderlab syntax.
In the first pass, "Alphatest Greater [_Cutoff]" only renders pixels with an alpha value greater than the Alpha Cutoff (which can be set between 0 - 0.9). This covers our opaque pixels, and Z-sorts them properly.
In the second pass, we set "ZWrite Off" as well as set "ZTest Less".
These settings make sure that the transparent bloom isn't culled by any other transparent quad in the mesh by preventing them from being written to the Z-buffer. Finally we set "Blend SrcAlpha OneMinusSrcAlpha" which is what makes the texture transparent.


Adjusting the Alpha cutoff amount

Now we are finally able to achieve the look that we want for our characters using a single mesh.



Caveats:
This is just the way we are rendering our models, it may not make sense for you, and if you know a better way, we'd love it if you shared it below.
This shader uses Alphatest, which is very not-optimized when used on iOS/Android hardware, for some complicated reasons (I think it has something to do with the Tiled Rendering Pipeline). However, since we're focusing on PC/Mac, this shader does the job for our game.


Additional reading:
Unity Shader reference

Origianl Post:
http://www.asteroidbase.com/devlog/6-2-5d-rendering-challenges/
Logged

Udderdude
Level 10
*****


View Profile WWW
« Reply #89 on: February 04, 2014, 09:34:19 AM »

That's some pretty advanced stuff, looks good though.
Logged
NinthPower
Level 2
**



View Profile
« Reply #90 on: February 04, 2014, 04:30:07 PM »

I've wanted this game for so long, it's awesome, you're awesome.
Logged

Veven
Level 0
*


View Profile
« Reply #91 on: February 04, 2014, 10:15:41 PM »

I use Unity and I'm just learning how to use shaders. I really enjoyed this article, and was surprised at the shader's brevity.

I'm curious, where did you come across the information about Alphatest having performance issues on iOS and Android devices? Is there a repository of information about which devices support the various shader features in Unity? I'd like to implement my own shaders, but I worry about mobile shader support.

I'd love to read more dev log entries from you guys! Keep it up.
Logged
tuckertuck
Level 0
**


Man-child


View Profile WWW
« Reply #92 on: February 05, 2014, 09:51:27 AM »

Thanks!

The Alpha Test thing I have just read at various points.
But in the apple developer section they talk about it:
https://developer.apple.com/library/ios/documentation/3ddrawing/conceptual/opengles_programmingguide/Performance/Performance.html#//apple_ref/doc/uid/TP40008793-CH105-SW2

We've only made a few shaders, because I too worry about support, but regardless if you do decide to make a wicked shader.
Always have a fallback shader and look out for warnings, because a warning on one GPU could be an error on another.
Logged

Udderdude
Level 10
*****


View Profile WWW
« Reply #93 on: February 05, 2014, 02:38:35 PM »

Do you ever wish you had just done the whole thing in Flash? :3
Logged
tuckertuck
Level 0
**


Man-child


View Profile WWW
« Reply #94 on: February 06, 2014, 09:24:52 AM »

Writing Flash shaders is amazing!

Update to the Devlog:
Thanks to Joel via Gamasutra comments, and @trialbyfun on twitter for pointing us to this, but you can in fact control the indexes of the vertices and how the quads will sort by selecting and combining the geometry in Maya from back to front. This will work for some of our geometry but our more complex characters have animations that move in the Z-axis which means that they still need this shader to dynamically sort.
Thanks for the help!
Logged

Beaulamb1992
Level 0
***



View Profile WWW
« Reply #95 on: February 06, 2014, 09:38:04 AM »

Ahh man this is just awesome! cool unique style too Smiley
Logged

matthammill
Level 0
**


Designer/Artist


View Profile WWW
« Reply #96 on: February 07, 2014, 10:32:52 AM »

A WIP monster for GIFriday:

Logged

Code_Assassin
Level 5
*****


freedom


View Profile
« Reply #97 on: February 07, 2014, 10:42:16 AM »

A WIP monster for GIFriday:



Very cool(especially with wire-frame mode enabled). Such jellyfish.
Logged
winkels
Level 0
*



View Profile WWW
« Reply #98 on: February 20, 2014, 01:19:30 PM »



We've had ground-based enemies, which we call Walkers, in Lovers since way back in the days of the GDC 2013 build. Until recently these enemies have been tethered to spherical (well, circular) planets, so programming their movement was simply a matter of ensuring that their distance from the center of the planet was constant and their velocity was tangential to the vector from the enemy's position to the planet's center. However, as we continued to add new scenarios for players to experience we needed Walkers to be able to traverse more exotic terrain. Being the lazy developers that we are, our first attempt to implement a more robust walking algorithm was the simplest and most naive that we could come up with. Luckily for us, it worked out pretty well.



Our naivety lead us to use raycasts to check for a collider underneath a Walker. Shooting one ray from the center may work for some situations, but the Walker would look squirrely as it moves across significant changes in terrain. Instead we shoot two rays, one from each side of the Walker:

Code:
bool doubleRaycastDown(TerrainMovementRayProperties movementRay, float rayLength, out RaycastHit leftHitInfo, out RaycastHit rightHitInfo)
{
    Vector3 transformUp = transform.up;
    Vector3 transformRight = transform.right;
    Ray leftRay = new Ray(transform.position + movementRay.originOffsetY * transformUp + movementRay.distanceFromCenter * transformRight, -transformUp);
    Ray rightRay = new Ray(transform.position + movementRay.originOffsetY * transformUp - movementRay.distanceFromCenter * transformRight, -transformUp);

    return Physics.Raycast(leftRay, out leftHitInfo, rayLength, DefaultTerrainLayerMask) && Physics.Raycast(rightRay, out rightHitInfo, rayLength, DefaultTerrainLayerMask);
}

If both rays hit a collider with the proper layer, we use take the average of the position and normal vectors of the resulting RaycastHit objects and use them to position and orient the Walker, respectively. Easy as that!

Code:
void positionOnTerrain(RaycastHit leftHitInfo, RaycastHit rightHitInfo, float maxRotationDegrees, float positionOffsetY)
{
    Vector3 averageNormal = (leftHitInfo.normal + rightHitInfo.normal) / 2;
    Vector3 averagePoint = (leftHitInfo.point + rightHitInfo.point) / 2;

    Quaternion targetRotation = Quaternion.FromToRotation(Vector3.up, averageNormal);
    Quaternion finalRotation = Quaternion.RotateTowards(transform.rotation, targetRotation, maxRotationDegrees);
    transform.rotation = Quaternion.Euler(0, 0, finalRotation.eulerAngles.z);

    transform.position = averagePoint + transform.up * positionOffsetY;
}

Well, almost as easy as that. Allowing the Walker to rotate an arbitrary amount each frame leads to very jittery-looking motion as it traverses the bumps and crevices. To combat this, we limit the amount it is allowed to rotate each frame using <code>Quaternion.RotateTowards</code>. This tweak goes a long way to allowing for more lifelike movement.

The Walker also had a tendency to get stuck in or clip through certain types of concave geometry.  To overcome this, we added a very short horizontal ray in the direction of motion that extends to about the edge of the character's body.  If this ray collides with any piece of terrain, it will override the downward ray on that side of the Walker.

Code:
if(rigidbody.velocity.sqrMagnitude > 0)
{
    //if moving left
    if(MathUtilities.VectorSimilarity(rigidbody.velocity, selfTransform.right) > 0)
    {
        RaycastHit overrideLeftHitInfo;
        Ray overrideLeftRay = new Ray(transform.position + horizontalRayProperties.originOffsetY * selfTransform.up, selfTransform.right);
        if(Physics.Raycast(overrideLeftRay, out overrideLeftHitInfo, horizontalRayProperties.attachedRayLength, DefaultTerrainLayerMask))
        {
            leftHitInfo = overrideLeftHitInfo;
        }
    }
    //if moving right
    else
    {
        RaycastHit overrideRightHitInfo;
        Ray overrideRightRay = new Ray(transform.position + horizontalRayProperties.originOffsetY * selfTransform.up, -selfTransform.right);
        if(Physics.Raycast(overrideRightRay, out overrideRightHitInfo, horizontalRayProperties.attachedRayLength, DefaultTerrainLayerMask))
        {
            rightHitInfo = overrideRightHitInfo;
        }
    }
}

Below is the system in motion.  The yellow and red lines represent the rays being shot from the Walker, the green and magenta lines are the normals generated from those rays' collisions with terrain and the cyan line is the average of those normals, originating at the average terrain intersection point of the Walker rays.  (The horizontal override ray is not shown.)



The asteroid the enemy is walking on is a compound collider consisting of sphere and capsule colliders, but this system works equally well on an arbitrary mesh collider.

Original post
« Last Edit: February 20, 2014, 09:16:38 PM by winkels » Logged
Veven
Level 0
*


View Profile
« Reply #99 on: February 20, 2014, 03:26:29 PM »

Such a nice simple system, and the end result is very smooth. That's three Raycasts per walker per frame, which I guess isn't bad.

What are you using for enemy AI? Finite state machines? Or behaviour trees? Did you write your own system, or are you using something from the Asset Store?

I just want to say that the bottom gif of the original post was very well made, and perfectly illustrates the important concepts of the code. Well done. Keep it up!
Logged
Pages: 1 ... 3 4 [5] 6
Print
Jump to:  

Theme orange-lt created by panic