I've decided I should make this a permanent and publicly searchable page on my blog (I keep losing links), so here's a place where I'll compile shader and material reference (code, scans, samples, best practice documents, reference images, etc) for myself and for other people working on such things. This will likely be primarily focussed on physically based rendering topics, but there may be other stuff here as well.
Showing posts with label math. Show all posts
Showing posts with label math. Show all posts
Friday, January 16, 2015
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.
Labels:
art,
CG,
math,
shader,
Technical Art,
Unity,
videogames
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.
Labels:
3D Coat,
animation,
art,
article,
CG,
game design,
LD29,
Ludum Dare,
math,
shader,
Technical Art,
Unity,
video,
videogames,
youtube
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:
Labels:
art,
CG,
math,
shader,
Technical Art,
Unity,
videogames
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).
Labels:
art,
CG,
game design,
GDC,
LD29,
Ludum Dare,
math,
shader,
Technical Art,
Unity,
videogames
Tuesday, April 15, 2014
Saturday, November 23, 2013
Overthinking Videogames 003: Majora's Mask, Game Theories, and Rough Math
So I took issue with some rough math that was done in an episode of Game Theory.
Here's the video:
Hit the jump the critique:
Wednesday, December 12, 2012
12:12:12:12:12:12
Welcome to the last repetitive date in standard calendar notation any of us are likely to see:
12/12/12 12:12:12
or written another way
December 12, 2012 at 12:12pm and 12 seconds
You know, twelve is a pretty cool number. It has a great platonic solid, the dodecahedron, which many of us will recognize as the die we accidentally pick up when we meant to grab a d20.
But it's not that big a mistake; the two shapes, dodecahedron and icosahedron have a lot in common (also, soccer balls, but those aren't as fun). Let's look at all the cool crap that has to do with 12.
12/12/12 12:12:12
or written another way
December 12, 2012 at 12:12pm and 12 seconds
You know, twelve is a pretty cool number. It has a great platonic solid, the dodecahedron, which many of us will recognize as the die we accidentally pick up when we meant to grab a d20.
Subscribe to:
Posts (Atom)




