Forum: Poser - OFFICIAL


Subject: How do I make a surface a light?

Pagrin opened this issue on Jun 19, 2007 · 107 posts


bagginsbill posted Tue, 19 June 2007 at 11:32 AM

Jon,

BRILLIANT - ABSOLUTELY BRILLIANT! I can't believe I never thought about this. I believe this may be the single most important reason that Poser indoor scenes look fake. The lights do not obey the inverse square law!

Be more than pleasantly surprised. Be very surprised. For I have figured out how to add this to any spot, point, or infinite light in Poser.

The screenshot above shows how this is done. You must put this shader network INTO THE MATERIAL FOR YOUR LIGHT! I have attached an actual Poser 6 material file, RSquaredLaw.mt5. I had to add the filename extension .doc to it to be allowed to upload it here in the forum. When you download the material, MAKE SURE YOU REMOVE THE .DOC from the name. 

Some of you have your PC set up to not allow you to do this. Before you click the attachment to download it, you must make sure your PC is configured to not hide the file types from you. Go into any explorer window - just click on your "My Computer" shortcut to bring one up. Choose the menu item "Tools" then "Folder Options...". Click on the "View" tab in the Folder Options dialog. Look in the "Advanced settings:" listbox. There is a checkbox labelled "Hide extensions for known file types". TURN THAT OFF. You will no longer be treated like a baby by Windows. You can now choose to rename files as you see fit.

OK with that out of the way, download the attached material file and save it in your Poser Materials library somewhere. Be sure you notice where you put it. Go into Poser. I suggest you drop down to just one light for your first test. Pick a light and set it to Infinite, Spot, or Point. Point is best to see the effect. Decide where to place your point light in your scene. Do a test render so you know what it looks like.

You must do a little setup on the shader. I designed the shader units to work in Inches, so if your Poser Display units are not inches, change them to inches. On the light Parameters tab, look for the "Transform" section. You can read off the exact coordinates of your light in the xTran, yTran, and zTran parameters. Write them down on a piece of paper. My light was at 20, 60, 100.

Now select your light, and go into the material room. MAKE SURE YOU SEE YOUR LIGHT THERE. Double click the file I gave you to download. It will load this shader into the light.

There are two nodes you need to edit. The first node is Unit_Distance_V1. The parameter Value_1 is going to be the "Unit Distance" - in other words, this is the distance from the light where the intensity will be exactly the value you put in the Light Intensity. I chose 60 inches, which is 5 feet. So I get to set the light intensity at a radius of 5 feet. 

Now look at the node Light_XYZ_Position. I know you think that's for colors, but it is also for vectors. In the Red, Green, and Blue parameters, type in the X, Y, and Z position of your light that you wrote down earlier. I'm sorry I can't do this for you in the shader but Poser shader nodes cannot get that information.

That's all you have to do. The light is now configured to implement the correct inverse square law. For my settings, that means that anything that is 5 feet from the light will be lit exactly as before. At 10 feet, it will be only 1/4 as bright. At 20 feet, 1/16th as bright.

Also, anything closer will be brighter. At 2.5 feet (30 inches) the light will be 4 times as bright.

That's all you need to know. Remember, if you move your light, enter the XYZ position again in this shader. Otherwise, you don't have to come back in here again. You can manipulate the light intensity and colors as you've always done with any of the Poser gadgets you want.


For those of you who want to know how it works - here is the explanation.

Starting from the lower right, there is the "P" node. This node gives me the position of the surface that is currently being lit. Not the position of the light, but the position of the point in a mesh prop or figure that is being lit. This is a very cool undocumented feature. Now the position is in some wierd variation of Poser Native Units. I want Inches. So I set the multipliers up with the value .0969. This is not EXACTLY the right multiple, but the next non-zero digit is way out there and its good enough for this shader. (Not good enough for precise displacement shaders, but that's another topic.)

Now just above that is a node called BugFixUserDefined. That is actually a Color_Math node. What I'm doing there is taking the square root of the light xyz position. This is because there is a bug in the UserDefined node. The Light_XYZ_Position is actually a UserDefined node. The UD node erroneously squares any numbers you type in. Who knows why. Anyway, I correct that by square rooting the values coming out of the node, so they are restored to the correct numbers.

Now, the node Distance_To_Light (actually a Color_Math node) takes the difference between the mesh position and the light position, computing the distance in each channel correspondingly for x, y, and z. So now we have delta x (dx), delta y (dy), and delta z (dz).

The next node, R_Squared (also a Color_Math node) multiplies these with themselves, one for each channel. This is actually R squared, which is what we need for the falloff.

Now go up and look at the Unit_Distance_V1 node. That node is actually a Math node. It is raising your unit distance to the 2nd power (squaring it). 

The next node Ratio (a Math node) computes the ratio of the unit distance (Unit_Distance_V1) with the distance to the light (R_Squared). Voila! That is the falloff light intensity ratio. That is plugged into the Light Intensity channel. This correctly modulates the light intensity over the distance you specified, completely automatically.

No modifications to mesh shaders is required at all.

I hope you enjoy this trick. I will be using it for all my indoor lighting from now on.

I have been keeping my mouth shut for days because I'm approaching my 1000'th posting at Renderosity. This post is #999 and I'm glad I held back because I just had to post on this issue. It's amazing what a difference it makes. I would post you some more renders to demo this, but I'm saving my next post (#1000) for the announcement of my Apollo Maximus skin shader. It is almost ready. After I post that, I'll come back here and show you more cool stuff. I'm also EXTREMELY busy at my real job releasing our latest version of software, largely written by me alone, so you can imagine what I'm dealing with. I've fixed over 40 bugs or enhancmenet requests in the last week.

Remember, you must put this shader on each light that you want to obey the true physical inverse square law. If you use several point or spot lights, attach it to each light, and make sure you type in the correct light position in each one. INCHES people. Remember the units are Inches.

After this, I will not be answering a single question until I finish the AM shader.

So if somebody has questions, maybe someone else can help out. I'm staying mum.

Angelouscuitry - I saw your other posts, but for reasons I just explained, I'm not going to answer just yet.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)