Texture gamma

TofusanTofusan Posts: 28

Is there a way to change the gamma value of texture by script?

Comments

  • rbtwhizrbtwhiz Posts: 2,250
    edited July 2015
    // Get the image managervar oImageMgr = App.getImageMgr();// Define the desired gammavar nGamma = 2.2;// Get or create a DzTexture for the image; set gamma if createdvar oTexture = oImageMgr.getImage( "Absolute/path/to/image.ext", nGamma );// If we have a texture and its gamma is not the gamma we wantif( oTexture && oTexture.getGamma() != nGamma ){ // Set its gamma to the desired value oTexture.setGamma( nGamma );}

    -Rob

    Post edited by rbtwhiz on
  • TofusanTofusan Posts: 28
    edited December 1969

    rbtwhiz said:
    // Get the image manager
    var oImageMgr = App.getImageMgr();
    // Define the desired gamma
    var nGamma = 2.2;
    // Get or create a DzTexture for the image; set gamma if created
    var oTexture = oImageMgr.getImage( "Absolute/path/to/image.ext", nGamma );
    // If we have a texture and its gamma is not the gamma we want
    if( oTexture && oTexture.getGamma() != nGamma ){
     // Set its gamma to the desired value
     oTexture.setGamma( nGamma );
    }

    -Rob

    Thank you very much. :D

  • dakkuuandakkuuan Posts: 305

    Is there a way to check a particular node for diffuse textures that aren't at 2.2?  This is probably a basic question but I'll ask since I'm new to Daz Scripting.  

  • Richard HaseltineRichard Haseltine Posts: 100,780

    Once you have the map oTexture.getGamma() will get the gamma. For getting the maps, see http://www.daz3d.com/forums/discussion/57229/

  • rbtwhiz said:
    // Get the image managervar oImageMgr = App.getImageMgr();// Define the desired gammavar nGamma = 2.2;// Get or create a DzTexture for the image; set gamma if createdvar oTexture = oImageMgr.getImage( "Absolute/path/to/image.ext", nGamma );// If we have a texture and its gamma is not the gamma we wantif( oTexture && oTexture.getGamma() != nGamma ){ // Set its gamma to the desired value oTexture.setGamma( nGamma );}

    -Rob

    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?

     

    Thnx Rob

  • rbtwhiz said:
    // Get the image managervar oImageMgr = App.getImageMgr();// Define the desired gammavar nGamma = 2.2;// Get or create a DzTexture for the image; set gamma if createdvar oTexture = oImageMgr.getImage( "Absolute/path/to/image.ext", nGamma );// If we have a texture and its gamma is not the gamma we wantif( oTexture && oTexture.getGamma() != nGamma ){ // Set its gamma to the desired value oTexture.setGamma( nGamma );}

    -Rob

    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?

     

    Thnx Rob

    You'd get the image from the property, then use Rob's code to get its gamma.

Sign In or Register to comment.