cellchuk Posted August 10, 2007 Share Posted August 10, 2007 Hi, I am going to texture a leaf geometry and I'd like to use a double-layered shader, 1 texture for the frontal face and 1 for the back face of the leaf. Note: I did take a quick look to the layer sop but I just managed to overlay 2 textures. I think I need to take the face normals into acount but how? Thanx in advance cheers Quote Link to comment Share on other sites More sharing options...
doc Posted August 10, 2007 Share Posted August 10, 2007 you should just be able to do this by testing against the "I" vector against "N" if the value will be -ve or +ve depending on which side is facing the camera. here's some code (I haven't tryied compiling this) if(dot(normalize(I),normalize(N))<0){ //back face code } else { //front face code } hope that helps Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 you should just be able to do this by testing against the "I" vector against "N" if the value will be -ve or +ve depending on which side is facing the camera. here's some code (I haven't tryied compiling this) if(dot(normalize(I),normalize(N))<0){ //back face code } else { //front face code } hope that helps Hi doc, thanx for the reply. I kind of understood the logic and tried to apply the code in VOPs , however, I couldn't manage to get it right. Could you please be more specific. (I am not that experienced on VEX // VOPs so... ) thanx in advance Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 Hi, I managed to get it work. with the formula that you gave. However, I have used the switcher VOP node instead of using "If then Block" node. Because "if node" didnt work ( it couldnt read the 0 input). Am i doing somehing wrong ? what are the principles to use "if then block" node Quote Link to comment Share on other sites More sharing options...
symek Posted August 10, 2007 Share Posted August 10, 2007 what are the principles to use "if then block" node here you have aplication of doc's idea. cheers, sy. PS and yes, if-then block is little weird.... almost like for-loop vop double_sided_textures.hipnc Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 Here is the VOP network which uses the switch node as a conditioner. d_sided.hip [if node read the 1 input but not the 0 input for some reason] cheers Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 here you have aplication of doc's idea.cheers, sy. PS and yes, if-then block is little weird.... almost like for-loop vop Thanx For the file Symek, Now I understood the workflow of using If conditions. Cheers. Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 Hey I don't have an output on my "if-then-block" node. I know sounds a bit strange but there is no output I am able copy from the help file though. Did this happende any of you guys before or Am I doing something wrong again cheers Quote Link to comment Share on other sites More sharing options...
symek Posted August 10, 2007 Share Posted August 10, 2007 you have to jump into if-then node and connect something to its output. See in an example. ("i" to jump in, "u" - to come back) sy. Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 Cheers, Symek that helped. Its a bit wierd though that you need to get in and go out. maybe it depends anyways it works now Thanx again. Quote Link to comment Share on other sites More sharing options...
symek Posted August 10, 2007 Share Posted August 10, 2007 Cheers, Symekthat helped. Its a bit wierd though that you need to get in and go out. maybe it depends anyways it works now Thanx again. well, the point is that this is a container for your stuff. That's why you jump into it. In many cases you want to make some job there - like in case of if-then statement in normal "hand written" code. good luck! sy. Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 yep, that make sense. I did a quick interface for the this double sided. The parameters that I put are quite basic. If you guys would like to change the interface interms off adding some other parameters or whatever. please feel free about it. Here is the hip file that I created by the help of "doc" and "Symek" ., that contains the VOP network. double_sided_texture.hip cheers Quote Link to comment Share on other sites More sharing options...
photex Posted August 10, 2007 Share Posted August 10, 2007 yep, that make sense. I did a quick interface for the this double sided. The parameters that I put are quite basic. If you guys would like to change the interface interms off adding some other parameters or whatever. please feel free about it. Here is the hip file that I created by the help of "doc" and "Symek" ., that contains the VOP network. double_sided_texture.hip cheers Why not just use IsFrontFace vop to a switch? No need to wire up globals. Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 10, 2007 Author Share Posted August 10, 2007 Why not just use IsFrontFace vop to a switch? No need to wire up globals. Hi Photex, I actually didn't know the existance of "IsFrontFace" vop . thanx for making me aware of it. Cheers Quote Link to comment Share on other sites More sharing options...
photex Posted August 11, 2007 Share Posted August 11, 2007 Hi Photex,I actually didn't know the existance of "IsFrontFace" vop . thanx for making me aware of it. Cheers Well rock and roll to that! Glad I could help. Quote Link to comment Share on other sites More sharing options...
cellchuk Posted August 11, 2007 Author Share Posted August 11, 2007 Well rock and roll to that! yep, that helped rock and roll :thumbsup: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.