Saturday, November 15, 2014

Physically Based Shader 1.1: "Simple Physical Shader"

My physical shader is now released! Check out the demo video for Simple Physical Shader 1.1:


Learn more and get the playable demo here:
http://ryangatts.weebly.com/simple-physical-shader.html

Get the shader on the Unity Asset Store here:
https://www.assetstore.unity3d.com/en/#!/content/22143

Simple Physical Shader is a general-purpose physical shader that is intended for users who are new to Physically Based Rendering (PBR) and want a simple shader that can be mixed and matched with the Unity default shaders.

Simple Physical Shader works on Unity Free, on any devices that support Shader Model 3.0, and was developed to provide a usable PBR shader for projects that don't use HDR or linear lighting and for users who don't want to worry about baking out cubemaps. It uses maps that are human readable and easy to generate.

It's still under development, so expect support for core and edge retroreflectivity (for safety vests and velvet materials) as well as one that has a second specular lobe (for materials with a clear coat on top like car paint or wet skin).

Tuesday, October 28, 2014

On Internet Arguments, Feminism, and GamerGate

I've been having a pretty interesting discussion about criticism, feminism, and videogames on Youtube, and I felt a need to preserve it, so I'm copying the conversation here. What I find interesting about this conversation is that as it has gone on, the anger and immediacy of the conversation has worn off, and we've managed to find some common ground.

I haven't written much about feminism or representation in videogames here, but it is a subject that is close to my heart. At least part of my posting of this was prompted by FilmCritHulk's excellent and amazingly empathetic essay here: http://badassdigest.com/2014/10/27/film-crit-hulk-smash-on-despair-gamergate-and-quitting-the-hulk/ . I want to try to bring to bear some of his calm demeanor in my own discussions -- especially around touchy subjects like GamerGate and feminism. I have these kinds of conversations all the time, so I felt the need to time-capsule this one up as an example. This is not an example of someone winning an internet argument. This is not me bragging about how good I am at arguing on the internet. This is just an example of two people managing to reach some amount of common ground.

This conversation is in response to the ExtraCredits & IdeaChannel collab video here: http://www.youtube.com/watch?v=7lPUlN0dnKk

Fair warning: this is a really long internet argument that turns into a really long internet discussion.

Monday, October 20, 2014

ShaderLab + CG highlighting for Notepad++

I finally got around to fixing my style and code highlighting for Unity Shaderlab CG in Notepad++. If you want something similar you can download it here: link
To import it, download this file to Appdata>Roaming>Notepad++ . Then, in Notepad++, go to Language>Define Your Language... and click the import. Make sure you set your global background style to something dark (Settings>Style Configurator>Enable Global Background Colour).

It's based on Luiz Alvarez's CG highlighting, with some color style edits to make it look better and work on a dark background, and additional keywords added so that major shaderlab terms are highlighted.

Tuesday, October 7, 2014

Hatching Shader

I was troubleshooting some shader problems on the Unity forums, and ended up overhelping and making a pretty decent-looking crosshatching shader (if I do say so myself). Here's what it looks like:


The UV math is a little messed up, but I think it looks pretty cool :D.

---edit---

(can't stop. won't stop) I went ahead and fixed the uv math. It now uses the UVs of MainTex rather than of Hatch0 as it's main input. I was going to resolve (read: "re - solve" as in "solve again") all of the other UVs separately, but it made the inputs a pain to set up when making a new material, so I just left the Hatch Density input.

Friday, October 3, 2014

Explosions with shockwaves

So, implementing this in a dynamic way is still giving me some lingering sorting/rangefinding problems, but I think this effect has legs :)


The green lines are debug. The explosion effect performs a check to see how far away it is from the ground and then spawns user-defined secondary effects based on how close it is. These effects also fade out the farther away the explosion occurs (by manipulating the start color alpha value of the shockwave effects). As you can see on the left, those two explosions are close enough to the ground to kick up a vertical column of debris underneath them. The explosion on the right is too high, and only spawns the shockwave ring. 

These effects can also be delayed slightly to give the impression that it took time for the expanding pressure wave to reach the ground and kick up the dust.

You can also see the sorting errors that are currently causing me trouble :/ Unity never has been very good at sorting particle effects. Does anyone know a good way around this problem?

Thursday, October 2, 2014

Lit Particle Shaders Demo

I've been working on some custom shaders for Shuriken particle effects in Unity. The main idea is to fill gaps that currently exist in the available alpha blended material.


Crucially, the default alpha blended material does not receive light from the scene -- not ambient or direct illumination. I originally wanted to also support point lights, but with the current limits on what data you can know about particle positions and normals, it ends up being a fairly complicated and performance-prohibitive feature.

That's why my shader supports lighting from directional sources and ambient sources. I did manage to get vertical hemispherical lighting working, so particles can receive disparate lighting from the top and bottom (either directional on top or on bottom).

There's also not good default way of modelling emissivity in particles. You have to either have two particle systems with two different materials one alpha and the other additive, or take what you can fudge from the alpha blended. I found myself always making "glow" particle effects to play alongside other effects, so I just wrote a shader that supports that kind of effect by using multiple passes and materials. Unfortunately, Shuriken can only pass one float4 value through the vertex color input of a CG program, so the "color" values in the Shuriken system only refer to the glow color and the general alpha of the particle. The "background" color of the particle can only be adjusted per-material. This turns out to not be much of a problem in practice, though, and it's an unambiguous step up from the default workaround for this effect.

Anyway, I hope to make it available for purchace on the asset store shortly.

Monday, September 29, 2014

Some Particle Flipbooks

I've been working on various techniques for making particle flipbooks easier to author. I've done some tutorials on fire and smoke (you can find them on my youtube channel), but I want to share a sort of gallery of effects I've managed to get and how I got them.


So, initially, I was trying to reproduce the look of GTA5's particles, so I tried baking out fluid simulations from Maya. The sim on the right was solved in 2d and was pretty quick to solve and render. The one in the middle was solved in 3d and was really really slow to work with. These two both have nice subtle animation, but they took forever to set up and to bake. The one on the right is generated completely from turbulent noise effects and masks in After Effects. I felt a lot more control here, and it was much faster to make (I'm very comfortable in AE, though, so your milage may vary).


These two effects were both hand made without a sim. The one on the left was made using the same kinds of noise effects as in the smoke effect above. The one on the right was animated as traditional frame-by-frame 2d animation in Flash and then modified in After Effects to add detail. I have a tutorial for how to do this on my Youtube channel, but suffice to say, it gives you a lot more control over the final look of the effect. That said, this technique doesn't scale well to effects longer than 32 frames long (or 64 if you're really patient). Because it relies on hand-drawn animation rather than tweens, as you double the length of the animation, you double not only the cost of keeping all the sprites for the animation in memory during the game, but also, you linearly increase the amount of work to make the effect in the first place, which is a problem that tweens don't have.

Anyway, feel free to ask questions if you have any. I have many many more flipbooks than these, but the ones here are fairly representative of the various ways I've tried to solve fire and smoke systems.