Double-sided material or double-sided object

Started by FlynnAD, March 19, 2012, 09:56:40 PM

Previous topic - Next topic

FlynnAD

I've got an OBJ of a plant where the leaves are flat planes onto which I'm placing an image map of the actual leaf.

The 3d program (Onyx) I'm using to create the vegetation can specify material coordinates separately on the front-side and back-side of each leaf.

In TG2 though, how do you apply a double-sided material? There is only a single Leaf "part" in the interior OBJ network when I load the OBJ.
I tried applying a multi-shader with a different color shader to shader slots 1 and 2 of the multi-shader, but this did not work.

Using a "get geometry coordinates" or a distance/facing to camera shader won't work for what I'm trying to do as the leaves are scattered on all axes, not all planar or facing the same direction.

Solutions? Ideas?

Thanks

j meyer

Hi there,
one thing you could try is using two single sided planes instead of a double-
sided one.You have to make sure,though,that they are a wee bit apart from
each other.Lots of work and i don't know if onyx can do that.
Hth,J.

AndyWelder

Sorry, I don't have a solution just a question: What version of Onyx(Garden) you're working with? I have access to v6 of Onyx Broadleaf and that doesn't have the option to specify material coordinates separately on the front-side and back-side of each leaf, or maybe I can't find it.
"Ik rotzooi maar wat aan" Karel Appel

Kevin F

When you load the object, there's a tick box for "double sided object" on the objects properties screen.
Have you tried this?

airflamesred

Interesting one.
When you import the obj, TG treats it as one object, whether its a double sided poly or two polys so only one texture can be aplied (AFAIK). I see what the idea is. The top face of a leaf will have a greater specular/reflectivity value than the underside, and indeed the translucency may well be different. The problem with leaves/trees is you're going to double the poly count of what I imagine is a large file anyway, by using two polys. I'll look into this tomorrow

FlynnAD

#5
to AndyWelder: I'm using Onyx Grass 2.0. It lets you break the mtls into a facing and back side. The obj (or rather in this case the .onx file for max) can be loaded into 3dsmax properly and shows up with a multi-material with a sub material split into facing and rear materials. I just can't export it from either Onyx or 3dsmax into TG2 and figure out how to make it work.

to Kevin F: I do have the "double-sided object" checkbox marked. Perhaps I should ask the "I'm stupid" question first and ask, in general, how does one assign shaders to a double-sided object in TG2? I am assuming that you use a multi-shader and assign one sub-shader to the multi-shader's "shader 1" slot, another to the "shader 2" slot. That's what I'm trying and can't seem to get it to work.

What I have is a grass plant with a culm part shader and two separate leaf shaders (which should theoretically each be double-sided). The culm works fine as I'm just putting a normal color shader into it. The leaf was the object part that was specified as double-sided in Onyx when it was exported. What happens when I use a multi-shader input into either leaf part (lets call the parts leaf-B and leaf-C) is that part leaf-B is taking its color from "shader 3" slot of the multi-shader and leaf-C is taking its color from the "shader 4" slot of the multi-shader. It doesn't seem that the slots on the multi-shader for "input" or "shader 2" are being used at all. The "shader 1" slot seems to be used by the culm part, if I plug the multi-shader into that part as well. I'm now assuming "shader 2" is for some "leaf-A" part that doesn't happen to be on this particular model but was still saved as a material slot by Onyx.

Thanks for helping,
-Matt

Walli

well, as I don“t have Onyx I just can guess ;-)

But I think it does the stuff like other applications too - it simply uses a thin poly for the leaf. Now some render engines are able to assign front material to the frontside, a different material to the backside - which is which is defined by the normal of the polygon.

This would mean for TG2:
- option double sided must be active (otherwise my guess would be , that leaves seen from back simply would be invisible
- you need a shader network, mixing/merging two shaders and as mixer you need something checking for the leaf normal.

So perhaps its possible to somehow use the Visualize Normal as a mixer. Of course after piping it through some functions. Or is there a a better frontside/backside check?

But it sounds as if it could be possible.

Matt

#7
Terragen only assigns one material to each polygon. To export both materials to Terragen, you'd have to have two copies of the polygon in the OBJ with each assigned a different material, and the vertex winding (which determines what is front and what is back) would have to be reversed on the backside polygon. Then you would have to *disable* double-sided in TG, so that each copy only shows from its own correct side. Disabling double-sided can lead to polygons becoming invisible if the windings are not correct on every polygon.

Can you show me an example OBJ which has this double-sided material set up? I could support it if I know what to look for in the OBJ.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

FlynnAD

Matt,

Here's a grass clump I made in Onyx, which can create double-sided OBJs. This OBJ actually has three Parts - a Culm (base), and two separate leaf groups. The two separate leaf groups each are double-sided in the OBJ. This is shown when I imported it into 3dsmax (so I could show you as the double-sidedness doesn't show up in TG2).

Basically, I've applied green to the culm, green/yellow to the front/back sides of leaf group 1, and red and blue to the front/back sides of leaf group2.

Also shown are two simple planes; one has the material of Leaf 1 (double-sided). The other plane has Leaf 2 material (double-sided).

This could be good for tree leaves especially. For my particular grass clump situation, because Onyx can divide up leaves into multiple groups, I'm just giving them different colors and it works alright just having two colors rather than four. But for future use or other models, it would be a nice function to have if it's an easy update. Having duplicate polys, flipped, would be pretty memory intensive and not the best solution. A tree that is a 200MB OBJ would balloon up to 400MB.

If you want a real multi-material, double-sided OBJ to play with, just ask. I'll make one quickly. It just can't be this Onyx file as I can't distribute or post those.

Thanks,
-Matt

Matt

Yes, an OBJ file that I can inspect would be great. Thanks.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

TheBadger

Quote from: Matt on April 01, 2012, 03:43:00 AM
Yes, an OBJ file that I can inspect would be great. Thanks.

Matt


Please let us know what happens with this. I am following this subject with great interest, despite that its new to me and a little hard to understand.
It has been eaten.

FlynnAD

Sorry to report this, but OBJs don't support double-sided materials.

I made a dummy dbl-sided model in 3dsmax to post here. However, when I exported the OBJ and re-imported it into Max to verify it before posting it, the OBJ wasn't double-sided.

So I realized that I had exported my original, double-sided Onyx plant from Onyx in ONX format, which only 3dsmax can open, and the ONX file preserves double-sided materials. Then I had tweaked the model and re-exported it from Max as an OBJ. Upon importing it in TG2, it didn't have the double-sided material anymore, so I had thought it was a TG2 issue, not an OBJ issue. Exporting an OBJ directly from Onyx to TG2 also "loses" the double-sided quality of the model. It's an OBJ issue, not a TG2 issue.

TG2 would have to internally recognize a poly's normal faces, then apply a separate material to the non-normal side. Oh well, something for the wishlist for TG3.

Sorry for the tease.

TheBadger

Quote from: FlynnAD on April 03, 2012, 12:58:06 PM
Sorry to report this, but OBJs don't support double-sided materials.
Sorry for the tease.

Well its good to know!
I was following this thread because I am working on a macro style shot looking up from the ground. In this shot, light is supposed to be passing through the thinner part of the cap of a mushroom, causing part of the under side of the mushroom to look illuminated. Imagine god rays through a mushroom as if it were a cloud, only not as as extreme as a real god ray. Something very soft and subtle. Having a different texture sounds like the way to go.
But a mushroom is not a leaf. Maybe your problem wont affect me? What do you think?
It has been eaten.

Oshyan

That's not terribly surprising, to be honest. But I would assume FBX/Collada and other more modern formats do support it. Can anyone verify?

- Oshyan

FlynnAD

Quote from: TheBadger on April 03, 2012, 02:50:44 PM
But a mushroom is not a leaf. Maybe your problem wont affect me? What do you think?

Badger,

If you're making a macro-shot of a mushroom, then I'd assume the mushroom cap is a fully-3d modeled form, not just a planar form. If the 'shroom cap is 3d, then the double/single material argument discussed here wouldn't apply. Just model the mushroom with different material IDs within the OBJ and it'd work fine. If you're also only seeing the mushroom from underneath, rather than seeing both top and bottom simultaneously, then the double/single material argument also would not apply. If anything, the spores might be modeled as planar surfaces, and then you'd want the double-sided material discussed here. If you are seeing both the top and underside of a 3d-modeled mushroom cap simultaneously, then I'd guess you would really want an SSS shader available in another 3d software program.

My two cents. Hope it helps.

-Matt