framebunker is an
independent game studio
based in copenhagen

Static Sky Unite Presentation

by Nicholas Francis
Aug 30, 2013

Hi peoples!

Due to popular request, I’ve uploaded the presentation from my 30-minute talk at Unite 2013.

UPDATE: now with youtube version of the actual talk

Since the session was so short, I couldn’t really go into the details as much as I’d like. Let me know which things in here you’d like more info on, and I’ll do my best to turn this into real blog posts.

Obligatory eye candy follows:

Get it here (PDF)

Somebody asked me about the code on page 25 to orient a camera for rendering into a skybox. It’s not hard to do but still takes a while to get properly right…

static Vector3[] kCubemapOrthoBases = {
	new Vector3( 0, 0,-1), new Vector3( 0,-1, 0), new Vector3(-1, 0, 0),
	new Vector3( 0, 0, 1), new Vector3( 0,-1, 0), new Vector3( 1, 0, 0),
	new Vector3( 1, 0, 0), new Vector3( 0, 0, 1), new Vector3( 0,-1, 0),
	new Vector3( 1, 0, 0), new Vector3( 0, 0,-1), new Vector3( 0, 1, 0),
	new Vector3( 1, 0, 0), new Vector3( 0,-1, 0), new Vector3( 0, 0,-1),
	new Vector3(-1, 0, 0), new Vector3( 0,-1, 0), new Vector3( 0, 0, 1),

static Matrix4x4 SetOrthoNormalBasisInverse (Vector3 inX, Vector3 inY, Vector3 inZ)
	Matrix4x4 mat = Matrix4x4.identity;
	mat [0, 0] = inX[0];	mat [1, 0] = inY[0];	mat [2, 0] = inZ[0];	mat [3, 0] = 0;
	mat [0, 1] = inX[1];	mat [1, 1] = inY[1];	mat [2, 1] = inZ[1];	mat [3, 1] = 0;
	mat [0, 2] = inX[2];	mat [1, 2] = inY[2];	mat [2, 2] = inZ[2];	mat [3, 2] = 0;
	mat [0, 3] = 0;		mat [1, 3] = 0;		mat [2, 3] = 0;		mat [3, 3] = 1;
	return mat;

by Noah Johnson
September 9, 2013

I was just going to ask about the camera! PERFECT! Thank you!

by Gabriel Sibley
September 13, 2013

I was wondering how you’re doing the lookup into the reprojected cubemap / simplified geometry? Is the entire thing still accomplished in 1 drawcall or does doing the reprojection add a drawcall?

by Cian Mc Sweeney
October 28, 2013

Would you recommend learning surface shaders or vertex and fragment shaders in unity
as I want to start creating my own.

by JecoGames
October 31, 2013

When you said oren-nayar was too expensive did you not try an optimised version like [here][1]


I implemented this using a surface shader and it runs pretty well.

by Nicholas Francis
November 12, 2013

That looks like a nice optimization. Since we’re on mobile, we’re sticking with a LUT-based super simplified CookTorrance

by E
November 12, 2013

Thanks for posting this! I’ve already created something similar to the cubemap reflections technique in Remember Me, but I’ve just been using camera.RenderToCubemap() for generating cubemaps.

So I’ve tried this cubemap rendering that you posted about, in hopes to get better looking cubes, but it seems like when using the posted code my generated cubemap is a solid grey color, with slightly darker borders along the edges of each face. (not even showing any of my camera’s background color)

Having trouble figuring it out, any ideas?

by Slav Pankratov
November 18, 2013


Is there a full source code for “cheap ass cook torrance” available anywhere?


by KillaMaaki
January 5, 2014

Would really love to know what formula you use to generate the BRDF texture (and additionally what range “shine” is supposed to be in – trying 0-256 but no idea if that’s the correct range or not).
The shape of the first mip level is correct, but as the mip levels get lower it degrades until it looks completely wrong at the lowest mip levels (and produces horrid results in the shader).

by Arie Leo
January 27, 2014

is it possible to show the cubemap projection technique and code? i still strugglling with concave/simplified mesh projection

by Arie Leo
February 18, 2014

Is it possible to request an article for the cubemap generation with custom mipmap and cubemap reprojection in custom mesh?? i’m still struglling on those…

by Arie Leo
February 18, 2014

woops…suddenly my post from january showed up, it didn’t showed up before. Sorry about that

by mgear
February 27, 2014

Added the sources that were visible from the presentation to:

but it doesnt work yet.. also note that the shader is currently modified, as it kept giving errors otherwise (if copied directly from pdf/video).

*if anyone knows how to make this work, feel free to post on that github also.

by Simon
March 20, 2014


We tried to implement your solution, but we encounter an “Trying to read pixel out of bounds” exception on the line:

tempTex.ReadPixels(new Rect(0, 0, size, size), 0, 0, false);
in the function EndCubeFaceRender()

Any idea what could cause this exception?

Thanks in advance for your answer.


by Tharyn
March 13, 2015

Great stuff, I very much enjoyed your talk!

Would you mind posting the code of the c# script that generates the lookup tables?


Add Your Comment