Dec 4, 2017 - Bullet-time, Displacement, Knockdowns, etc...

It's another late update, and as I'm typing this I am impaneled in a Grand Jury which will last until the end of the month. Usually I try to get out of these things but I'm planning to take it seriously, learn a few things, and hopefully enjoy the process...

Shaders!

The past week has been mostly a crash course in writing shaders in Unity. I completed about 90% of Penny de Byl’s Shader course on Udemy.  Her lessons go over several topics including shaders that produce outlines, displacements (extrude) which are both features I'd like to add to my game. I already have displacements incorporated to indicate a distortion effect that happens when you use your power on a standing/walking enemy and are trying to pull them toward you. They resist and get warped before succumbing to the power.

Displacement shader:

I duplicated the extrude effect in Penny's course but added in another vector and applied animated sin waves to each axis for a more unique effect:

Outline Shader:

  So, adding an outline wasn't that big of a deal either, the challenge was syncing up the displacements so that both passes line up properly.

Bullet-time-ish effect:

Another feature I added on a whim was the ability to freeze time for the enemy characters. It was easy enough to freeze their animator components and to pause the audio tracks, but the real fun part was setting all of the ragdoll rigidbody nodes to kinematic so they appear to freeze in the middle of their physics simulations.

Transparent shader shadow fix:

I noticed that the blood splatter was missing shadows and i was prepared to add a whole fragment shader pass to fix it. I had no idea what I was doing.  I looked at render queue and a few other things but what finally ended up fixing it was the optional parameters on the lighting model in the #pragma line.  Switching from alpha to decal:blend fixes it. I still don't really understand why this fixes it. There's a lot going on under the hood that I don't fully understand. For now my hacky shader works and that's pretty much turning my frown upside-down.

Change this:
            #pragma surface surf StandardSpecular alpha
to this:
            #pragma surface surf StandardSpecular decal:blend


I'm treating these "blood splatter planes" as giant decals with dynamic texture maps. Eventually I hope to replace this with a procedural shader that can modify the surface color on the fly without disturbing the texture map. I don't know if this will be faster or better, but I think it's worth exploring.

Psychic Knockdowns:

I added the ability to knock down an enemy using the grab mechanic.
Using psychic pull gave me an idea that i wanted to visualize when you are exerting force on a character without moving them, so I went with the wavy displacement that I described above. Kind of like you're making their molecules shift around in an uncomfortable way.

 

Surface shaders vs vertex/fragment shaders:

I'm still trying to wrap my head around the confusing complexity of having surface shaders and vertex/fragment shaders. Apparently surface shaders give you a lot of the hard stuff for free, like shading and shadows so you can go nuts with color. Vertex and fragment shaders give you really low level control such as displacement, shading, and shadow casting. That's where the real fun stuff is but it's also very complicated and easy to break.

I've managed to combine my surface shader with vertex and fragment passes without fully understanding the ramifications of it, but it helped me to get good shading and shadows for free and I appreciate that. There's an odd ambient occlusion pass artifact that I've been noticing. I'll keep an eye on that and fix it later.


What I've been playing:

Payday 2 in VR:
So, first I bought Payday 2 on a recommendation and I hastily started playing it in regular desktop mode and I thought it sucked LOL!  Then I remembered I was supposed to switch over to beta mode in Steam and then I was able to play the VR game. And it's pretty sweet! I only played one level so far and it was pretty damn fun.






Last Week's Instagram Post!

This post from last week has 1970 views! Maybe I'll come up with something new this week...


Record Scratch Sound Effect!

Play Accounting in VR... It's sick and twisted and hilarious. That is all...


Comments

Popular Posts