Announcement

Collapse
No announcement yet.

Setting Properties on Material Instances

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Originally posted by westcut View Post
    192.168.1.1 192.168.0.1 10.0.0.1

    Tried to use it but it refused to build. will try again later also the link you gave is broken
    SetTextureParameterValueEditorOnly(FMaterialParameterInfo("Diffuse"), GetTextureByName(Textures[animaMat->mDiffuseIndex].mName, ConnectionSlot:iffuseSlot));

    Leave a comment:


  • replied
    I made a couple of functions in order to create or modify material instance parameters:

    https://gist.github.com/animationdav...ae9708b66fcfd1


    Leave a comment:


  • replied
    Ok! I found a way to do it, I modfied the previus code to show you.

    At the same way that you can set a parameter into a dict, you can make a copy and set the name of the parameter, if it exists,automatically the checkbox is turned on.

    Code:
    for i in range(len(paramInfo)):
        if paramInfo[i].parameter_info.name == "testVal":
            print "Found Parameter"
            newParams = paramInfo[i] #i made a copy
            newParams.parameter_value = 1 # adjusted the value
            paramInfo[i] = newParams #copied all the values back to the array
        else:
            new_param = paramInfo[i]
            new_param.parameter_info.name = "testVale"
            new_param.parameter_value = 1
            paramInfo[i] = new_param

    Leave a comment:


  • replied
    A friend just told me how he do this in C++:

    SetTextureParameterValueEditorOnly(FMaterialParameterInfo("Diffuse"), GetTextureByName(Textures[animaMat->mDiffuseIndex].mName, ConnectionSlot:iffuseSlot));

    https://docs.unrealengine.com/en-US/...ant/index.html

    I have checked it and we don't have this method in python, I can assume that we shoud replicate it with "set_editor_property" but does not work for me in any case.

    Grettings,

    Leave a comment:


  • replied
    Ye i made a UDIM texturing system that handles that but setting the bool was annoying

    Leave a comment:


  • replied
    Thanks for the reply westcut,

    I'm completly stuck in this part right now, I gonna try to understand how to do it in C++ and then replicate it in Pyhton, maybe someone can bring us some light into this... I'm lost xD

    Leave a comment:


  • replied
    Originally posted by KaitoDBM View Post
    Hi westcut!

    How do you turn on the checkbox parameter in python?
    unfortunately havent figured that part out as we move on from that section it is on hold for now

    Leave a comment:


  • replied
    Hi westcut!

    How do you turn on the checkbox parameter in python?
    Last edited by KaitoDBM; 07-04-2019, 02:30 PM.

    Leave a comment:


  • replied
    Originally posted by duke22 View Post
    Or grab my EditorPlus plugin, switch to the 4.22 branch and use this:

    https://github.com/GeorgeR/EditorPlu...​​​​
    Tried to use it but it refused to build. will try again later also the link you gave is broken

    Leave a comment:


  • replied
    Or grab my EditorPlus plugin, switch to the 4.22 branch and use this:

    https://github.com/GeorgeR/EditorPlu...​​​​

    Leave a comment:


  • replied
    I played around with this and got the following to work, not sure if this will work for you. I tried to use the set_editor_property and could not get anything to work either.

    Code:
    paramInfo = instance.scalar_parameter_values
    print paramInfo
    #LogPython: [{parameter_info: {name: "testVal", association: GlobalParameter, index: -1}, parameter_value: 1.000000}, {parameter_info: {name: "RefractionDepthBias", association: GlobalParameter, index: -1}, parameter_value: 0.000000}]
    
    #because i got an array, i need to check and make sure i am adjusting the right one.
    for i in range(len(paramInfo)):
       if paramInfo[i].parameter_info.name == "testVal":
          print "Found Parameter"
          newParams = paramInfo[i]  #i made a copy
          newParams.parameter_value = 1.2 # adjusted the value
          paramInfo[i] = newParams #copied all the values back to the array
    
    print instance.get_scalar_parameter_value("testVal")
    #LogPython: 1.20000004768
    After running the above code i reloaded the material instance in the material editor and the values changed. Note: For some reason if the material instance was already loaded and you run the code, the changes do happen behind the scenes, but don't show up in the editor until you reload it. Meaning you need to close and double click on the material instance again to see the changes

    Leave a comment:


  • started a topic Setting Properties on Material Instances

    Setting Properties on Material Instances

    Hello,
    I am trying to set some parameters on my material instance to automate the process and i made a simple instance to test it on.
    Click image for larger version

Name:	Untitled.png
Views:	18
Size:	49.6 KB
ID:	1634963
    instance is already set to the reference.
    if i did scalar_value= instance.get_scalar_parameter_value("TestVal")
    print scalar_value i would get 1.0

    i want to be able to set the value of that scalar parameter

    i have tried
    instance.set_editor_property("scalar_parameter_values",(parameter_info=['TestVal', MaterialParameterAssociation.GLOBAL_PARAMETER, -1], parameter_value=0.0))

    I have tried various version of this line of code but get the error: LogPython: Error: SyntaxError: invalid syntax (<string>, line 1)

    Last edited by westcut; 06-24-2019, 01:47 PM.
Working...
X