[Solved] Is there a way to change the image gamma using DzTextureModifier?

EsemwyEsemwy Posts: 577

The "Image Editor" has the ability to read and edit image gamma, so logically, so should DzTextureModifier, except I can't find a method or property that allows me to do so. Has anybody figured out how to do this?

Post edited by Esemwy on

Comments

  • zaz777zaz777 Posts: 115

    This is definitely possible.  I wrote the following code snippets prior to being aware of documentation for some of what is used.  I just used a method similar to Rob's self_discovery script to find methods and variables, then tried using them in obvious ways.

    I believe Rob has documented some of what I used since then and you might find documentation here.

    I found the texture maps and DzTextureModifiers by examining properties of a material.  I did this in a loop, iterating over the return from DzMaterial.getPropertyList().

    // With a property from a materialif (!prop.isHidden ()) {    if (prop.inherits ("DzFloatColorProperty") || prop.inherits ("DzFloatProperty") || prop.inherits ("DzColorProperty")) {        print ("prop " + propIdx + " is " + prop.getLabel () + " => " + prop.className());        if (prop.isMappable ()) {            props [propNum] = prop;            propNum += 1;        }    }}

    Later in my code when I'm editing the values, I use the following code.

    if (texs [texNum].isMapped () && imageList [texs [texNum].getLabel()] == true) {    print ("         image: " + texs [texNum].getMapValue().getFilename ());    texMod = texs [texNum].getTextureModifier ();    if (! texMod) {        print ("No DzTextureModifier, make new one.");        texMod = new DzTextureModifier ();    }    texMod.horizontalTiles = horizTiles;    texMod.horizontalTilingOffset = horizOff;    texMod.verticalTiles = vertTiles;    texMod.verticalTilingOffset = vertOff;    texMod.scale = imageScale;    texMod.offset = imageOffset;    texs [texNum].setTextureModifier (texMod);    texs [texNum].setDefaultMapGamma (imageGamma);}

    It has been quite awhile since I wrote the script that this code is from.  I believe "texs" is the array I built in the first code block (called props there).  So, "texMod" is a DzFloatColorProperty, DzFloatProperty or a DzColorProperty.  The gamma doesn't/didn't actually use the DzTextureModifier object, perhaps because gamma is used by both 3Delight and Iray, while the other properties in the DzTextureModifier object only apply for Iray.

    So, if you really only want to set the gamma, you can actually do that on a DzColorProperty using get/setDefaultMapGamma or you can do it on a DzTexture using get/setGamma.  I'm not sure what the difference is, one might be only associated with the property and the other with the texture.  The DzTextureModifier is definitely only associated with the property.

  • EsemwyEsemwy Posts: 577

    You're entirely correct. I did not need the DzTextureModifier after all. Calling DzNumericProperty::getMapValue() returns a DzTexture on which I can call setGamma(). I was led astray by the fact that the other properties in the "Image Editor" dialog are controlled by the DzTextureModifier.

    Thanks!

  • Esemwy said:

    You're entirely correct. I did not need the DzTextureModifier after all. Calling DzNumericProperty::getMapValue() returns a DzTexture on which I can call setGamma(). I was led astray by the fact that the other properties in the "Image Editor" dialog are controlled by the DzTextureModifier.

    Thanks!

    Can you please share that code of what you have done to solve this "problem"? I need to change the gamma & the offset too.

    Thank you very much.

  • Esemwy said:

    You're entirely correct. I did not need the DzTextureModifier after all. Calling DzNumericProperty::getMapValue() returns a DzTexture on which I can call setGamma(). I was led astray by the fact that the other properties in the "Image Editor" dialog are controlled by the DzTextureModifier.

    Thanks!

    But how do you know which channel to set the gamma value? If you want only the Base Color? Or if you want only the Translucency Color?

  • EsemwyEsemwy Posts: 577

    I posted a script in the substance painter discussion a while back. I think it should have all the elements you’re looking for.

    https://www.daz3d.com/forums/discussion/comment/1940251/#Comment_1940251

    Esemwy said:

    You're entirely correct. I did not need the DzTextureModifier after all. Calling DzNumericProperty::getMapValue() returns a DzTexture on which I can call setGamma(). I was led astray by the fact that the other properties in the "Image Editor" dialog are controlled by the DzTextureModifier.

    Thanks!

    But how do you know which channel to set the gamma value? If you want only the Base Color? Or if you want only the Translucency Color?

     

Sign In or Register to comment.