Everything has Fresnel


You can sorta think of this post as part 2 of my “Everything is shiny rant”. While standard specular lighting is pretty common in games, one effect that we rarely see in games is proper fresnel.

Hopefully, you know what specular is by now. The most common model for specular in video games is Blinn-Phong, which is:


H = normalize(V+L);
specVal = pow(saturate(dot(H,N)),power);

In this case, V is the view vector, L is the light vector, N is the normal vector, and power is the specular exponent. H is the derived half vector, and it is the vector half-way between the View and Light vectors.

How does it work? Here’s a diagram.

(more…)

Everything is Shiny


Every once in a while I’ll see a tutorial online or a paper that talks about specular. And it will have a line like “Some materials such as cloth and cardboard are pure diffuse surfaces with no specular”. This is a lie. Every object in the real world has specular, even good old cloth and cardboard. I took these with my homebrew polarized lighting setup. Since I was holding the polarizer manually, the separation isn’t perfect, but seems to work well enough.

First, we’ll start with a cotton shirt. This is the most diffuse one I could find. Most cotton shirts have more specular.

Main:

Diffuse:

Specular:

(more…)

Where are my subpixel triangles???


Here’s a question that comes up a lot. According to the spec sheet, the RSX in the PS3 has something like 250 million triangles per second. Then, you can do the math. If we are hitting 30 fps, then we in theory get 8.3m triangles per frame. The resolution of a 720p display is 1280×720, or 921,600 pixels. That means we get about 9 triangles per pixel. At the top is a screenshot from Uncharted 2, and clearly we aren’t getting 9 triangles per pixel. So what gives.
(more…)

A Head! And a Rendermonkey Scene?


Well, it looks like our prayers to the CG gods have been answered! Lee Perry-Smith over at Infinite-Realities has answered the call and made his head available for use. And by his head, I mean literally, his scan of himself. Here is the link to the head scan. Also, under that page he has the 6 million poly zbrush file with the subdivision layers intact if you’re an artist and you want to cause trouble. It’s licensed under a creative commons attribution license which means that you can use it, but if you redistribute it, you have to give Lee credit.
(more…)

Cross Bilateral Filters for Skin Shading


Hope you all don’t mind a plug for a cool skin paper written by Morten Mikkelsen. Morten is a programmer for the ICE team at Naughty Dog, and he has put together a technique getting faster skin shading using a full-screen buffer.

The paper:
http://jbit.net/~sparky/subsurf/cbf_skin.pdf

Gamedev.net discussion:
http://www.gamedev.net/community/forums/topic.asp?topic_id=581761

In Morton’s words:
Essentially, it’s a screen-space approach to simulate subtle effects of local subsurface scattering. Convolution is done in a separable way which makes it fast
and the cost of simulation is not affected by the amount of lights, light model or the amount of characters on screen.

The core idea to this work (which is derived in the paper) is that convolution by a Gaussian, across a surface, can be expressed as the cross bilateral filter (cbf)
in screen-space. The distinction between regular just blurring in screen-space and using the cbf is shown in figure 3. Using the idea to make results appear more skin like are shown in figures 4 and 5.

So if you are into skin shading you should check it out. For current-gen consoles, we can barely afford the most basic of lighting models (blinn-phong with fresnel), so it’s probably a little optimistic to hope for full-screen subsurface scattering in the near term. In the future though, anything is possible. In particular, what I like about the full-screen techniques is how they handle lightmap resolution.

In U2, for cutscenes, we render the lightmap into UV space, and then use the blurred version of that buffer for subsurface scattering. But when we have a closeup of Chloe’s hand, her fingers occupy such a small area in UV space that our approach doesn’t really work. With a fullscreen approach however, you always have enough resolution exactly where you need it.

As we start thinking about the next generation of consoles, it’s possible that we could afford some kind of subsurface scattering on all characters in realtime. Getting faster full-screen approaches seems like a promising avenue.

Anyways, check the paper out!

Early Z-Cull with Clamped Depth


Check out these pool balls from the PSN game Hustle Kings. They do a pretty cool trick where the balls where they render a quad in front of where the ball should be. Then they essentially do a ray-sphere intersection in the pixel shader. It’s a pretty cool trick and looks pretty good. You can find a more detailed explanation at the VooFoo Studios website.

In the future, I’m pretty bullish on techniques that so some kind of mini raytracing inside a pixel shader. That’s a longer post. But the question becomes what to do with early z-cull for pixel shaders that change the depth. Here is a quick picture showing the problem.
(more…)

Can someone please buy a head?


We need a head. Preferably a bald, white male, mid-20s.

This issue popped up for me at Siggraph, but it has been a problem for years. At my course on lighting shading in Uncharted 2, I had to put a Rendermonkey scene together showing off the skin shading in the game. So I used the Lazarevic head, which no one else has access to. This is a problem because:

  1. No one else has access, so I can’t give the scene to them.
  2. No one can do a direct comparison of this technique versus other techniques, since the head isn’t available.

There are a few heads out there, but each one has a catch.
(more…)

Is this research for next-gen or next-next-gen?


One of the cooler things about Siggraph is that we all get to drink some Kool-Aid and yell at each other over the future of graphics. One set of course notes you should definitely check out is the Beyond Programmable Shading course. For me, the theme of Siggraph was “What would it take to actually solve this problem”. Instead of thinking about what hacks we can do to get slightly less-worse results, most talks seemed to focus on actually solving these things for good.

Problems for film-like rendering:

  • What would it take to have no aliasing anywhere.
  • What would it take to get sub-pixel triangles everywhere.
  • What would it take to have perfect shadow resolution with no acne.
  • What would it take to have perfect soft shadows with clean edges.
  • What would it take to get true environment reflections.
  • What would it take to get correct real-time GI.
  • What would it take to render hair as unique strands.
  • What would it take to get true lighting models.
  • What would it take to get correct order-independent transparency.
  • What would it take for photoreal water/fire/smoke.
  • What would it take for proper caustics.
  • What would it take for proper light scattering in media (i.e. smoke, thick liquids, etc).

Yes, there were some talks that focused on incremental improvement via hacks (like my talk), but the focus seemed to be on actually solving these long-term problems. Also, the consensus for most of these is that we can’t really solve these problems by just scaling up current hardware. In order to really tackle them, hardware has to change in some fundamental way. So the question becomes are we going to care about these for next-gen (PS4, Xbox 720), or are we going to wait for next-next-gen (PS5, Xbox 1080).
(more…)

CPUs and GPUs: Converging?


It seems like I constantly hear about how CPUs and GPUs are converging. That CPUs are getting more GPU features, GPUs are getting more CPU features, and that eventually they will converge into one happy processing unit. I disagree, and here’s why. Btw, that picture above is NVIDIA’s Fermi die.

Why CPUs are slow(er).

1) Load and Store

These two instructions destroy CPU performance. Reading data from registers and L1 cache is fast. Reading data from L2 is slow. Reading from L3 is slower. Reading from main memory takes forever.
(more…)

Do any broswers resize images in linear space?




After the last post where I talked about the ideal way to correct for gamma when mipmapping, I thought I’d do a quick rundown of current browsers to see if any account for gamma when resizing images. So I did resize tests in IE7, Firefox, Minefield (pre-release Firefox), Chrome, Safari, and Photoshop CS2. Any of them gamma-correct? Unfortunately, the answer seems to be no.
(more…)