Monday, July 26, 2010
Shader Tips.
I've been working on a high end shader over the last few days. this particular shader needed a diffuse map, a normal map, a specular map (color and alpha mask), a cube map, and a fallback texture. The cube map provided reflections which were mapped over the normals (from the normal map) of the model. Here are some random things I've learnt.
1. Add ambient light, don't multiply.
2. To mix colours, multiply them together, then multiply by 2 to retain the same brightness.
3. Use the Unity3D macros in UnityCG.cginc, they make life much easier.
Subscribe to:
Post Comments (Atom)
Popular Posts
-
These are the robots I've been working on for the last 12 months. They each weigh about 11 tonnes and have a 17 meter reach. The control...
-
This hard-to-see screenshot is a Generic Node Graph Editing framework I'm building. I'm hoping it can be used for any kind of node...
-
Unfortunately I've not secured a venue for the GGJ. With 9 days left, things are not looking hopeful. It could be that GGJ Perth will no...
-
So, you've created a car prefab using WheelCollider components, and now you can apply a motorTorque to make the whole thing move along. ...
-
MiddleMan: A Pub/Sub and Request/Response server in Go. This is my first Go project. It is a rewrite of an existing Python server, based o...
-
Often, when building a game, you need to test if objects are colliding. The objects could be spaceships, rocks, mouse pointers, laser beams....
-
I've just read a newspaper article (courtesy of Kranzky ) from WA Business News documenting the malfeasance, gross negligence and misc...
-
Space is awesome. Especially when it is generated using Perlin noise, and some cool shaders. You can try it out over here.
-
I made something which lets you render very large worlds with a small farClipPlane. https://github.com/simonwittber/scaled-origin The d...
-
After my last post, I decided to benchmark the scaling properties of Stackless, Kamaelia, Fibra using the same hackysack algorithm. Left axi...
2 comments:
"2. To mix colours, multiply them together, then multiply by 2 to retain the same brightness."
"Same brightness" as what? Color1 or color2? The average? If you only want to mix the "color", not the brightness, you likely need to convert to a different color-space (like YUV or HSB).
I may be confused, but I think you're doing:
vec3 col0 = vec3(0.1f);
vec3 col1 = vec3(0.1f);
vec3 your_result = 2.0f*(col0*col1);
vec3 correct_result = mix(col0,col1,0.5f);
- giving
your_result = 0.02f
correct_result = 0.1f;
(the math works for 0.5 though :P )
LOL. I have much to learn. :-)
Post a Comment