Sunday, July 6, 2014

Physically Based Shader v0.12

More progress on the Physically Based Shader for the free version of Unity. I've improved the math for the ambient diffuse contribution. It should now behave very similarly to hemispherical ambient light solutions you might see elsewhere. Next I'll probably re-tackle the math for how the ambient light setting is combined with the RSRM. The one I'm using still ends up a little too saturated in extreme lighting conditions -- though it's really not noticeable in most scenes now.


This scene is wearing out its usefulness in demonstrating new features, so this may be the last time you see the bunny, the rocks, and the kyles like this. I actually broke this scene in the latest version of the shader and had to reset the material settings, lights, and camera by eye. :/ The shader can cast and receive shadows now and I've fixed a bug that couldn't be seen in this scene where objects that were lit by multiple point lights would double accumulate fog.

In the new scene, I'll also be showing off new tools for wrangling scene render settings, skybox tint, key light settings, distance fade-able flares, ambient light-skybox calibration, and a fog light scattering approximation. So stick around for that!

Hit the jump for a couple more pictures including just the ambient contribution and some different lighting conditions.

Tuesday, July 1, 2014

Face Contouring Makeup

I was taking some notes on basic makeup layout for "contouring" which, for those uninitiated, is using makeup to emphasize attractive contours of the face by highlighting or shading. I only made them as part of my personal note-taking, so it's all way overdone and not very subtle, but I thought I'd share them here as they are broadly applicable to painting, modelling, and texturing of faces:


Other than the red, the colors are not meant to be taken literally, but as broadly representative of either darker shading makeup or lighter highlighting makeup. Hope it helps somebody to have this laid out for them clearly :).

Sunday, June 29, 2014

Ludum Dare 29: 72 Hour Jam Game: The Fields



The above video has a breakdown of game design and technical art decisions made while making my latest jam game "The Fields". Hit the jump for a link where you can play the game, a quick synopsis of the game, bunch of links about shaders and graphics programming.

Thursday, May 8, 2014

Physically Based Shader v0.11

RSRMs are up and running on my PBR shader.

Local point lighting.
Directional lighting from behind camera. Materials are exactly the same.
Here's a quick demo of the setup. You can see a material with various levels of smoothness and metallicity:

Sunday, May 4, 2014

Physically Based Shader v0.10

So I started learning CG a few weeks ago (partly inspired by an awesome GDC talk by Sean Murphy) in order to build a physically based shader. This here is the first version of that shader:


The shader takes four texture maps: "main color", "smoothness", "metallicity", and "normal". The main color gets split into the specular and diffuse map based on the smoothness and metallicity of the material. The specular contribution is a normalized Blinn-Phong and the diffuse contribution is an NdotL normalization that I made. Using a "light wrap" property, the material can transition from a lambert, to Valve's half-lambert, to a perfectly translucent material. This wrap can be used to help emulate partially bounced light and subsurface scattering with minimal additional cost. Both the spec and diffuse contributions are affected by a fresnel term that is softer on rough materials and shallower (due to a higher base reflectivity) on metallic materials. I also decided to use a physically-inaccurate attenuation model that uses a gaussian curve instead of the square of the distance. This sort of falloff is much easier to work with in a practical case because near to the illuminated object, it better models the light coming off an object that is not an infinitesimal point. This attenuation is currently calibrated to work best at ranges up to 15 meters (after which, the contribution of an individual light falls effectively to zero, and the light can be culled).

I had this shader nearly finished when Ludum Dare 29 started last weekend, so I used it all through the production of "The Fields" in order to test the shader's applicability in an actual production.

Rabbit in a minefield; lit by one directional light and an ambient.
I'm happy to report that it went pretty well! I discovered a bug that caused negative lighting in very rough, very metallic materials, but luckily, I was working in a game that only had rocks, dirt, wood, grass, and bunnies, so it wasn't much of an issue. After LD, I went back and fixed the bug (a problem in how I was normalizing my spec contribution that could cause it to go negative) and here we are at version 0.10!

Since it doesn't take very many maps and two of the maps are black and white, I found it pretty easy to work with and maps were generally pretty easy to generate. Everything except for the wood is hand-painted, and the only things in the scene not using the physical shader are the alpha cut-out materials. I hope to have a greater variety of colors and materials to shade in the next use case; World War I is not a very vibrant setting.

I still have a ways to go. The current shader uses the unity ambient light to determine non-direct shading and environment reflectivity. This looks okay on rough materials and diffuse materials, but becomes obviously flawed on specular metals -- especially when they have a not-very-noisy normal map. Next version will support RSRMs that will either be stand-alone reflectance maps, or will be overlayed on the ambient light and provide more value information than color. I think I'll add support for cube maps, since the main point of this shader is to be easy to work with and cheap to render, and I find cubemaps (and their mips) to be a pain in the ass to generate and work with (you can only ever appreciate them on extremely smooth surfaces, and if you have a lot of those, the failures of non-parallax corrected cubemaps start to show anyway).