I've been messing around with trying to get a different look for my materials and decided to try a Blinn specular hit with a Lambert diffuse.
I found this formula
(((V + L)*0.5) dot N)^Shinyness
from an earlier archived thread have wired that together in the material editor that I'm adding to a Lambert model using this formula
(N dot L)* diffuse color * light color (again from same thread)
Although I am assuming the light color value comes from the light itself and is not a node in the editor. But it's not really getting me the expected results. I was looking for something similar to the phong model but different enough to distinguish itself but what I wind up with is an equal distribution of specular across matching surface normals.
Here is a screen grab of my network. I just can't figure out where I'm going wrong.
Replies
If my understanding of things is correct, just adding the vectors and multiply by .5 won't give you consistently unit vectors, so if the mentality of blinn is to use the halfway vector I'm assuming it's about getting that vector as a unit vector, so you would add the two and normalize that.
For testing it in the material editor use MLM_Custom lighting model and plug into custom lighting to see the result, that way you're only seeing that. If it's what you want then there you go! multiply it by your specular values and add it to the diffuse lighting.
Constant Clamp your Diffuse term.
Remember to clamp your Blinn by your Diffuse term, so you don't get any linear anisotropic falloff in the shadows.
Light color cannot be accessed in the material, UDK does the attenuation and color scatter automatically.
Use a image hosting site like Imgur, etc to upload images and link them here.
Camera Vector + Light Vector -> Constant Clamp * 0.5
this result goes into a DotProduct with the normal map texture sample
The DotProduct output goes into a Power node with a float variable as the exponent. (shininess)
This is added to the Lambert function which is the DotProduct of the Light Vector and the Normal map. The output from that DotProduct goes into a Constant Clamp and is then multiplied against my diffuse texture sample.
The result of that multiply is then added to the output from the Blinn network and plugs into Custom Lighting.
For custom lighting diffuse I am using the diffuse texture sample node.
I hope I made sense of that... Hopefully I'll be able to upload a screen grab soon.
Thanks for checking in :cheers:
[EDIT]I'll try that hosting site Ace. I think I'm already doing waht you guys have mentioned but I'm new to this type of network so some of it is still over my head.
If you plot a point in 3D space (think of the 3D viewport in a modeling app), that point has x, y, and z coordinates relative to the origin (each value is saying how far in a certain direction the point is from the origin). If we draw a straight line from the origin to the point we can see that our point is a certain distance away from the origin in a certain direction. Unit vectors, having a distance of 1, are able to describe just the direction for us; if we wanted to describe a specific point in that direction we would multiply the unit vector that describes just the direction by the distance the point is away (a scalar value).
For the math we just want pure directions, we want unit vectors, and to find those we can find the length of our vector (the distance from the origin out to some point in 3d space) and divide by that. The Normalize node does all of that for you.
Now with Blinn you're looking for the half-way vector, so when you add the camera vector and the light vector you get a non-unit version of the vector you're after; it's the right direction but isn't length 1. Normalize that to get the half-way vector.
[If you want to see why adding two vectors and dividing by 2 won't work, draw two vectors coming out of the same origin and then add them together (add their coordinate values and plot the new point, draw a line from the origin to the new point). Notice the length of that is pretty much never 2 unless you're adding the same coordinate values to themselves (basically multiplying by 2), dividing by 2 will pretty much never give you a unit vector, so while adding and dividing by two sounds promising, it doesn't work out]
You can then take the dot product of your half-way vector and the surface normal.
http://www.wildbunny.co.uk/blog/vector-maths-a-primer-for-games-programmers/