maxscript: How to place OSLbitmap lookup in an Arnold standard surface map slot?

maxscript: How to place OSLbitmap lookup in an Arnold standard surface map slot?

10DSpace
Advisor Advisor
1,980 Views
5 Replies
Message 1 of 6

maxscript: How to place OSLbitmap lookup in an Arnold standard surface map slot?

10DSpace
Advisor
Advisor

Hi all,

 

I am working on a maxscript to auto load the PBR bitmaps exported from substance painter into an Arnold standard surface material (and the Physical material as well.)   I want to place an OSL Bitmap Lookup Map in the slots requiring a linear workflow (e.g., Normal, Roughness, Metalness) so that I can take advantage of the ability to set gamma = 1.0 with the OSL Bitmap Lookup Map.  However,  I have not been able to  find the right syntax to do the first step of loading the OSL Bitmap Lookup Map into any slot.    I am pretty sure it is something simple that I am missing.   

 

For example, none of the following work:

 

--//////////////////// Attempt 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

-- load Roughness map into slot and set gamma to 1.0

newMaterial.specular_roughness_shader = OSLMap() 

 

--The above just results in the generic example OSLMap loaded into the slot and not the Bitmap Lookup OSL Map

 

--//////////////////// Attempt 2 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

--tried loading the file .osl file directly into slot

newMaterial.specular_roughness_shader = "C:\Program Files\Autodesk\3ds Max 2020\OSL\OSLBitmap.osl"

 

The above produces the following error message:

OSL Error message.png

 

--//////////////////// Attempt 3 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

-- so tried loading the file .osl file using the BitmapTexture Filename: 

newMaterial.specular_roughness_shader = Bitmaptexture fileName: "C:\Program Files\Autodesk\3ds Max 2020\OSL\OSLBitmap.osl"

 

--The above places the .OSL into the Bitmap Parameters  > Bitmap slot and not the parent slot;  in other words treats it like a texture map and therefore with no access to the parameters I am interested in (gamma )

 

--//////////////////// Attempt 4  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

--so I tried using the <OSLMap> OSLPath method, but obviously got the syntax wrong 

newMaterial.specular_roughness_shader = OSLMap.OSLPath = "C:\Program Files\Autodesk\3ds Max 2020\OSL\OSLBitmap.osl"

 

 --The above gave the following error message:

OSL Path error.png

 

 

I will not bore you with the various other (pathetic) attempts to get the syntax right, but am hoping the expertise here can guide me as to what I am doing wrong. 

 

Thanks in advance for any guidance.

0 Likes
Accepted solutions (1)
1,981 Views
5 Replies
Replies (5)
Message 2 of 6

10DSpace
Advisor
Advisor

Anybody?  Is there no way to load the OSL Bitmap Lookup Map into a material slot using maxscript?   Even confirmation that it is not possible would be helpful so I don't waste further time on it.  Would appreciate any help. 

0 Likes
Message 3 of 6

denisT.MaxDoctor
Advisor
Advisor

 

everything is straightforward:

 

 

mat = ai_Standard_Surface()
mat.specular_roughness_shader = OSLMap()

 

 

what is "Bitmap Lookup OSL Map"?

 

0 Likes
Message 4 of 6

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

ohh! i see...

 

let me think a little...

 

here is it:

mat = ai_Standard_Surface()
tx = mat.specular_roughness_shader = OSLMap()
tx.OSLpath = @"C:\Program Files\Autodesk\3ds Max 2020\OSL\OSLBitmap.osl"
tx.OSLAutoUpdate = on
Message 5 of 6

10DSpace
Advisor
Advisor

@denisT.MaxDoctor 

 

Thanks very much! That works.  I was overlooking the @ symbol in specifying the file path to the specific OSL MapI was interested in.   

0 Likes
Message 6 of 6

nl2Y8BW
Explorer
Explorer

that worked well. can you show how to imbed the OSL code into the maxscript(using .OSLCode)? 

also when running the script the name always shows as "OSLMap". can that be changed?Screenshot 2021-07-06 163642.png

0 Likes