The Amazing Light Sensitivity Shader

From Realsoft3D Wiki


Contents

LIGHTSENSITIVITY SHADER

Garry Curtis, January 31 2006, A tutorial for Realsoft3D V5

With Thanks to Boris Jahn for revealing this awesome shader to the Realsoft Mailing List in answer to a question from Arjo about modifying the amount of light on certain objects . Visit Boris's site at http://www.3ddart.com Boris's Personal Web Site .

Skill Level Suggested : Beginner

Introduction

Another tutorial in the "Saved From The Abyss" Series , which are tutorials concerning little known but very useful information that appeared on the Realsoft3D Mailing List . This tutorial is actually a perfect example of working with Realsoft3D in general . That is to say , this very simple shader can easily be added to any scene with very dramatic results , and new shaders can be created quickly , once the new user has an understanding of how certain things work within Realsoft3D . Without those insights the power and potential of RS goes mostly , untapped .

Just a quick recap before we begin ... Arjo Rozendaal had approached the Realsoft mailing list one night asking about how he could "link a light source to a single object?" That is , he had several light sources , and various objects , but just wanted to link certain objects to one particular light source . Boris responded with the answer of using the Realsoft3d light sensitivity shader.

Let's Get Started

OK , let's get started on this very simple method of linking certain objects to a particular light source . First , download the project file that is complete and ready to go . Once you have looked at it a bit and rendered it , and maybe adjusted the settings a bit , we can go over how it was built so that you can add it to any project you may need to in the future . http://www.studiodynamics.net/saved/ls-1.zip Tutorial Project


2004-02-04-render.jpg

Just hit the render button !


Above we see what you will get if you hit the render button on the above linked project , and as we can see , every single SDS sphere is being affected differently by the single light source and that is because we have added the light sensitivity shader to that light source and then adjusted the amount of light sensitivity for each and every object , except the globe on the far left which was left at the default setting of '0.000' , or not affected at all by the light source .


How does it work ? Very simply , actually , and that's the beauty of it . Rather than try to explain it , why don't we just build the scene and actually do the explanation as we go along . This is well worth the trouble , as we will eventually delve into creating our own custom channel in order to modify the lighting of these SDS sphere's in a new and different way too .

Let's Build it .

Fire up Realsoft3D version 5.x and build any kind of simple scene you like . I'll assume you know how to add a simple SDS sphere to the scene . Copy or create new globes or cubes or teapots or whatever . Add a simple Rectangle floor . Now , add a simple point light by clicking on the "Point" icon on the "Light Sources" Tab at top.


2004-02-04-point.jpg

Add a Point Light


Also , make sure you have your camera's built in light , the 'Flashlight' turned off . Do this by right clicking anywhere in the View port Window and selecting "View Properties" from the resulting Pull down Menu . Then select the "Camera" Tab and click on the Color Box beside the "Flashlight" control and change it from the default .5,.5,.5 to 0,0,0 . This way we can really see what is going on with our lights without having the camera's light modifying our results in any way .


2006-02-04-flashlight.jpg

Make the Flashlight's Color 0,0,0 (black)

Render this simple scene and then try to find a nice view of your scene , one that will show the globes lighted side , and the floor and the cast shadows too . We will use "Raytraced Shadows" in this example as it will help us to stay grounded as we modify the lighting in all kinds of ways and manners . Double click on your point light in the Geometric Objects Tab and it's Property Window will pop up . Select the "Spec" Tab and adjust the lights intensity here , and also make sure that Shadow Casting is turned on .


2006-02-04-liteprop.jpg

The Light Properties Control Window

Almost Ready


When you're happy with your lighting and happy with the angle you're using to view your simple scene then it's time to create a camera so that you will have a place to come back to once we start rendering and experimenting with the light sensitivity shader , and the new shader that we will be creating . Just click on the "Camera" icon in the "Creation" Tab and then click "Accept" , like you did for the Light Creation .


2006-02-04-camera.jpg

Creating a Camera

Time to Add the Shader

First , select your Point Light in the Geometric's Object Tab in your Select Window ,then switch to the "Materials" Tab in the Select Window and Right Click and choose "New From Template" from the resulting Pull down Menu . Browse your way to the Materials Folder in your Realsoft3D directory , and then go into the "Misc" directory and grab the light sensitivity.r3d shader . Just drag and drop this shader into the View port Window and it will automatically be added to your Point Light (this is the reason for selecting the Point Light before we went into the Materials Tab) .

Render your scene and we see ... nothing! Why ? Because the Light Sensitivity shader defaults to 0.00 , or zero light affecting objects . To modify the amount of light that is affecting the objects in this simple scene (via the Point Light) , double click your objects to get the object's Property Window to appear , then click on the "COL" Tab and you will see a "Surface Properties" and "Attribute" control that is currently set to adjust "Color" . Click on the arrow tab at right and a Pull down Menu will appear with a list of many Surface Properties ready to be customized . For right now , the only one we're interested in is the "Light Sensitivity" property , so select that one .


2006-02-04-pulldown.jpg

Select Light Sensitivity From the Pull down Menu

As stated earlier , we see that the default setting is 0.00 (zero effect) so select the slider directly below and move it to 1.00 and re-render . Ahhh , lo and behold we see the light , literally . What you have just done is add the normal default amount of light to that particular object from that particular light . Now , just for fun , type the number 3.00 directly into the numerical box to the left of the slider and render again . Note that the other objects in your scene are still not receiving any light at all , but now this object is receiving 3 times the default amount of light !

Do the same with all your teapot and cow objects , but vary all of them a bit too , from 0.00 to 2.00 or 3.00 etc. , just so that we'll have a good example of what this shader is capable of doing for us . Save this file as an ultimate kind of "undo" . In case we make mistakes along the way we can always come back to this saved file . In fact , as you probably know , saving often under slightly different project names is a great way to backtrack your journey .

Let's Take it One Step Further ...

This shader as is is OK for simple scenes with just one light that is giving us trouble with certain objects , but if we were to add this same shader to multiple lights it would not work very well . However , we can venture out and perhaps build a new shader that does the exact same thing and then add that new shader to another light source that we want to control more accurately for certain other objects .

To do this is actually very easy . Easy , that is , once you know how , and that brings us back to our original supposition , that Realsoft3D is a tool that has much power and can be easily tapped , but only once you know how to do so . The Realsoft methodology may be slightly different than what you might be used to , and may seem hard to comprehend sometimes , but the fact is that the way "there" is pretty straight forward ... OK , yes ... once you know the way .

The Power of Channels

The true power of channels will not be observed in this simple example tutorial , but perhaps once you've broken the ice with channels you may not be so hesitant to approach this area of Realsoft3D in the future . For now , let's select the "Channels" Tab in your Select Window and once there right click and select New/Float Channel , then select that new Channel and rename it to "lightmod2" . There is a small bug with renaming , but I know you'll find a way to do it .

2006-02-04-lightmod.jpg

Create a Brand New Channel

What does that do ? Well , if we go back to "Surface Properties" and the "Attribute" control (back on the "Col" Tab) for any one of your objects and once again click on the arrow tab at right we will notice that in the Pull down Menu of Surface Properties , we now see our newly created channel , named lightmod2 (or whatever you chose to call it).


We can see the new channel but it's not as of yet been configured to do anything for us , and so that step is next ... Go back to your Materials Tab and select the light sensitivity shader and right click and select "Duplicate" from the pull down menu . This duplicate material will be our new lightmod2 channel trigger . To complete the duplication process we must walk bravely into the land of VSL .

Am I Man Enough For VSL ?

VSL is not for everyone but for simple things it can be easily handled . Once again we have to pause and wonder what kind of power lies within this interface . Answer : TONS !!! . We'll leave that topic for another time or for you to explore on your own . For now let's just complete some simple tasks in here and then test our work with the last part of this tutorial .

Double click on your new duplicate copy of the "LS" shader and change the name to triggermod2 , or such . Then click the "Advanced" control to show the advanced shader attributes . You will see a contracted box named "Light Properties" so click that to expand it and then select the line of VSL code that is visible now called illumination*=Copy(light sensitivity) and we'll notice a new interface at the bottom of this window , with 3 new Tabs , "Copy" , "General" and "In/Out" .

Almost There

Almost there . The In/Out Tab is the one we want , so select it , and we notice now there are 2 controls below named "Source" and "Destination" . Hmmm , seems logical so far . If we select "Destination" we see that on the right side it points to LIGHT : iLLUMINATION as in the illumination of our SDS Teapot and Cow objects . Sounds about right so we'll leave that alone , but when we select the "Source" control we see that it points to TARGET : LIGHT SENSITIVITY , which makes sense too , except we don't want an exact duplicate of the "LS" shader but want to modify it so that it triggers our new channel , lightmod2 , so change this now so that Source is TARGET : lightmod2 (our newly created channel) .


2006-02-04-trigger2.jpg

This is How We Trigger Our New Channel


That's about it really . All that's left is to create a new light source , then render to see what it looks like unmodified , then add this new VSL shader "lightmod2" to that new light source , and modify some of the SDS objects by selecting "lightmod2" in each objects "Surface Properties" control , as we did originally with the "LS" shader , and re-render to see the new results . We can create as many new light modifying shaders as we think we might need for as complex a scene as we can imagine .

How Useful is it ?

It may not seem very useful at first , but advanced Global illumination experts will tell you that the key to realism is in the exact placement of "invisible" lights in order to 'fake' the radiosity effect that software programers are trying desperately to code into apps like Realsoft3D . In reality we can't expect a software to do it all on it's own and so gentle light placement is an advanced tool we can use , and the ability to tweak that light for certain objects lies here in the use of channels and shaders like the Realsoft3D light sensitivity shader .