Heya peeps, it's me again!
Question: I was wondering how I could create an Unormalized Light Vector from scratch?
I was taking a look at several engines out there for RT shaders, and most, if not, all of them, only had premade Light Vectors which were Normalized right off the bat.
So yeah, any helpsies here? I tried a google search, but I'm getting some non-so-standard-language which I'm unable to read, such as this:
/ compute the light vector in model space float3
vec = refPos - pos;
Which I have no idea on how to read it. Does RefPos = to ObjectSpace? And what does Pos refer to? Argh, my poor little mortal brain!
Anyhow, cheers and ciao!
PS: I'm using UDK if that matters, but any HLSL explanation is more then welcome for me.
Replies
Light Vector = objectPos (World Space) - lightPos (World Space)
which would give you the unnormalised light vector in object space...
Curious, though, why do you need an unnormalised light vector?
Unofficial Story: I like learning about shaders ;P
Cheers and thanks.
Yep, that's the idea
Cool to know, cheers!
Ah, got you, that makes sense. Cheers!
1- When transforming my Light Vector to World Space, does it need to be Local, or is there something more to it?
I currently have this LV -> Transform from Local to World -> Etc... (Object World Position - World Light Vector).
2- I was looking up the math for Length, which seems to be this V, is it the correct one, or is there more to it?
Vector3Lenght = (R^2 + G^2 + B^2) SquareRoot'ed.
3- Pretty daft question, but how exactly would I know if my attenuation is working in the 'correct' way? Currently, due to Post-Processing, the results looking like a glowing ball of fire, in UDK atleast.
Cheers!
2. UE3 has a node called distance: http://udn.epicgames.com/Three/MaterialsCompendium.html#Distance
EDIT: OK, to UDK pro's out there, let me ask this, is it even possible to over-ride UDK's shadows when it comes to the materials, in a friendly way, to achieve a controllable SSS?
The reason I'm asking this, is because I noticed the SSS only appears in the non-shadow-culled parts of the mesh, so you're limited in what you can do, unless you very specifically get rid of ALL shadows, which is what I would like to avoid.
The reason I'm asking all this, is because my attenuation doesn't seem to be working at all, while on the other hand, controlling the radius of my light does what I'm trying to do with the material...if that makes sense.
Basically, controlling the Light Radius = Light Propagation on Mesh vs. Attenuation Material = Nothing.
Here is the material I currently have, not sure if anything is wrong with it. Kudos to Ben for his examples, from which I copied to test out the results.
Also, you can control the Emissive Channel? Mind telling me how, that would be most welcome in my case. I tried playing around with the Emissive as a cheap hack, but it doesn't respect the values I put in it.
For example, putting in an Inverted Lambert term, with my SSS mask will make ALL of my mesh Glow, even if I 'cut' the Lambert term in Half with a Power Node, the Emissive will make all of my mesh Glow, it doesn't respect any Terms I put in it.
I just spent some time trying to get that working, and it appears that the emissive input, for whatever reason, doesn't like the Light Vector node. If I use world up, I can get the emissive playing nicely, but the moment I switch the dot from world up to Light Vector, I get a constant value over the entire surface of the mesh...
@Ambershee: Fingers crossed, maybe the old versions of UDK didn't have this issue? Argh, silly UDK.