Geenz's Shader Stuff - Now with more lightmap shaders!

Hello everybody!
I’m a bit new to the forum here, however silently in the background I’ve been working on my own little projects to enhance unity’s usability!

One such project is my Ramp Shader. To keep it short and simple, Gz Ramp Shader is a shader to simplify the process of simulating a variety of shading styles and surface type specific shading.

It uses shading ramps; gradients that define the overall shading of a surface whether it’s the surface’s specular shading, or the surface’s diffuse shading.

It also allows for an artist to change the overall light contribution to the shader it’s self.

You can find the web player here: http://bit.ly/cvcTfB

And now for a couple of screenshots :smile:

From left to right: “Toon” and “Lambert” Ramps, with the “Medium Toon” and “Subtle” specular ramps applied.

Nice job. I’ll check this out as a possible replacement to the skin shader I’m using right now.

Nice work, and good demo of it too.

Thanks :smile: You can also provide colored shading ramps for both specular and diffuse shading, making it very effective for skin shading, and shading for car paint. You could actually simulate dual specularity this way, or even triple specularity, or however many specular colors you want to display at once, so long as it all fits in the same diffuse space.

I’m also working on an “exponential” diffuse shader that works very similarly to UDK, and also a shader that simply allows you to input an image that defines the specular highlight’s shape (making it possible to simulate anisotropic highlights with minimal impact on performance).

Case in point:

Meanwhile, in the Cattelab, I’ve been experimenting with pre-computed lighting that can be used with bump maps and the like. So far, the results provide some nice stylized effects for ambient lighting, but direct illumination really needs some work.

The cool thing is, once I’m done with it, you’ll be able to get results that could beat UDK and Unity 3 simply because
A) it will support proper specular highlights, not UDK’s “fake” highlights it applies to light maps and simply masks by light color, and
B) the way I intend to do it, it would also support “grabbing” light vectors from a light map and applying to a character.

I’ve already got pre-computed light vectors with attenuation and shadows partially working, I just need a renderer that can output them properly.

Alternatively, I suppose I could just find a way to calculate tangent space lighting vectors on the fly based off of the lightmap’s z coordinates, but that would defeat the purpose of pre-computed lighting to an extent :stuck_out_tongue:

You can now purchase my shaders at UnityPrefabs here.

There is only one real light source in this scene.

Not sure what a light vector is, but does this mean we can have lightmaps that darken/lighten dynamic objects?

Afaik this is something most games have, but I have no clue how to implement it myself. :slight_smile:

Yes.

Is this a solid method of approaching that problem?

Will it work in caves, houses etc.?

There seems to be multiple possible ways of achieving this, and some that only work without geometry overlapping vertically.

Either way I’m interested.

Also, having bump maps show up without pixel lights sound great as well.

So long as there’s a way to “bake” light vectors (not light colors), you’d be able to sample the appropriate light direction on a dynamic object. So it’d work on just about any geometry that has a pre-made light vector texture applied to it. The only draw back would be, you’d get a weird “shifting” effect on any dynamic objects depending on how fast you update the current light vector sample on the dynamic object.

Technically, this is a per-pixel technique. But the pixel lights don’t actually exist in any form. They’re all pre-calculated.

On another note, I’ve implemented colored specular mapping into the shader as well, giving it this UDK-like appearance:
http://grab.by/6h3w

That last image is without any lights in the scene?

Just a lightmap?

That’s extremely cool. :slight_smile:

Correct.
Same shader, different lightmap applied:

http://snowcatdesign.org/gzlightmap/
Web player is up, enjoy~

While I was going though and working on the shader, I decided to modify one of the pre-computed light vectors that was generating bump map and specular shading. Here’s the results:
Before:

After:

Another example:
before:

after:

This is really cool. How does a lowly user like myself get ahold of a shader like yours. One that allows the use of Normal and Spec effects on a light-mapped object? Can I buy it from you?

Indeed.

This is an interesting idea.

So what you are suggesting is that instead of storing just the light color (in hdri) per pixel of the light map, to store a vector that would denote the light direction so that specular and bump map could be properly computed?

But then you can only store 1 vector per pixel for each map. Which vector would that be, if there are more lights shining on a specific point of the surface?
Those can’t be just average of all lighting.
And what about bounce lights? There are too many, you can’t capture that information in 1 vector.

So that means that you basically need multiple “light direction” maps to account for most of the lighting in the scene.

Are there any light bakers that can output the information you need by the shader?

I don’t entirely understand what GennadiyKorol is saying, but at least in my case the scene is an outside scene and I bake my lightmap in 3ds max. There’s only one light, the sun, and then there’s the bounced skylight (which doesn’t need to be taken into account).

So all I need from this shader is the ability to tell it where my sun is (which I’m guessing could be that vector you’re talking about. :)) so I can have proper normal maps and specular in relation to my sun because my lightmap is the only form of lighting in the scene and without a shader like this my textures will be completely flat.

So in theory it sounds perfect for me at least. :slight_smile: