3 Replies Latest reply on Jun 25, 2012 4:32 AM by Dave Merchant

    Change the color of a Texture




      I have in my 3Dpdf, a cube on which a texture is applied.


      I can make a change of color of this texture using the following script:


      mat0 c3d.scene.materials.getByName = ("name");

      if (mat0)


      mat0.emissiveColor.set (0.521569,0.639216,0.482353);



      The problem with this method is when I use special lighting in more in my scene (spot light) with this script, the color reflected on the cube have not the "right shade" and is not uniform. I think there is a conflict between the emissive and the light source.


      I try using "diffuseColor" but nothing happens!


      Is it possible to color my cube and texture using a JavaScript?

      If so, how?



        • 1. Re: Change the color of a Texture
          Dave Merchant MVP & Adobe Community Professional

          Lighting in the scene will always affect the colors of objects, that's part of the 3D experience.

          • 2. Re: Change the color of a Texture
            fredo5344 Level 1



            Yes, i know that lightning in 3D scene is an hard part !


            But is it possible or not to change the color of an object that is textured with other ways than by using the following script?


            mat0 c3d.scene.materials.getByName = ("name");

            if (mat0)


            mat0.emissiveColor.set (0.521569,0.639216,0.482353);



            In fact , i research a mean  to change the object color. I research the method that would be less interference with the light in my 3D scene and that enable to have the correct RGD render.



            • 3. Re: Change the color of a Texture
              Dave Merchant MVP & Adobe Community Professional

              To change the apparent colors of a 3D mesh you have to use scripting as in your example, but you must be aware of the interaction between the material and scene shaders if you want to get a specific effect. There are no other ways to modify textures in a 3D scene, other than in the 3D application which created the file in the first place. Remember that the 3D viewport is not intended to display managed colors so getting an exact RGB value on screen is very difficult - the normal color-management rules of PDF do not apply to rich media annotations.



              If you have an object with some random material shader and want it to appear 'flat' red, I would typically run a zero-point function against the material and scene:


              mat0.specularStrength = 0;

              mat0.reflectionStrength = 0;

              mat0.ambientTexture.image = undefined;

              mat0.diffuseTexture.image = undefined;

              mat0.emissiveTexture.image = undefined;

              mat0.specularTexture.image = undefined;

              mat0.reflectionTexture.image = undefined;




              scene.lightScheme = "cad";



              If the material has a texture applied to a shader slot, it will completely override  the colors defined in the same shader slot unless the texture.amount is less than 1; so if for example you have a teapot with a brick pattern in the diffuseTexture slot and you change the diffuseColor to green, nothing will happen. Set diffuseTexture.amount = 0.5 and you'll get green bricks, set it to 0 and the bricks vanish to leave a plain green teapot.