Menu

How to use diffuse vertex colors

2006-06-26
2013-05-28
  • Peter Ernst

    Peter Ernst - 2006-06-26

    Hi,

    I'm trying to find a way to get diffuse vertex colors to show up int the model. This is what I tried so far:

    1. Assign a vertex color to all faces in the facetted model:

    IFXVector4 diffuseColor(0.0f,1.0f,0.0f,1.0f);
    authorMesh->SetSpecularColor(0,&diffuseColor);

    IFXAuthorFace diffuseFace;
    diffuseFace.Set(0,0,0);

    for (int i = 0; i < nFacetts; i++)
    {
      authorMesh->SetDiffuseFace(i,&diffuseFace);
    }

    2. to get the shader to display the diffuse green
    color, I tried:

    shader->SetChannels(0x00000001);
    shader->SetBlendFunction(0,IFXShaderLitTexture::BlendFunction::BLEND);
    shader->SetBlendConstant(0,0.0f);
    shader->SetUseDiffuse(TRUE);

    No luck! Only the shader's color shows up.

    Could you please give me some idea what is going wrong?
    I am using the RTL from U3D_A_060322_2.

    Thanks in advance,

    Peter

     
    • Roman Borisov

      Roman Borisov - 2006-06-26

      Hello,
      Try to follow next recommendations:

      1.
      Use SetDiffuseColor instead of SetSpecularColor

      2.
      IFXRenderMaterial& rRenderMaterial = pShader->GetRenderMaterial();
      rRenderMaterial.SetUseVertexColors( TRUE );

      See how IDTFConverter converts "teapot" model in VertexColor.idtf
      The main samples we distribute now are SamplePlayer and IDTFConverter with set of scenes in .idtf (text) format.

      Thanks,
      Roman

       
    • Peter Ernst

      Peter Ernst - 2006-06-27

      Thanks Roman,

      this got me a bit further... Sorry, about the silly mistake in 1.)

      However, this is, as you may have guessed, is not the only challenge with the U3D library, I'm facing at the moment, so I wonder how to proceed.

      I'm trying to implement a high quality U3D export from a CAD system, and find myself headscratching a lot. I'm trying to use the ECMA specs, and the code docs and reverse engineering the sample code. Still there is a lot (actually a hell of a lot ;-) of experimentation required. I wonder how I can make better progress.

      Would it be ok to ask more questions in this forum?

      Could you recommed other information sources about U3D?

      What do you think?

      Regards,

      Peter

       
      • Roman Borisov

        Roman Borisov - 2006-06-27

        Peter,
        you are on the right way :)

        Specs, Docs, SampleSoftware and this forum's mission is to help you make better progress in U3D format adoption.

        Thanks,
        Roman

         
    • ams

      ams - 2009-06-23

      I am also trying to use vertex colors, but I would like to use both diffuse and specular colors for each vertex.  I can get the diffuse ones to work, but the specular color does not seem to have any effect.  I assumed that you would have to do the same thing as with diffuse colors, like:

      IFXVector4 diffuseColor(0.0f,1.0f,0.0f,1.0f);
      IFXVector4 specularColor(0.0f,1.0f,0.0f,1.0f);
      authorMesh->SetDiffuseColor(0,&diffuseColor);
      authorMesh->SetSpecularColor(0,&specularColor);

      IFXAuthorFace diffuseFace;
      diffuseFace.Set(0,0,0);
      IFXAuthorFace specularFace;
      specularFace.Set(0,0,0);

      for (int i = 0; i < nFacets; i++)
      {
      authorMesh->SetDiffuseFace(i,&diffuseFace);
      authorMesh->SetSpecularFace(i,&specularFace);
      }

      but nothing changes.  Is there something special you have to do in order for specular colors to be displayed?

       
    • ams

      ams - 2009-06-25

      Never mind, I think I know why it is not working now.  I am loading my u3d files into Adobe Reader and I see from posts in other threads of this forum that when you use per vertex coloring, lighting is disabled so the specular colors will not appear.

       
  • Ashish S

    Ashish S - 2010-03-10

    One thing I have notice that, when I export diffuse vertex colors to .pdf and open it into pdf viewer, it doesn't show color interpolation. There are changes in lighting of the shell.
    Interestingly when I keep 'model render mode' to 'vertices', the vertices appear with applied color.
    This means that the vertex colors are getting exported correctly, but either some setting is missing on my side, or pdf is not able to interpolate the vertex colors on faces.
    Does anybody know about this more?

    Thanks,

    Ashish.

     

Log in to post a comment.