Planetside Software Forums

General => Terragen Discussion => Topic started by: gregsandor on May 11, 2010, 12:32:47 PM

Title: Retroreflective shader
Post by: gregsandor on May 11, 2010, 12:32:47 PM
Has anyone figured out how to make a retroreflective shader in TG?  I have a set of highway signs and want to give the surface that extra kick.

A retroreflective surface reflects light back to the source instead of off at an angle away; like roadsigns, safety vests, etc.
Title: Re: Retroreflective shader
Post by: jritchie777 on May 11, 2010, 06:23:29 PM
You can fake it using luminosity on the default shader.  Match the color of the luminosity to that of your main light, or different if you want yellow to come back from reflective warning signs you just choose a deep yellow as your luminosity.  This also allows you to apply a function to it or an image.

JR
Title: Re: Retroreflective shader
Post by: gregsandor on May 15, 2010, 07:23:08 AM
I appreciate that suggestion, but I'm looking for true retroreflectivity.

Does anyone know how to return the light rays hitting a surface back to the light source rather than off at the normal angle?
Title: Re: Retroreflective shader
Post by: jritchie777 on May 15, 2010, 02:22:45 PM
I can do it in another program DAZ 3D, but not in Terragen.
Good luck with that....
Title: Re: Retroreflective shader
Post by: gregsandor on May 15, 2010, 03:38:09 PM
Can you explain how you do it in Daz or Poser?  Maybe I can convert using the principles. 
Title: Re: Retroreflective shader
Post by: Goms on May 15, 2010, 03:46:31 PM
can you "draw" what you are thinking of?
i can't imagine a situation where you need this type of reflection.... ;)
Title: Re: Retroreflective shader
Post by: gregsandor on May 15, 2010, 04:22:14 PM
Quote from: Goms on May 15, 2010, 03:46:31 PM
can you "draw" what you are thinking of?
i can't imagine a situation where you need this type of reflection.... ;)

Read my first post in this thread.
Title: Re: Retroreflective shader
Post by: Goms on May 15, 2010, 05:23:57 PM
hah, good point.
what about this?

Title: Re: Retroreflective shader
Post by: gregsandor on May 15, 2010, 06:16:27 PM
How did you do that?

Here is some more information and examples:

http://www.3m.com/intl/ca/english/centres/safety/personal_safety/retroreflection.html

http://en.wikipedia.org/wiki/Retroreflector
Title: Re: Retroreflective shader
Post by: Goms on May 16, 2010, 01:30:55 PM
i used two objects; one Tetrahedron with one side as hole, and one triangle that won't cast any shadows and put a light inside. ;)
take a look at the file attached.
Title: Re: Retroreflective shader
Post by: gregsandor on May 16, 2010, 01:39:57 PM
Thank you Goms, but I don't see how that solves it.  What I am looking for is a surface that reflects light (or spec only, doesn't have to be true reflection) back at the source instead of off at an angle.
Title: Re: Retroreflective shader
Post by: Goms on May 16, 2010, 02:15:03 PM
i think this is the best you will get. you can try to use functions to create a surface that is made from 90° angles...
but this is tricky
Title: Re: Retroreflective shader
Post by: gregsandor on May 16, 2010, 02:23:49 PM
How do you mean?
Title: Re: Retroreflective shader
Post by: Tangled-Universe on May 16, 2010, 02:28:11 PM
Hi Greg,

This is a topic about a fresnel function:

http://forums.planetside.co.uk/index.php?topic=8432.0 (http://forums.planetside.co.uk/index.php?topic=8432.0)

You might try to adjust this function with a boolean operator to get reflections independent of a polygon's/triangle's angle to the camera.
So you could try to let the function generate a value of 1 for every angle. Then apply this function to a shader which is restricted to your object/texture of interest.

Martin
Title: Re: Retroreflective shader
Post by: dandelO on May 16, 2010, 02:31:28 PM
If I had any valid input, Greg, I'd have done it already.

Anyhow, I've tried this myself, along with some other reflection techniques that I can't remember the correct term for(it involves kind of pearlescent reflections, produced by 2 opposing lattices of the surface, both reflect back different parts of the spectrum, making a kind of holographic/pearly effect, what's it called? ...)

For your idea, I'd say(if I thought it was possible) to try and create a transparent surface with lots of tiny displacements to use as box reflectors over the surface. You'd need to make them each 45 degrees and displaced negatively from the surface you're reflecting but small enough to still appear as a flat surface from a distance. But... Given that the transparent surface would optimize your reflections(making them no longer accurate) and that the box reflection displacements would be render-detail dependant, I'm sure it isn't any type of workable solution.
Not an ideal idea, eh? That's why I haven't posted. I've no sensible input that could be applied.
Title: Re: Retroreflective shader
Post by: dandelO on May 16, 2010, 02:32:13 PM
Quote from: Goms on May 16, 2010, 02:15:03 PM
i think this is the best you will get. you can try to use functions to create a surface that is made from 90° angles...
but this is tricky

Yes, I meant that, too.
Title: Re: Retroreflective shader
Post by: dandelO on May 16, 2010, 07:24:08 PM
I've found it impossible. Making tiny 45 degree displacements(90 degree sawtooth pattern) across the surface is the easy part. Applying reflections to it and bouncing light onto it requires very, very high render detail to get acceptable reflection results and I'm not sure the light is being reflected correctly at all, there's a lot of reflection noise even at high detail. I've been playing with this for a few hours now and can't make it work with any simple approach.

Maybe some real function wizardry could be made to take the angle of incidence of the light caster against the surface that could revert it back along the same angle and path it came from. I have no idea, sorry. ???
Title: Re: Retroreflective shader
Post by: gregsandor on May 16, 2010, 07:29:23 PM
Quote from: dandelO on May 16, 2010, 07:24:08 PM
I've found it impossible. Making tiny 45 degree displacements(90 degree sawtooth pattern) across the surface is the easy part. Applying reflections to it and bouncing light onto it requires very, very high render detail to get acceptable reflection results, there's a lot of noise. I've been playing with this for a few hours now and can't make it work with my hack and slash approach.

Maybe some real function wizardry could be made to take the angle of incidence of the light caster against the surface that could revert it back along the same angle and path it came from. I have no idea, sorry. ???

Yeah, same here.  I think the solution will employ functions to get the light source direction, and re-rerouting it so that instead of bouncing off at the equal angle, it is returned to the same.

There's a renderman shader at http://www.renderman.org/RMR/Shaders/SHWShaders/SHW_velvet.sl

Maybe the math inside can give some guidance.

/* Renamed to SHW_velvet.sl -- tal AT renderman DOT org */

/*
* velvet.sl -- velvet
*
* DESCRIPTION:
*   An attempt at a velvet surface.
*   This phenomenological model contains three compnents:
*   - A retroreflective lobe (back toward the light source)
*   - Scattering near the horizon, regardless of incident direction
*   - A diffuse color
*
* PARAMETERS:
*   Ks:   controls retroreflective lobe
*   Kd:   scales diffuse color
*   Ka:   ambient component (affects diffuse color only)
*   sheen:   color of retroreflective lobe and horizon scattering
*   roughness: shininess of fabric (controls retroreflection only)
*
* ANTIALIASING: should antialias itself fairly well
*
* AUTHOR: written by Stephen H. Westin, Ford Motor Company
*
* HISTORY:
*    2001.02.01   westin AT graphics DOT cornell DOT edu
*         Fixed retroreflection lobe (sign error); added
*         "backscatter" parameter to control it; added
*         "edginess" parameter to control horizon scatter;
*         defined SQR()
*
* prev modified  28 January 1997 S. H. Westin
*/

#define SQR(A) ((A)*(A))

surface
SHW_velvet (float Ka = 0.05,
             Kd = 0.1,
             Ks = 0.1;
       float backscatter = 0.1,
       edginess = 10;
       color sheen = .25;
       float roughness = .1;
 )
{
 normal Nf;                     /* Normalized normal vector */
 vector V;                      /* Normalized eye vector */
 vector H;                      /* Bisector vector for Phong/Blinn */
 vector Ln;                     /* Normalized vector to light */
 color shiny;                   /* Non-diffuse components */
 float cosine, sine;            /* Components for horizon scatter */

 Nf = faceforward (normalize(N), I);
 V = -normalize (I);

 shiny = 0;
 illuminance ( P, Nf, 1.57079632679489661923 /* Hemisphere */ ) {
   Ln = normalize ( L );
   /* Retroreflective lobe */
   cosine = max ( Ln.V, 0 );
   shiny += pow ( cosine, 1.0/roughness ) * backscatter
     * Cl * sheen;
   /* Horizon scattering */
   cosine = max ( Nf.V, 0 );
   sine = sqrt (1.0-SQR(cosine));
   shiny += pow ( sine, edginess ) * Ln.Nf * Cl * sheen;
 }

 Oi = Os;
 /* Add in diffuse color */
 Ci = Os * (Ka*ambient() + Kd*diffuse(Nf)) * Cs + shiny;

}


Title: Re: Retroreflective shader
Post by: goldfarb on May 17, 2010, 12:21:00 AM
I'd do this is something other than terragen...

but...
this /might/ work...
you could render a seperate pass with a light pointing in the same direction as your camera (and animated identically if needed)...

ideally you would want to parent the light to your camera and exclude everything but the signs from the influence of the light...


HTH
Title: Re: Retroreflective shader
Post by: PabloMack on May 17, 2010, 01:49:05 AM
Here is a reflector I did in Lightwave.  It uses physical geometry as
used in automobile reflectors.  The camera has a glowing green ball
behind it and the reflector is spinning to show how the image of the
ball is returned back to the ball (and camera).  Notice that the angle
of view is best at 90 degrees and is lost at about 60 degrees.  There
is a secondary image that races across the reflector at about 45 degrees.  
This technique will require a lot of geometry.  However, it should be
limited to the reflective surfaces of the signs so it might not be too
excessive.  You might be able to import a LWO and apply a reflective
surface to the little mirrorlets.  

http://www.technoventure.com/Terragen/Reflector.wmv
Title: Re: Retroreflective shader
Post by: Tangled-Universe on May 17, 2010, 03:55:15 AM
Did you look at my earlier post here?

http://forums.planetside.co.uk/index.php?topic=9830.msg103045#msg103045 (http://forums.planetside.co.uk/index.php?topic=9830.msg103045#msg103045)

I think this should work. It is a function which returns a value of 1 when a triangle faces the camera directly and 0 when it's 90 degrees off camera.
Modifying this function (with a boolean operator or clamp) should allow you to get "full reflectivity =1", independent of angle to camera, or to get a different buildup when using a clamp.

Cheers,
Martin 
Title: Re: Retroreflective shader
Post by: gregsandor on May 17, 2010, 07:27:37 AM
Alright guys, now we're getting some progress.  I appreciate all the ideas here.  Math functions are greek to me, so it is slow going.