Front material and back material assignment


#1

Dear friends,
I need your help in assigning the materials in a face. I am creating a rectangular face (which I later pushpull) with the following form:

mod.active_layer=layer2
mir=ent.add_group
face = mir.entities.add_face [[x1.m,y1.m,z1.m], [x2.m,y2.m,z2.m], [x3.m,y3.m,z3.m], [x4.m,y4.m,z4.m]]
face.material="White" # I would like this to be the front face material
face.pushpull 1
face.back_material="Red" # and consequently this to be the back face material

I want to do this so that when I export it to Kerkythea for rendering, I would like to see two materials for editing, the White and the Red, and edit them separately. But I am missing sth.
Thank you in advance.
Chris


#2

Most rendering apps ignore the backs of faces and thereby also their materials.
Using either a white/black/transparent/as-front material as its default.
You should never see a face’s ‘backside’ in a correctly modeled 3d object [they should all be ‘inside’ the volume], so even if it did render it ‘red’ you’d never know as it’d be unseen.
Your code makes a quad face, then colors it ‘white’ and then pushpulls it into a volume, the volume’s 6 faces will then clone their material from the parent-face.
Assigning ‘red’ to the original face before pushpulling would make the internal 6 back-faces ‘red’.
Assigning it afterwards only affects the original face.
But as said, adding materials to backs of faces is pointless [either manually or in code], since when it’s transferred to most renderers, which will ignore it anyway.
Try making a ‘box’ by hand, delete the top face, paint the outside faces ‘white’ and the back-faces ‘red’.
Now try that in our renderer - I’d expect the back-faces NOT to show up as red !

Your code is obviously missing some earlier reference set ups…
But why are you messing with the active_layer ?


#3

Hi Tig,
Thank you for your input.
You are right, there are earlier reference set ups not seen there. Also please ignore the mess with the active layer. I see that this quesiton of mine drifts away from ruby and goes to rendering basics. Please see this image:


If I understand you correctly, you are saying that rendering this box as it is, is impossible. I tried it as you see, and you are correct ofcourse. However, if you would like to produce such a render, how would you go about it? The way I am seeing it, is that I should modify my ruby code to have two independent volumes for each wall, one with white material and one with red. ie a sandwich structure like the below:


#4

I think TIG’s point is that you shouldn’t be having exposed back faces in your models.

It’s sloppy modeling to leave back faces exposed. From what I can see, if you are practicing good, clean modeling methods, you shouldn’t need to worry about rendering back faces.


#5

To make a box with a white outside and a red inside you need to model it as you would make it in the real world.
That is with the box’s walls having some thickness.
The initial idea is not a hollow box, it’s a solid cube, which has all of its faces white.
The back-faces should not be confused with inner faces.
If your box has wall thickness and the walls’ faces are correctly oriented then they will all face outwards, all of their back-faces will be within the volume of the wall.
Those front faces can be assign whatever material you desire - e.g. white outwards looking and red inwards looking.


To do it in code is not too difficult - consider followme or pushpull of some ‘offset’ faces etc…


#6

I see, thank you very much DaveR and TIG for your explanations and the drawing.
I was afraid at first that I would have to produce an additional set of coordinates with 3d geometry (as my initial ones) but eventually I took TIG’s advice and it worked like a charm. I wanted a quad face with different material in each side and now I just draw two faces in the same set of coordinates and pushpulled in different directions:

mir1=ent.add_group
face1 = mir1.entities.add_face [[x1.m,y1.m,z1.m], [x2.m,y2.m,z2.m], [x3.m,y3.m,z3.m], [x4.m,y4.m,z4.m]]
mir1.material="White"
face1.pushpull 5

mir2=ent.add_group
face2 = mir2.entities.add_face [[x1.m,y1.m,z1.m], [x2.m,y2.m,z2.m], [x3.m,y3.m,z3.m], [x4.m,y4.m,z4.m]]
mir2.material="Red"
face2.pushpull -2

Many thanks!