ZBrushCentral

ZScript Apply DispMap doesn't seem to work?

Hi everyone,

I’m a beginner with ZScript but loving it!

Below follows a part of my script:

[IPress,Tool:Texture Map:TextureMap]
[IPress,PopUp:Texture 28]
[IPress,Tool:Displacement Map:DisplacementMap]
[IUnpress,PopUp:texture_name]
[IPress, Tool: Displacement Map:Disp On]
[ISet,Tool:Displacement Map:Intensity,0.015]
[IPress, Tool:Displacement Map:Apply DispMap]

The texture map and displacement map are assigned to the UV’ed model, also the intensity is set.

But the displacement map is not applied.

Did I do something wrong or am I missing something?

Thank you for any feedback and help!

try that :

[IPress, "Tool:Texture Map:TextureMap"]
[IPress, "PopUp:Texture 28"]
[IPress, "Tool:Displacement Map:DisplacementMap"]
[IPress, "PopUp:Alpha 62"]

[ISet, Tool:Displacement Map:Intensity,0.015]
[IPress, Tool:Displacement Map:Apply DispMap]

Well that is awesome Nicolas, works like a charm, thank you so much!

I’m wondering why ZBrush generated ‘false’ zscript code?

I have some 500 models that need displacement this way. Thanks to you I will get some sleep and let the PC do the work :smile:

Ah wait, it still doesn’t work in my setup.

I think it has something to do with the alpha texture that I import and its name I’m trying to use.

I use this for importing the alpha texture:

[FileNameSetNext,"N:/path/3849_5478_3829_displacement_map.jpg"]
[IPress,Alpha:Import]

Then I use your code but replace:

[IPress, "PopUp:Alpha 62"]

with:

[IPress, "PopUp:3849_5478_3829_displacement_map"]

and then there’s just the alpha selection window that is opened and stays open.

Any ideas?

does it works if your try with :

[FileNameSetNext,"N:/path/3849_5478_3829_displacement_map.jpg"]
[IPress, File:Alpha:Import]

Hi, unfortunately that doesn’t change anything, the displacment map selection window opens, and stays open.

I can even first load the alpha texture manually.

I think the problem has to do with these lines:

[IPress, "Tool:Displacement Map:DisplacementMap"]
[IPress, "PopUp:3849_5478_3829_displacement_map"]

Somehow I don’t think ZBrush recognizes the texture name.

But when I use your line:

[IPress, "Tool:Displacement Map:DisplacementMap"]
[IPress, "PopUp:Alpha 62"]

it does work, I just can’t figure out the difference.

Thank you for your thoughts!

just add that line :

[IClick,  6207]

right after this line :

[IPress, "PopUp:3849_5478_3829_displacement_map"]

full source code :

[RoutineDef, apply_displacement,
	[FileNameSetNext, path, ]
	[IPress, "File:Alpha:Import"]
	[IPress, "Tool:Texture Map:TextureMap"]
	[IPress, "PopUp:Texture 28"]
	[IPress, "Tool:Displacement Map:DisplacementMap"]
	[IPress, [StrMerge, "PopUp:", filename]]
	[IClick, 6207]
	[ISet, "Tool:Displacement Map:Intensity",0.015]
	[IPress, "Tool:Displacement Map:Apply DispMap"]

,path, filename]

// and the ibutton

[IButton, "Zplugin:test plugin:Apply displacement",".",
	[VarSet, path, "N:/path/3849_5478_3829_displacement_map.jpg"]
	[VarSet, filename, "3849_5478_3829_displacement_map"]
	[IPress, "Tool:Plane3d"]
	[IPress, "Tool:Make Polymesh3D"]
	[RoutineCall, apply_displacement, path, filename]
,,1]```

When I call:

[RoutineCall, apply_displacement, path, filename]

two times it works :smile: So that is a little crazy, but it finally works.

Thank you so much!!

I’m really puzzled by the fact that ZBrush doesn’t have automation or an SDK that is up to par with any other professional 3D application out there.

I’ve been reading the things you need to do to make the filesystem accessible to ZScript, it’s just nuts.

There are so many studios depending on ZBrush, why hasn’t Pixologic replaced ZScript with Python or C++, C, C# or just any standard language?

It’s so strange that you would need methods like ‘[IClick, 6207]’ to be able to ‘fix’ the script. That is defintely not in the manual!

If there was an application with a great SDK that could replace ZBrush I would pay double to replace it immediately.

It’s mind boggling really, to be a professional technical designer and having to work like this, it feels like the dark ages.

But now… back to 2020!

it should work with just a single [RoutineCall, …]
I can’t say about the context you are using the script or maybe you can post your script so i could tell you a bit more.

[IClick] is documented in the manual

I don’t appreciate you cherry-picking my comments, but since you were so kind to help me I also don’t want to come off as being rude towards you.

Clearly I meant that this ‘fix’ is not in the manual. The recorded ZScript code from ZBrush itself doesn’t work at all and needs many ‘fixes’ to work.

After doing some research it’s clear that Pixologic has a decade-long policy of not addressing all the automation flaws.

One can just wonder why? Having decades of automation experience I can state that - compared to ZBrush - e.g. automating Photoshop or 3D Studio Max is a dream.

I’m open to discussing this honestly but you need to bring an open mind.

This code works OK for me:

[RoutineDef, ApplyDisplacement,	
	[IPress, Tool:Texture Map:New Txtr]	
	[IPress, Tool:Displacement Map:DisplacementMap]
	[IClick, [StrMerge, "PopUp:", [Var,alphaName]]]	
	[ISet, Tool:Displacement Map:Intensity,0.15]
	[IPress, Tool:Displacement Map:Apply DispMap]
,alphaName]


[IButton,TestDisp,"Do it",	
	[VarSet,fileName,[FileNameAsk,"Image Formats(*.bmp)|*.BMP|(*.psd)|*.PSD|(*.tif)|*.TIF|(*.jpg)|*.JPG||",,"Please Select File..."]]
	[If,[StrLength,fileName],
		[FileNameSetNext,fileName]
		[IPress,Alpha:Import]
		[RoutineCall,ApplyDisplacement,[IGetTitle,Alpha:Current Alpha]]
	]
]

-Marcus

Thank you Marcus, but we have removed ZBrush from our pipeline entirely, except for the occasional sculpting.

We are replacing many of ZBrush’s great (but manual) features with CUDA-based scripts that do the same but 100% automated and many times in realtime.

In the meantime, we have saved us 31 ZBrush licences, so there’s that.

Still, do your thing Pixologic management. You’re just perfect the way you are. Don’t ever change.

Byyyeeeeeeeee Felicia