Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Understanding different games' shaders.


Nemox

Recommended Posts

Each time I hopelessly come back to my projects with such futile notions that I might actually get something done for once, one thing strikes me the most. My objects and characters look like crap, and my game thusly feels to crappy to care as much as I would like to. That is to be expected of course, given that I'm using little more than Diffuse lighting.

But I've been learning about writing surface shaders and custom lighting models. I have a pretty good idea of the flow of data at this point, but not a very good understanding of common practice and stylized lighting.

At first I attempted to copy Star Wars: The Old Republic's style, and at first I assumed that the rim lighting was an exaggerated Fresnel effect. As much as I tried, I couldn't get anything remotely similar.

But then I tried walking around I noticed something in SWTOR that I had previously noticed in Sonic Generations: The rim hilights do not depend on any angle between light and view directions, but the rim light simply exists wherever the light is shining, and has a falloff based on viewing angle.

In Generations, Sonic's rim lighting seems to do something similar, but I'm not sure what's going on. I see rim lights of some sort that seem to come from both a downward and faint upward light of varying colors, but not on the sides. I also can't quite figure out whether the effect is intended to be emissive or specular.

What exactly is going on under the hood?

EDIT: I've found a flaw in my old lighting, and tried again on the SWTOR shader, applying it to Sonic, and it looks spot-on! I think the extra light coming from below is just some extra light source in the grass. It even answers the confusion I had about making surfaces feel more vibrant. There's a nice contour along the rim light, and it doesn't feel forced like all the ones I had before, coming from all angles.

Here's an example of a couple of angles with two light sources; white directly from overhead, and red on the side. I'm gonna mess around more with this and see how many types of objects this type of lighting might apply to...

SonicShadertest.jpg

Link to comment
Share on other sites

Luckily it seems that in that last fix I've answered my own question with regards to character shading. xD

Still though, environments are something I still have yet to figure out. I suppose on the off chance that someone who does have some experience with shaders happens by, there's still that to shed some light on. Pun intended of course.

Link to comment
Share on other sites

The ones posted in that thread are for Max and Maya, while Unity's shaders must be typed out. There have been a few node-based editors made but the ones I've seen are missing some key functions.

Would be quite beneficial however to analyze those if I can manage to, and see what a real Fresnel calculation looks like.

Shader "grammar" is quite a bit different from regular scripting, but the idea's pretty much the same. You've got some properties about a surface, what happens to the property, and the result.

Unity's surface shader system simplifies it a lot so it's essentially a structure of data, perform the surface shader function on it (textures, normal mapping, specular mapping, etc.), then it goes through whatever lighting function you make for it, and out comes the color to go on-screen.

Luckily, most of it is copy-paste work. It's the really stylized stuff that takes a little creativity.

That picture in that thread has a rim light hilighting all the edges of the ogre, which can be desired in some games. But what I did is take the same kind of rim lighting, but multiply it by the value of regular diffuse light. The result is that it only shows up where light is actually shining from.

Link to comment
Share on other sites

Well, I can offer a few methods, but I only know Maya, so you'll have to do some interpreting...

So then, shall we begin?

- Method 1: Do as you're currently doing, with a few light sources hovering around him and the environment constantly emitting a faint glow.

- Method 2: Create an invisible wireframe of Sonic that is ever so slightly bigger and follows his movements 1:1, and emits a faint glow.

- Method 3: Put light sources inside Sonic himself at a few key points, so that he kind of glows.

- Method 3a: Alternatively, you could make Sonic himself a very faint light source, he'll glow just a little, but not too much.

Link to comment
Share on other sites

Honestly this is all you need to understand.

Is it strange that my mind instantly jumped to Peter Molyneux?

Well, I can offer a few methods, but I only know Maya, so you'll have to do some interpreting...

So then, shall we begin?

- Method 1: Do as you're currently doing, with a few light sources hovering around him and the environment constantly emitting a faint glow.

- Method 2: Create an invisible wireframe of Sonic that is ever so slightly bigger and follows his movements 1:1, and emits a faint glow.

- Method 3: Put light sources inside Sonic himself at a few key points, so that he kind of glows.

- Method 3a: Alternatively, you could make Sonic himself a very faint light source, he'll glow just a little, but not too much.

Hm, those are interesting ideas, and I particularly like the idea of having lots of small light sources scattered throughout levels.

Applying an emissive shader could accomplish methods 2, 3, and 3a without affecting anything around him, and would also be pretty optimized for gaming.

That does remind me though, I remember going around in Green Hill zone, I saw many unexpected colors shining on Sonic, such as the orange rocks and green grass. I'm willing to bet there might be different reflection maps applied to Sonic's whole body, and given what I've seen of that Specular texture he's equipped with, that could be why it's not so overbearing.

So in essence, it might be a reflection map acting emissively to produce extra light sources on his body, applying them only where the specular map allows, and then only applying as a rim light!

I think I'll do another runthrough and see if anything else is affected by the same lighting. If they are, it could very well just be extra light sources emitting from various world objects.

EDIT: Yes! I believe this is exactly what's happening! Going through Green Hill again, I noticed that there was always some of this "glow" from certain angles, and it occurred even in shadowy areas. The brightest one was the only one that required a light source.

I would see green light shining under Sonic's body throughout the level, even in areas with absolutely nothing green around. However, this changed in a couple of select spots. In that rocky tunnel the glow changes to a fitting orange/brown color, and continues even in shadows. There is a precise spot where the transition happens, and it is pretty instant.

In fact, when I stood on the spot and walked around a bit, it appears I tricked the game and maintained the green glow in an area where it was supposed to be orange. I'm confident that it is indeed a reflection map.

Link to comment
Share on other sites

Is it strange that my mind instantly jumped to Peter Molyneux?

Heh, I was thinking Ken Balough and his hilariously ignorant insistence that texture res meant there was no benefit for S4E2 PC to run higher than 720p, but yeah Molyneux is on a level of his own.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...