Jump to content

Property of material


Icare
 Share

Recommended Posts

Hi,

 

Is it possible to retreive or set the properties of an material on runtime without read or write on the .mat file ?

 

I would like to retreive or set :

* Depthmask

* colormask

* alphatest

* etc ...

 

Similarly we can load or create a material, but if we want to save it we must write The function to do it?

 

thank

 

Nicolaas

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

Is it possible to retreive or set the properties of an material on runtime without read or write on the .mat file ?

 

I would like to retreive or set :

* Depthmask

* colormask

* alphatest

* etc ...

I think you can still use GetMaterialKey and SetMaterialKey for this but I know in the past that SetMaterialKey didn't work for all standard properties in the material file. For instance 'castshadows' couldn't be set programatically. Both Masterxilo and myself requested the full set be implemented on separtate occations but I'm not sure this ever got implemented ... I just gave up asking in the end!

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Been a while since I've done much with LE, but I remember this part:

 

Local myMaterial:tmaterial = LoadMaterial(FILE)

SetShaderVec3(myMaterial.reference.shader, "ShaderVariableName", vec3(0,0,0))
' SetShaderVec4
' SetShaderFloat

 

Not sure if that's what you meant exactly, but there you go.

Link to comment
Share on other sites

As Pixel Perfect said you can modify some material keys at runtime using GetMaterialKey and SetMaterialKey. This doesn't work for all keys however. So you'd be better off writing a class that creates a temp material file, loads and deletes it to create materials at runtime. That's what I did anyway.

 

Similarly we can load or create a material, but if we want to save it we must write The function to do it?

Yes.

Link to comment
Share on other sites

I found my happiness ...

 

There is reference member in blitzmax object that gives access to everything...

 

global material=creatematerial()
WriteLine file, "color=" + 1.0 / 255.0 * r + "," + 1.0 / 255.0 * g + "," + 1.0 / 255.0 * b + "," + a
WriteLine File, "blend=" + material.reference.blendmode
WriteLine file, "depthmask=" + material.reference.depthmask
WriteLine File, "depthtest=" + material.reference.depthtest
WriteLine File, "alphatest=" + material.reference.alphatest
WriteLine File, "overlay=" + material.reference.overlay
WriteLine file, "zsort=" + material.reference.zsort
WriteLine file, "cullface=" + material.reference.cullface
WriteLine file, "castshadows=" + material.reference.castshadows
WriteLine file, "specular=" + material.reference.specular
WriteLine file, "bumpscale=" + material.reference.bumpscale

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...