SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

SM Forums / Maya Questions / Programming / NCloth set alpha based on vertex position

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
Thread Tools
08-06-2020, 08:41 AM   #1
Join Date: Jun 2020
Posts: 1
NCloth set alpha based on vertex position
I am trying the following setup:

NCloth material has a) or a initial state, b) a copy of mesh in initial state
NCloth is tearable and will split / explode in many places which should alpha/fade based on some "life" parameter, or in this case, the vertices current distances from their initial position.

I am using Arnold as renderer and my attempt is to use vertex color driven by expression comparing every frame every vertex from its original position and then remapping this distance to work as transparency channel on the object texture.

I am very far from achieving any promising effect after 3 -4 hours and I am using just a simple cube as test.
Anyone has any experience about similar situation for advising?
(have no idea what happened to code formatting below - you have to select the text in order to see it...)

 int $vtxCount[] = `polyEvaluate -v pCube1`;
for($i = 0; $i < $vtxCount[0] ; $i++){
	float $c1[] = `pointPosition -l pCube1.vtx[$i]`;
	float $o1[] = `pointPosition -l pCube2.vtx[$i]`;

	float $d1 = sqrt(  ($o1[0] - $c1[0]) * ($o1[0] - $c1[0]) + ($o1[1] - $c1[1]) * ($o1[1] - $c1[1]) + ($o1[2] - $c1[2]) * ($o1[2] - $c1[2]));  
	if ($d1 > 0.01) {
		//setAttr remapColor1.inputMin = $d1; $d1 $d1 $d1 ; works only when I press "evaluate button"
               //direct connection
                remapColor1.inputMin = $d1;
  Reply with quote

arnold , ncloth , vertex color

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to keep the control vertex of a curve visible? will2power Maya Basics & Newbie Lounge 0 29-05-2020 07:01 PM
set pivot on lowest vertex kmthrong Programming 0 08-01-2016 10:59 AM
Vertex position into nodes exodune Programming 0 06-09-2015 02:53 PM
Textures not linking to tutorial maya.... dan003 Maya Basics & Newbie Lounge 2 07-03-2015 11:08 PM
Set ramp color position as driven spandy Maya Basics & Newbie Lounge 5 24-06-2003 01:24 PM