|
|
Archive for 'gpu'
Finally after many years of dreaming I made it to SIGGRAPH! And not only that, I also did a talk/course with ReJ for 1.5 hours. This was the first time Unity had real presence at SIGGRAPH and I hope we’ll be more active & visible next time around.
Here it is, 100+ slides with notes: Fast Mobile Shaders (17MB pdf). This isn’t strictly about shaders; there’s info about mobile GPU architectures, general performance, hidden surface removal and so on. Also, graphs with logarithmic scales; can’t go wrong with that!
Posted on 2011-08-17 21:22 in conferences, gpu, mobile, papers, unity | 11 Comments »
Recently a discussion on Twitter about folks using 2048 textures on a pair of dice spawned this post. How do artists know if the textures are too high or too low resolution? Here’s what we do in Unity, which may or may not work elsewhere.
When you have a game scene that, for example, looks like this:

We provide a “mipmaps” visualization mode that renders it like this:
(more…)
Posted on 2011-05-03 18:41 in gpu, rendering, unity | 6 Comments »
I was recently optimizing some OpenGL ES 2.0 shaders for iOS/Android, and it was funny to see how performance tricks that were cool in 2001 are having their revenge again. Here’s a small example of starting with a normalmapped Blinn-Phong shader and optimizing it to run several times faster. Most of the clever stuff below was actually done by ReJ, props to him!
Here’s a small test I’ll be working on: just a single plane with albedo and normal map textures:

(more…)
Posted on 2011-02-01 9:43 in code, gpu, mobile, opengl, rendering | 6 Comments »
Over a year ago I had a thought that “Shaders must die” (part 1, part 2, part 3).
And what do you know – turns out we’re trying to pull this off in upcoming Unity 3. We call this Surface Shaders cause I’ve a suspicion “shaders must die” as a feature name wouldn’t have flied very far.
(more…)
Posted on 2010-07-16 8:38 in gpu, rendering, unity | 5 Comments »
Just spent half a day debugging this, so here it is for the future reference of the internets.
In a deferred rendering setup (see Game Angst for a good discussion of deferred shading & lighting), lights are applied using data from screen-space buffers. Position, normal and other things are reconstructed from buffers and lighting is computed “in screen space”.
Because each light is applied to a portion of the screen, the pixels it computes can belong to different objects. If in any place of lighting computation you use textures with mipmaps, be careful. Most common use for mipmapped light textures is light “cookies” (aka Gobo).
Let’s say we have a very simple scene with a spot light: (more…)
Posted on 2010-01-07 16:27 in code, gpu, rendering | 9 Comments »
I’m catching up on various GPU hacks that exist for Direct3D 9 (things like native shadow mapping, render to vertex buffer, etc.). Turns out there’s a lot of them, but all the information is scattered around the intertubes.
So here are the D3D9 hacks known to me in one place.
Let me know if I missed something or got something wrong. I also want to figure out if Intel GPUs/drivers implement any of them.
Posted on 2009-11-20 14:26 in d3d, gpu, rendering | 18 Comments »
If you’re new to SSAO, here are good overview blog posts: meshula.net and levelofdetail. Some tips and an idea on strided blur below.
(more…)
Posted on 2009-09-17 9:59 in gpu, papers, rendering, work | 12 Comments »
I’ve been experimenting with compact storage of view space normals for small g-buffers. Think about storing depth and normal in a single 8 bit/channel RGBA texture.
Here are my findings – with error visualization and shader performance numbers for some GPUs.
If you know any other method to encode/store normals in a compact way, please let me know!
Posted on 2009-08-04 11:39 in d3d, gpu, rendering, work | 24 Comments »
The saga continues! In short, I need to pack a floating point number in [0..1) range into several channels of 8 bit/channel render texture. My previous approach is not ideal.
Turns out some folks have figured out an approach that finally seems to work.
Here it is for my own reference:
So here’s the proper way:
inline float4 EncodeFloatRGBA( float v ) {
float4 enc = float4(1.0, 255.0, 65025.0, 160581375.0) * v;
enc = frac(enc);
enc -= enc.yzww * float4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);
return enc;
}
inline float DecodeFloatRGBA( float4 rgba ) {
return dot( rgba, float4(1.0, 1/255.0, 1/65025.0, 1/160581375.0) );
}
That is, the difference from the previous approach is that the “magic” (read: hardware dependent) bias is replaced with subtracting next component’s encoded value from the previous component’s encoded value.
Posted on 2009-07-30 14:58 in gpu | 15 Comments »
Almost half a year ago I was wondering how to implement T&L in vertex shaders.
Well, finally I implemented it for upcoming Unity 2.6. I wrote some sort of a technical report here.
In short, I’m combining assembly fragments and doing simple temporary register allocation, which seems to work quite well. Performance is very similar to using fixed function (I know it’s implemented as vertex shaders internally by the runtime/driver) on several different cards I tried (Radeon HD 3xxx, GeForce 8xxx, Intel GMA 950).
What was unexpected: the most complex piece is not the vertex lighting! Most complexity is in how to route/generate texture coordinates and transform them. Huge combination explosion there.
Otherwise – I like! Here’s a link to the article again.
Posted on 2009-06-09 8:08 in code, d3d, gpu, rendering, unity, work | 4 Comments »
|