Skip navigation
fredo5344
Currently Being Moderated

Change the color of a Texture

Jun 20, 2012 8:40 AM

hello,

 

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?

 

cordially

 
Replies
  • Currently Being Moderated
    Jun 21, 2012 8:38 AM   in reply to fredo5344

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 4:32 AM   in reply to fredo5344

    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;

    mat0.diffuseColor.set(1,0,0);

    mat0.emissiveColor.set(0,0,0);

    scene.ambientIlluminationColor.set(0,0,0);

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points