PDA

View Full Version : How to assign different properties to each side of a single, doublesided polygon...



Celshader
07-21-2006, 09:13 PM
If it helps anyone else here...here's how to do away with "air polys" and still give each side of a doublesided surface a different index of refraction...

-+-
-+-

From http://www.newtek.com/forums/showpost.php?p=414401&postcount=2

... In the node graph shown in the image below, the FG Color of the Mixer is overlaid on top of the BG Color of the Mixer. So, the green FG Color completely wipes out the red BG Color underneath as long as the Opacity is 100%. If the Opacity is 0%, the green fades out completely, and only the red shines through.

The Polygon Side output of the Spot Node marks the frontside of each doublesided polygon as white/100%/1.0, and the backside of each polygon as black/0%/0.0. I plug this Polygon Side output into the Opacity input, overwriting the internal Opacity of the Mixer node. Now the Opacity of the green FG color will be 100% opaque on the frontside of each polygon, and 0% opaque on the backside of each polygon. This is why the frontside of these double-sided polygons are green and their backsides are red.

This is good for applying different color textures/imagemaps to each side of a double-sided polygon. Plug one color texture/imagemap into the BG Color, and another into the FG Color, and you'll have a double-sided surface with different textures on each side.

-+-

For different Luminosity/Diffuse/Specular/(anything with a "green" input)/Translucency settings on each side of the polygon, consider using the Logic Node (Add Node->Math->Scalar->Logic) instead of the Mixer. Plug the Polygon Side output of the Spot Info into the Logic node's "A" input. Set B to 1.0, and the Operation to "A Equal To B." With this setup, the frontside of the polygon (1.0 in Polygon Side terms) will equal B (which is also 1.0), and the Logic node will use the number in the "If True" setting. The backside, which is 0.0 in Polygon Side terms, will not equal B (which is 1.0), and the Logic node will use the number in the "If False" setting.

With the setup shown in the second node graph, the frontside of each doublesided polygon has an Index of Refraction of 1.3. The backside of each doublesided polygon has an Index of Refraction of 1.0.

THREEL
07-21-2006, 09:43 PM
If it helps anyone else here...here's how to do away with "air polys" and still give each side of a doublesided surface a different index of refraction...

You go girl!:thumbsup: Actually, this topic came up in one of the threads just a short while back. Some questions, though. Did you do this in LW v9.0? If so, can this be done in v8.5? Is it possible to have 2 completely different images, and/or procedual textures, one on each side of a double-sided surface? If it does, it would be a tremendous help when doing calcs for ClothFX.

Thanks for the info!:) THREEL (AL)

jameswillmott
07-21-2006, 11:06 PM
Yes, you can have two different images on each side of a polygon.

Celshader
07-21-2006, 11:15 PM
You go girl!:thumbsup: Actually, this topic came up in one of the threads just a short while back. Some questions, though. Did you do this in LW v9.0? If so, can this be done in v8.5? Is it possible to have 2 completely different images, and/or procedual textures, one on each side of a double-sided surface? If it does, it would be a tremendous help when doing calcs for ClothFX.

Thanks for the info!:) THREEL (AL)

Yes, I did this in LW9.0.

I do not how to do this exact same thing in LW8.5. I know how to texture (http://www.newtek.com/forums/showpost.php?p=295161&postcount=33) either side of a double-sided polygon that lies flat in the XZ plane in 8.5, but it's nowhere near the level of control offered by the Node Editor in LW9.0. It might be possible with the TB Shader Tree, though, judging by this post (http://www.newtek.com/forums/showpost.php?p=295169&postcount=34).

Yes, you can have two completely different images/procedurals on either side of a double-sided surface. Plug the Color outputs of an Image or Procedural node into the color inputs of the Mixer node. Whatever you plug into the Mixer node's BG Color and FG Color will replace the Mixer's internal BG Color and FG Color, just like the way the Spot Info's "Polygon Side" overrides the Mixer's internal Opacity when plugged into the Opacity input. Check out this double-sided ClothFX skirt. Each side has a different color:

Lor
07-22-2006, 10:05 AM
Whoa.....

I haven't really dug in to the node editor yet, but I'm starting to see that it has major power. Applying logic to material values is major!...well, to me anyway.... ;)

lor:lwicon:

Celshader
07-22-2006, 10:23 AM
Applying logic to material values is major!

Yup! ...and I heard the Logic node works faster than the Gradient node for this specific task of assigning different values to each Polygon Side.

:boogiedow

Bog
07-22-2006, 10:58 AM
Oh, wow! That could totally change the way I do the surfacing for book pages in the British Library stuff I do - I've always used two planes very close (from 1mm to 0.1mm) togehter

Being able to do away with that fiddly, picky cause-of-many-math-error-and-interpenetration way of doing things would make my life a *LOT* easier!

Cheers, Jen!

Sekhar
07-22-2006, 02:31 PM
Good idea/tip, thanks for sharing!

THREEL
07-23-2006, 10:28 AM
I do not how to do this exact same thing in LW8.5. I know how to texture either side of a double-sided polygon that lies flat in the XZ plane in 8.5, but it's nowhere near the level of control offered by the Node Editor in LW9.0. It might be possible with the TB Shader Tree, though, judging by this post.

A local LW friend showed me how to keep a texture where you want it by making a flat-straight plane, copying it to another layer, munipulating the copy, and then running a Bkg to Morph on it. Then you bring it into Layout and run Morphmixer on it. The texture retained its placement, even on the curves. He did this with an animated displacement map for a river. It was pretty cool. Hopefully, this will work for the different surfaced, double-sided polys as well.

Boy, I've been doing LW for a while, but in some areas I still feel like a newbie. It's great to see true LW professioinals share their expertise. You don't see that type of friendship in some professions.

Thanks!::D THREEL (AL)

Earl
07-23-2006, 06:14 PM
This is great Jen! Thanks for taking the time to show this. I don't know, though. These forums are great, but I can see these great tips n tricks threads getting lost. Maybe we should have a master list of all these gems...

Celshader
07-24-2006, 12:08 AM
This is great Jen! Thanks for taking the time to show this. I don't know, though. These forums are great, but I can see these great tips n tricks threads getting lost. Maybe we should have a master list of all these gems...

For what it's worth, BeeVee asked me to add a page to the LightWiki (http://www.lightwiki.com) on this subject, just so others could find it without having to search for it on a forum. It's my first time using Wiki-stuff, but the info is now mirrored on this page:
http://www.lightwiki.com/wiki/mediawiki-1.4.4/index.php?title=How_to_assign_different_properties _to_each_side_of_a_doublesided_surface

Also, there's a chance that Proton might (http://spinquad.com/forums/showpost.php?p=141846&postcount=8) turn this into a video, further spreading this information. :boogiedow

Doug_M
07-24-2006, 08:02 PM
Thanks, Jen.

But I have a question, how does this affect the Omega shader, which was the question of the original thread. I didnt see any impact myself when using this technique with omega.

Dave Jerrard
07-25-2006, 07:55 PM
Omega actually does a form of refraction, so the same rules apply to it that apply to regular refraction, the big one being that light is only refracted when it passes from one material to another of a different IOR.

Without an inner air surface, objects that have thin parts, like a glass, will render as though they're much thicker. In the case of Omega, shading can be much darker than it should be. Here's some examples using the same object I used on another Omega thread found here (http://www.newtek.com/forums/showthread.php?p=404227#post404227).

Here's some renders of that teapot, using only the Omega shader. They all have the same settings (PLD 7 pass, Samples set to 1x3 for Omega, Penetration set to 20mm, single scattering, 100% Spread). The color in Omega is set to a light grey and the only other settings applied to the surface are a incidence angle gradient for reflections, and the use of the Polygon Side output mentined above, applied to the Reflection, Transparency and Refraction Index channels, which I'll call air polygons from this point on (since that's what this is doing).

The first couple images here do not use Omega's ray tracing. It renders faster, but it's not as accurate. You can call this Omega's fake mode. :hey:


http://davejerrard.postresource.com/Pics/Teapot-SSNR-185s.png

This image took 185 seconds, and uses no ray tracing. Penetration was 20mm, meaning light will not be traced very far through the surface. If the rays hit another surface in this distance, then the surface will be considered thinner (unless it's the same surface). It has air polygons, so there's a defined thickness for the entire object. You can clearly see light shining through the spout and the top opening is glowing through the shadowed sides, and the shadow of the lid is visible on the inside surface of the pot.



http://davejerrard.postresource.com/Pics/Teapot-SSNR-SS-168s.png

This image took 168 seconds to render (the first image used to take this long too but I did something wrong when I deleted some unnecessary nodes that were used for more realistic surface), but this time it was only single sided - no air polygons. It's much darker, because the shader isn't seeing any terminating surfaces, so it thinks the teapot is thicker than it really is. So rays entering at the front are treated as though they're going deeper into the surface than they should, and the surface appears dark. If this was just using refraction, the teapot would appear to be a solid mass of glass.


These next two images use Omega's Full Raytracing option. Remember, I have Penetration set to 20mm here, so even parts of the model that are thinner than this will have a very low transparency. Yes, Omega CAN render an object like it's transparent.


http://davejerrard.postresource.com/Pics/Teapot-SSFR-1126s.png

This one bumped the render time to 1126 seconds (gotta love refraction, huh?). Samples are set at 1x3, just like the previous images, so each ray that hits the surface splits into three. So basically, I'm ray tracing three times more rays than normal refractions would be doing. Light scattering through the rim is more accurate here. If I changed to Multiple Scattering, light would start to spread around the edges more, making the object appear to glow a bit, the higher I set the recursions for this. This image only has Single Scattering though, as do the rest, unless indicated otherwise.


http://davejerrard.postresource.com/Pics/Teapot-SSFR-SS-1567s.png

Rendertime:1567 seconds. It's the same as above, but single sided again - no air polygons. It took a bit longer once more, about 400 seconds longer. This is either because I have something wrong in the surface that I'm missing, or because the rays are tracing out further into the scene because of the lack of terminating surfaces (most likely both). It's a bit lighter in the light areas, but otherwise pretty similar, at this level of penetration...

Increasing the recursions in the shader (different from Ray Recursions, this controls how often the light bounces inside the surface) will lighten the shading, increasing the amount of glowiness in the surface. It really softens the self shadowing transitions.


http://davejerrard.postresource.com/Pics/Teapot-MS3-NR-256s.png

This took 256 seconds and is the same as the first image, but has Multiple Scattering with 3 recursions as the only difference. There's no ray tracing going on in the shader here.


http://davejerrard.postresource.com/Pics/Teapot-MS3-NR-SS-290s.png

This image is identical to the second image - no air polygons - but used Multiple Scattering with 3 recursions, and took 290 seconds. Higher recursions will brighten it up even more. Without air polygons, the surface is considered thicker again, and the added thickness combined with more interna recursions makes the surface brighter. Kinda like mixing milk with water, it won't appear as white in a glass as it will in a larger container.

Since I'm reaching the limit on the number of images a single post can contain, I'll have to break this into two parts.


He Who Hates Being To Be Continued....

Dave Jerrard
07-25-2006, 07:56 PM
Increasing the Penetration value will make the surface more transparent. In these next two images, I used the same settings as the 3rd & 4th images in the previous post - they're using ray tracing - but I increased the Penetration to 5 meters. This will reduce the amount of 'murkiness' in the surface, making it more transparent and glass-like.


http://davejerrard.postresource.com/Pics/Teapot-SSFR-5m-1015s.png

This render took 1015 seconds and is doublesided, while the image below took 1382 seconds and is single-sided again.


http://davejerrard.postresource.com/Pics/Teapot-SSFR-5m-SS-1382s.png

They look pretty much the same since they have a large amount of scattering going on, but they do have a more glassy look to them. If I was to lower the Spread value to 10%, you get the following at a render time of 1092 seconds:


http://davejerrard.postresource.com/Pics/Teapot-SSFR-5m-10S-1092s.png

You can just make out the checkerboard pattern and the lid through the back side of the pot.

The Spread value indirectly controls how transparent the surface appears by blurring the refraction, much like the Refraction nodescan do In this next set of images, I'm going back to the settings used in the fourth image above (Omega's ray tracing and no air polygons), and lowering the spread from 100% to 0%. Now no blurring is being done in the refraction and you can see the checkerboard and the lid through the teapot, which wasn't visible before. The teapot now looks like it's made of a smoky glass. Some light scatters backward, some forward, and some goes straight through.


http://davejerrard.postresource.com/Pics/Teapot-SSFR-SS-0S-861s.png

After 861 seconds, this is the result. As mentioned above, this is using single sided polygons, so the refraction is actually wrong on this one. The front side is rendering as though the entire pot was solid, and the rear, inner surface is rendering as though the surface extended all the way to the floor behind it - a common mistake in rendering refractions. You can actually the checkerboard is warped quite a bit through the back, looking more like a dark curved band from this angle. Since the shader thinks the object is so thick, it's rendering pretty dark again.



http://davejerrard.postresource.com/Pics/Teapot-SSFR-DS-0S-1113s.png

With the air polygons added again, render time is 1113 seconds. You can see the refraction is corrected now. All the surfaces are rendering as though they're thin, so they're not being shaded so darkly and they're not distorting everything seen through them so much.


http://davejerrard.postresource.com/Pics/Teapot-SSNR-DS-0S-177s.png

This is the same as the last render above, but this time with ray tracing turned off. The shading is about the same, but you can no longer see through the surfaces. This also brings the render time down to 177 seconds again.

These are just some of the results possible with only about half of Omega's features. It can be made to render very glass-like surfaces (http://www.newtek.com/forums/showthread.php?t=51491&highlight=omega), fleshy (http://www.newtek.com/forums/showthread.php?t=51964) ones (http://www.newtek.com/forums/attachment.php?attachmentid=34801&d=1153475210), or what I was after with this, subtle translucent porcelain (http://www.newtek.com/forums/showpost.php?p=404219&postcount=7).

He Who Has Now Finished Being Continued.

erikals
07-25-2006, 07:58 PM
Cool !!
Didn't even know that was possible.
Thanks Jen, I definetly will be using this technique :)
(edit: and thanks Dave :))

Dave Jerrard
07-26-2006, 03:09 AM
Here's the node map for that teapot.


He Who Knows He Who Requested It Knows Who He Is. Ow. :confused:

Elowan
09-09-2006, 07:03 PM
Gadzooks!

Rusherific
02-16-2007, 03:11 PM
I'm still fuzzy with this "Air Poly" concept in the first place. This post helps, but lets say you ahve a simple sphere, that is supposed to be hollow, wiht double sided polys and a refracting glass shader. You are supposed to have an air sphere inside it to keep the sphere from looking like a solid chunk of glass right? What if the sphere had a small thickness already, not just one layer of double sided polies--would you still need an air sphere inside? This seems like something newtek really needs to fix, htat it should assume a 1.0 iof (at least, if not settable) once a ray passes a poly in the same direction of that poly's normal.

TSpyrison
03-23-2007, 01:55 PM
Dave, were your posts supposed to have images in them?

Celshader
03-23-2007, 02:11 PM
Dave, were your posts supposed to have images in them?

Looks like the images are gone. They're mirrored here, though:
http://lightwiki.com/wiki/mediawiki-1.4.4/index.php?title=Subsurface_scattering_in_LightWave _v9

Dave Jerrard
03-23-2007, 02:24 PM
Dave, were your posts supposed to have images in them?
Grrr. The host that I was using for them is no more.


He Who Is Going To Have To Find A New Host Now.