View Full Version : using xpresso to alternate between textures / texture properies
caimatthews 09-11-2010, 04:18 PM hi all,
I've spent the past few days trying to figure out how to change the shader properties (colour, alpha etc.) of a polygon mesh using each poly's rotation, orientation & global position using xpresso... but with little success!
I've managed to find a few examples with similar principles to what I'd like to do, such as here (http://www.tvgrafx.com/tutorials/xpresso/assets/xpresso_replace_image.mov), but I'm still struggling slightly with regard to which nodes i should use to switch between materials or any given materials properties (on the 'input' side).
This is my first venture using xpresso (although i have coding experience using processing & max/msp), so I'd really appreciate any help, or even just a nudge in the right direction!
Also, sorry if the solutions to the problem I've posted are xpresso 101... as i mentioned, I'm completely new to it.
thanks! cai.
|
|
pgrooff
09-19-2010, 10:13 AM
Hi cai,
I do like the tutorial and I think it is a good start.
Accessing the shader properties is rather simple.
Double click you material and drag & drop the little preview window of the material to your Xpresso window.
You can then select what you want to set.
Hope this helps.
caimatthews
09-27-2010, 03:53 PM
Hey pgrooff, thanks for the response!
That does help, although I have worked my way through the help menu and found solutions for the more basic problems I was having - but I still I haven't managed to figure out my main issue.
I have a .obj which is essentially a plane (exported from processing) - which I am displacing using the mograph displace effector.
What I am trying to do is create a custom shader / material which samples the angle of each plane/poly within the .obj & and controls the material in correlation to its local position or rotation.
i.e. if it is not being displaced, the material would be 'off', but as soon as it's coordinates change due to displacement, i want the material to be 'on'.
(the .obj has around 20,000 polys)
I'm not even sure if it's possible, as I've been working on it for a few weeks now!
I know it can be done in 3d max, but I'm tied to c4d for this project.
Any ideas are welcomed & when i get a chance after this project I'll try and answer some of the simpler questions on here - to free up the more experienced of contributors to spend their time on more advanced problems and ideas!
Thanks again!
Cai.
Darter
09-28-2010, 01:27 PM
Point nodes have a Use Deformed Points option, which can be used to compare a point's deformed and original positions. A Polygon node can feed a poly's point indices into point nodes and if a point has moved, the poly has been deformed. Each deformed poly can be selected and stored in a Polygon Selection tag, which can then be used to apply the material.
In the example setup, there's a one-frame lag in the editor but this isn't an issue when rendering to the Viewport or Picture Viewer.
EDIT: Updated to test orientation and position of polys using Polygon nodes.
caimatthews
09-28-2010, 05:43 PM
Hey Darter,
That really is fantastic, thanks so much!
This is so close to what I have been trying to achieve!
Hopefully this will also help me expand my understanding of xpresso as I can use the file you attached as a kind of building block and example of how to set these kind of things up!
I do have one small question to add though... (if it's possible to do this) what nodes would I need to look at to make the material transparent (or 'off') for the areas which are not being deformed?
e.g. so that only the orange polys are visible at any point in time, and not the sphere sections which are grey?
Again I can't thank you enough for this, when the project is completed I'll post the finished piece as a reply here so that I can share it with you (as long as my clients exclusivity clauses aren't affected by me doing so!).
Cheers, Cai.
Darter
09-28-2010, 09:55 PM
Glad to hear that it's created the desired effect.
To bring it home you can apply a material with transparency and no specular, or a black alpha channel. Then place its Texture Tag before the coloured material's tag in the Object Manager.
caimatthews
09-29-2010, 06:23 PM
Amazing! Thanks so much!
Applying the transparent texture worked perfectly on the sphere in your file!
I'm having a little trouble applying the principles to my object though, I feel like I've done all the right things - but I think the c.o.f.f.e.e node needs to be changed for my object? Or maybe certain parameters?
I'm not sure how to attach files to posts (I presume it needs to be hosted, or I need to be a premium member of somesort?), but I would love to share it, and any insights into the areas I should be adapting more specifically would be massively helpfull! (even if you want to message me email addresses, that's fine with me.)
The final material for the mesh is far more complicated than the flat colour... but for demonstration purposes hopefully the matt orange will work!
Thanks again! Cai.
Darter
09-29-2010, 09:04 PM
The expression transfers to different objects fine here. The Object node is set to automtically reference the host object so you just need to drag the XPresso tag, poly tag and textue tags onto the new object.
As you have over 2 posts, you should be able to attach files to your reply under Additional Options.
caimatthews
10-01-2010, 02:13 PM
Thanks Darter,
I've spent a while experimenting and I still can't quite put my finger on what's not working.
There's also the 'xpresso' node that feeds into the c.o.f.f.e.e. polygon selection port - I'm not exactly sure what node type this is?
I've attached the file here (which should hopefully contain the displacement map's texture), I'd super appreciate if you could take a look for me!? (please excuse the messiness of the setup :blush:)
thanks again.
Darter
10-02-2010, 01:09 AM
You've broken the expression by trying to rework it and the Displace texture wasn't included with the scene. Also, it was a .mov file which is probably too large to upload here.
You'll need to recreate the problem with the original setup. For displacement, use a bitmap saved with the project.
caimatthews
10-02-2010, 11:17 AM
sorry about all that Darta,
I tried to recreate your xpresso setup on my mesh object - rather than copy it over, so I'm presuming thats why its messed up so bad!?
I've changed the displace material to a noise texture, and included the entire mesh (rather than try to trim it down). This meant that I couldn't get the file size small enough to attach on here, so have included the sendspace link - i hope this is allowed on the forum?
I think the main issue I was having (out of the obvious many) was that I could figure out how to create the polygon selection tag?
I appreciate your patience with me on this Darta, If you ever need help with After Effects or compositing, I'm your guy!!
Thanks, here's the link to the project file.
http://www.sendspace.com/file/cstdvt
Darter
10-03-2010, 04:01 AM
No worries. The problem was caused by a small floating point error and solved by setting a threshold for the displacement test. Also, instead of point positions the test is now applied to orientation and position of polys, improving speed.
The original expression above has been updated.
caimatthews
10-03-2010, 07:04 PM
That's great, thanks so much!
Just 2 more questions, I promise ;)
1 - Is it possible for the displacement to turn on/off different sections of the material as it passes through it (i.e. only the areas of the material covering the displaced polys), rather than 'squash' the whole material to just the displaced polys? When I replace the orange with my material which uses an image that is based on the polys, it crunches it onto just the displaced areas. I'm not even sure if this is possible in c4d?
2 - What is the correct way to copy the xpresso, poly selection & other tags to other objects/projects?
I feel bad that I'm loading all this onto you Darta, shame I'm not in Australia to buy you a few beers!
thanks!
(sorry about the size of the .zip, my texture is pretty large as it's a .psd)
http://www.sendspace.com/file/xk2mg4
Darter
10-05-2010, 10:41 PM
Your UVW mapping appears corrupted. To fix:
Delete the UVW Tag
Set the Texture Tag to Flat Projection
Right-click the Texture Tag and select Fit to Object
Right-click the Texture Tag and select Generate UVW Coordinates
Either Flat or UVW projection are suitable for this mesh. If using Flat projection, apply a Stick Texture tag to pin down the texture during deformation.
To transfer the setup to a different object, drag the XPresso, texture and poly selection tags onto it from the original object. You may need to repeat the above steps for the texture.
caimatthews
10-07-2010, 05:29 PM
That procedure doesn't seem to work for some reason?
the image on the material still doesn't seem to correlate to the polys on the mesh itself... but I'm sure it's probably something I'm doing incorrectly, or maybe there is an issue with the resolution of the image itself - I will look into this!
Thank you so much for the help Darter, I really mean that!
Now I'm off to try to pick apart the expression in the c.o.f.f.e.e. node and try to learn the language a little better! Oh, one super last question... What type of node is the 'poly selection' xpresso node that feeds into the c.o.f.f.e.e. node on the very bottom? Is it the poly selection tag dragged into the xpresso window?
Like I said, if you ever need any compositing or any After Effects advice... I'm your man!
Cheers,
cai.
Darter
10-08-2010, 01:34 AM
The steps above work perfectly with your provided texture, so give it another try.
The node is an Object Operator created by dragging the XPresso tag into the XPresso editor. 'Polygon Selection' is the name of the port, which is for the User Data on the XPresso tag. If you left-click on the node's red square, you'll find it ghosted under User Data.
caimatthews
10-14-2010, 01:38 PM
hey,
sorry for the delayed reply... been a bit manic working on this think for the past week or so!!
the set-up works perfectly now - for some reason I had re-sized the mesh, which is why the texture didn't match up! (oops!)
Once I've finished on this project I'm hoping do try and develop more controllable versions of this thing, maybe using the sdk and some c++.
Thanks again or all the help darter, really appreciate it!
Cai.
Darter
10-14-2010, 09:14 PM
No problem Cai, glad to hear that it's working!
CGTalk Moderation
10-14-2010, 09:14 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.