Faster Triplanar Setup (maxScript)

Faster Triplanar Setup (maxScript)

cjwidd
Contributor Contributor
1,826 Views
7 Replies
Message 1 of 8

Faster Triplanar Setup (maxScript)

cjwidd
Contributor
Contributor

I would like to prepare a macroscript to address the issue described in this thread while waiting for an official implementation from Corona (Render Legion). Before I start asking implementation questions, does anyone have a script like this laying around that they would be willing to share?

I expect the script would:

1. Access a material with attached bitmaps
2. Insert a Corona Triplanar node to all bitmap attachments
3. Assign a bezier float controller to all Triplanar 'scale' parameters

It would be great to piggyback off some functionality for a script like this (ezMat for 3ds Max) to create an all-in-one texture / material import workflow.

0 Likes
1,827 Views
7 Replies
Replies (7)
Message 2 of 8

denisT.MaxDoctor
Advisor
Advisor

if i understood correct what you want the script might be as:

fn getCoronaMaterialAllTexmaps mat = 
(
	ss = stringstream ""
	showproperties mat to:ss

	local txs = #()
	seek ss 0
	while not eof ss do
	(
		tx = readline ss
		if matchpattern tx pattern:"* : texturemap" do (append txs (filterstring tx " .")[1])
		
	)
	
	free ss
	txs
)

fn createCoronaMaterialTriplanar name: texmaps:#all scaleControl:bezier_float = 
(
	local mat = CoronaMtl name:name
		
	if texmaps == #all do texmaps = getCoronaMaterialAllTexmaps mat
	if iskindof texmaps Array do
	(
		for tx in texmaps where isproperty mat tx do
		(
			bmp = CoronaTriplanar()
			if iskindof scaleControl FloatController do bmp.scale.controller = createinstance scaleControl 
			setproperty mat tx bmp 
		)
	)
	mat
)

/* USING EXAMPLES : 

mat0 = createCoronaMaterialTriplanar name:"CoronaMatAllTri"
mat0.name
mat0.texmapDiffuse
mat0.texmapOpacity
mat0.texmapDiffuse.scale.controller

mat1 = createCoronaMaterialTriplanar name:"CoronaMatDiffuseTri" texmaps:#(#texmapDiffuse) scaleControl:linear_float
mat1.name
mat1.texmapDiffuse
mat1.texmapOpacity
mat1.texmapDiffuse.scale.controller

mat2 = createCoronaMaterialTriplanar name:"CoronaMatBaseTri" texmaps:#(#texmapDiffuse, #texmapOpacity, #texmapBump)
mat2.name
mat2.texmapDiffuse
mat2.texmapOpacity
mat2.texmapBump
mat2.texmapDiffuse.scale.controller

*/

so as you see you can specify the name, the types of texture maps to set as Triplanar, and type of scale controller to apply

0 Likes
Message 3 of 8

denisT.MaxDoctor
Advisor
Advisor

and you can update the existing one:

fn updateCoronaMaterialTriplanar mat texmaps:#all scaleControl:bezier_float = 
(
	if iskindof mat CoronaMtl do
	(
		if texmaps == #all do texmaps = getCoronaMaterialAllTexmaps mat
		if iskindof texmaps Array do
		(
			for tx in texmaps where isproperty mat tx do
			(
				bmp = CoronaTriplanar()
				if iskindof scaleControl FloatController do bmp.scale.controller = createinstance scaleControl 
				setproperty mat tx bmp 
			)
		)
		mat
	)
)

/*
mat3 = CoronaMtl()
mat3.texmapDiffuse
try (mat3.texmapDiffuse.scale.controller) catch()

updateCoronaMaterialTriplanar mat3
mat3.texmapDiffuse
mat3.texmapOpacity
mat3.texmapDiffuse.scale.controller

*/
0 Likes
Message 4 of 8

cjwidd
Contributor
Contributor

@denisT.MaxDoctor Thank you for taking the time to respond to my question. I experimented with your scripts but I'm not sure I understand. It appears that the scripts are creating a material with triplanar nodes and bezier float controllers, but the material is not visible in the Slate Material Editor(?)

 

To clarify, I am trying to create a macroscript that takes the user from 'Before' to 'After' in one click (see below):

 

The idea is that the user sees a material with bitmaps attached in the Slate Material Editor, selects the material, clicks a button (or hotkey), and then sees that material with triplanar nodes inserted, and bezier float controllers attached to the 'scale' parameter of the triplanar nodes.


Before 

before.png

 

 


A material with different bitmaps already attached.

NOTE: the bump channel is connected to a 'Corona Normal Texmap' and a source bitmap (normal).

 

After

after.png

A material with triplanar nodes inserted between the CoronaMtl and the incoming node. Bezier float controllers are attached to the 'scale' parameter of the triplanar nodes to globally adjust triplanar scaling.

NOTE:  the triplanar node in the bump channel is inserted between the Corona Normal Texmap and the material, rather than between the source bitmap (normal) and the Corona Normal Texmap.

0 Likes
Message 5 of 8

denisT.MaxDoctor
Advisor
Advisor

did you say any word about the Slate Material Editor in your original post?

 

so it's a second question: How to add a material to the Slate Material Editor?

 

0 Likes
Message 6 of 8

cjwidd
Contributor
Contributor

I did not include any details about the Slate Material Editor in my original post, sorry for the confusion. 

0 Likes
Message 7 of 8

denisT.MaxDoctor
Advisor
Advisor

well... here is how to show a material in the MSE (one of the possible ways):

fn setMaterialInSME mat pos:[0,0] zoomExtents:om = if sme.isOpen() do
(
	if (id = sme.getViewByName "Selected") != 0 do sme.deleteView id off
	view = sme.getview (sme.createview "Selected")
	view.CreateNode mat pos	

	if zoomExtents do
	(
		 -- Update Layout:
		hwnd = windows.getChildHWND 0 "Slate Material Editor"
		WM_COMMAND = 0x111
		ID = 0xA02C -- Layout All Button source ID
		windows.sendMessage hwnd[1] WM_COMMAND ID 0 -- press button
	)
)
/*
setMaterialInSME mat2
*/ 

with the function i give you an option to ZOOM (as a bonus 😉).

 

 

But I already know that you will ask another questions:

--- How to "Show All Additional Parameters"?

--- How to "Hide Unused Nodeslots"?

--- etc.

 

There are several Autodesk guys on this forum... it's their job to answer this kind of questions or at least explain why questions above (and most all SME UI methods) are not available to MXS.

 

  

0 Likes
Message 8 of 8

kinower
Contributor
Contributor

the script could be upgraded to corona 7

0 Likes