View Full Version : Back to Front Shader?
Posted this on XSIBase as well (http://www.xsibase.com/forum/index.php?board=12;action=display;threadid=31043), but I figured it wouldn't hurt to also try here.
I'm looking for a shader that will display on the front faces what happens on the back... sort of like a translucency shader but then for everything and not just lights. So if, say, reflection/FG rays hit the back facing polys of an object the shader would display this on the front facing polys.
Edit: I could bake it and use the front-back switch, but I'm looking to avoid baking this if possible.
Does anyone know of such a shader or method, or does anyone have any tips for creating one?
Thanks,
Rens
___________________________________
EDIT - Found one that does FG, thanks floze (http://forums.cgsociety.org/showthread.php?f=21&t=509592)! So basically the same as a translucency shader, only it passes on FG as well. Can be cool for things such as lamp hoods and curtains, to get bounced light through.
To install:
1. Go to *XSI Dir*\Application\bin\nt-x86-vc71\
2. Copy subsurface.dll from there
3. Go to *XSI Dir*\Application\phenolib\spdl\mibase\
4. Paste subsurface.dll and rename it to misss_lambert_gamma.dll
5. In XSI go to File -> Plug-In Manager... -> SPDLs -> Install
6. Browse to *XSI Dir*\Application\phenolib\spdl\mibase\ again and select misss_lambert_gamma.spdl, hit install
7. Locate the preset file mention in the install report and drop it into the render tree, or do what you normally would do; preset folder, workgroup, ...
XSI Dir is wherever XSI is installed.
flip 0 = render front faces as front faces (as most shaders do).
flip 1 = render back faces as front faces (the effect I was after).
flip 2 = render back+front faces as front faces (adds modes 0 and 1).
Here's a visual example of what it does, to make things clearer:
http://www.rensheeren.com/images/cgtalk/misss_lmb_gamma.jpg
|
|
Saturn
06-13-2007, 07:47 AM
you may try this :
ask Mental ray to render only back face.
You can specifiy it in the visilibity option of your object or in the render settings.
Hi Harry, thanks.
Unfortunately it just ignores the front facing faces and renders out the back facing faces on the other side. What I'm hoping to achieve is that it still renders the front facing faces, but they would be shaded with what is visible on the back of those same faces.
Say I have a red light casting caustics on the back of a grid and on the front is a blue light. What I'm looking for is something that will swap the faces so that on the front I will see red light and red caustics, while when I then view the back I will see blue light.
Similar to the translucency shader, but then for everything, not just light/shadow.
P.S. thanks for those sRGB nodes, they're really useful.
CiaranM
06-13-2007, 10:37 PM
That sounds like something that you might have to do in post. i.e. render out a seperate pass for each light & caustics and composite together with colour adjustments.
Anyone know how to output seperate buffers for the contribution of each light in a scene?
That sounds like something that you might have to do in post. i.e. render out a seperate pass for each light & caustics and composite together with colour adjustments.
Thank you, but that won't do the trick I'm afraid.
I've attached a picture... it's pretty hard to explain.
A flip normals / swap face sides shader. Rays hitting the front call up the back and vice versa.
Anyone know how to output seperate buffers for the contribution of each light in a scene?
You could leave everything as it is, but create a different pass for each light where only that light is on. Then add all passes together in post, passA+pB+pC...
I found a shader that passes on FG. I updated the first post with the details.
not sure if this will satisfy your needs but
try this
Vector State node (set to Normal Vector) -> Vector-vector math Node (set to negate) -> Bump slot of your material
this will invert normals in render so the front will behave as back and therefore it will receive everything from other side and vice versa
You sir, are an awesomist. And don't let anyone tell you otherwise!
Yes, very nice and so simple, I was looking for a way to flip the normal vector but never thought of using the bump port. It works with FG, regular lights, hell I even got a setup where it did both front and back path tracing scattering at the same time.
Still have to test GI.
I can't get both front and back FG (like mode 2 in the shader above) to work with this... it requires two shaders and this only works when plugged in the material bump port, doesn't seem to work when plugged into a standard shader's bump port. Well I can always use two misss_lambert_gamma shaders with a mix2 if that's required.
Thank you.
NunoNisa
06-24-2007, 12:14 PM
"I can't get both front and back FG (like mode 2 in the shader above) to work with this... it requires two shaders and this only works when plugged in the material bump port, doesn't seem to work when plugged into a standard shader's bump port. Well I can always use two misss_lambert_gamma shaders with a mix2 if that's required."
You could get around it by along Anim's solution use a fornt/back (get»switch»front/back) node pluged in to the difuse and/or ambient slot. Then you can plug an ilumination node or whatever to both front and back slots of the front/back node. It lets you control the front and back faces without using the bump slot...
You could get around it by along Anim's solution use a fornt/back (get»switch»front/back) node pluged in to the difuse and/or ambient slot. Then you can plug an ilumination node or whatever to both front and back slots of the front/back node. It lets you control the front and back faces without using the bump slot...
Thanks, but the front-back switch just defines what is visible if a ray hits the front or the back. What I was looking for here was a shader that would pass on the shading from the front to the back and vice versa. Front-back can't do that.
Here below is an image to show why having such a shader working with FG is so awesome. The light hits the back of the lamp shade, then gets passed on to the front, where it illuminates the back wall. No working lights, just a sphere with a constant shader as a light source, one pass, no textures.
Using regular shaders you wouldn't get the light on the back wall and the lamp shade would be black on the outside. Come to think of it the new mia_material might be able to do this with FG as well.
Using misss_lambert_gamma on the lamp shade, flip 2:
http://www.rensheeren.com/images/cgtalk/fg_translucency.jpg
I like Anim's solution because it's so simple, though for now it seems that you can only use it on things where the back side of the object isn't visible, like a closed lamp shade for instance, or a paper wall, though the back side won't bounce light.
Quote from another thread (http://forums.cgsociety.org/showthread.php?f=21&t=509592) (which I blatantly hijacked for my own pleasure). :)
I checked the link, and the other thread. Intresting research... But...
as U just said it's basically the samething as a translucency shader "in this case"...
I was wondering in what way it would be different from translucency?? will it help in facking SSS?? as far as I can see, it can't take into account the thickness of the object...
Still.. very Intresting... just woundering about the possibilities??
With "in this case" I was talking about that particular picture (http://www.rensheeren.com/images/cgtalk/misss_lmb_gamma.jpg), which just shows standard diffuse lighting and would be no different from a regular translucency shader.
However a regular translucency shader won't work with final gathering. Having a shader setup mentioned in the posts above will pass on FG, making it useful to create SSS effects and things like curtains and paper. Take a look at the lamp picture above as an example.
Importantly it will also pass on indirect lighting, not only direct, adding to the realism.
You could also place a bright object next to a solid box/cube and then the light would go through the box, bounce around inside and come out the other side and illuminate the floor or wall there.
Unfortunately, with both normal reversal through bump and with misss_lambert_gamma theFG sampling just gets messed up totally when using two sides at the same time and I haven't found a way around it yet. It just looks bad unfortunately. :/
CiaranM
06-26-2007, 01:25 AM
Well, how about duplicating the lamp shade without the reversed normals and make it the object that is sampled for FG rays etc, but not primary eye rays. You can set this in te visibility options.
jankin
06-26-2007, 11:50 AM
Well, I don't think this is possible with standard shaders. The FG precomputation takes place only there, where something can be seen by the eye ray (primary and secondary). If you want extended functionality of finalgathering you could use the mi_finalgather_store function in your custom shader. Here is an excerpt from the mentalray maual:
This function is useful for setting finalgather points in places where they would not normally be seen by preprocessing, such as the back sides of objects. This is especially useful for lightmap shaders because light maps that compute irradiances would otherwise look better on parts of the object seen by the camera. For example, the light map shader might use mi_finalgather_store in compute mode to place finalgather points on vertices, for later lookup in output mode.
Well, how about duplicating the lamp shade without the reversed normals and make it the object that is sampled for FG rays etc, but not primary eye rays. You can set this in te visibility options.
Interesting, but if I make a duplicate object how would I get the FG rays to pass from the back to the front? Also if I disable primary rays it will only render out the reversed model.
Well, I don't think this is possible with standard shaders. The FG precomputation takes place only there, where something can be seen by the eye ray (primary and secondary). If you want extended functionality of finalgathering you could use the mi_finalgather_store function in your custom shader. Here is an excerpt from the mentalray maual:
Nice! Yes I need to dig into shader writing some more, this is all pushing the limits of out of the box shaders to areas you really don't want to find yourself in. Like riding your bicycle on a highway. :)
Though it seems mi_compute_irradiance_backside would be more applicable in this case as mi_finalgather_store seems to need defining of where to place the FG sample points.
CGTalk Moderation
06-26-2007, 03:34 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.