[vtk-developers] Bug in scalar color mapping?

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Tue Sep 9 11:13:48 EDT 2014


Here's my test script. With the patch applied, I don't see the ambient
and diffuse colors bleed in anymore.

On Tue, Sep 9, 2014 at 11:11 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> I added SetScalarMaterialModeToAmbientAndDiffuse() and applied the
> patch, but it had no effect.  The results were exactly the same as in
> my first email.
>
> I'll have to look through the code to figure out what the intended behaviour is.
>
>  - David
>
> On Tue, Sep 9, 2014 at 8:56 AM, Utkarsh Ayachit
> <utkarsh.ayachit at kitware.com> wrote:
>> Doh! Here you go.
>>
>> On Tue, Sep 9, 2014 at 10:53 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>>> Hi Utkarsh,
>>>
>>> The "attached patch" seems to be missing.
>>>
>>>  - David
>>>
>>> On Tue, Sep 9, 2014 at 8:44 AM, Utkarsh Ayachit
>>> <utkarsh.ayachit at kitware.com> wrote:
>>>> David,
>>>>
>>>> Try the attached patch and then set
>>>> SetScalarMaterialModeToAmbientAndDiffuse() on the mapper.
>>>> ScalarMaterialMode is the thing here. When set to
>>>> SetScalarMaterialModeToDefault(), which is the default, it determines
>>>> which material component should track the scalar color based on which
>>>> coefficient is greater (see vtkOpenGLScalarsToColorsPainter.cxx:175).
>>>> The patch fixes an issue where the painter was not respecting the
>>>> material mode set on the mapper.
>>>>
>>>> Utkarsh
>>>>
>>>> On Mon, Sep 8, 2014 at 8:15 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>> Hi Utkarsh,
>>>>>
>>>>> Thanks for the reply.  If I use this:
>>>>>
>>>>>   mapper->InterpolateScalarsBeforeMappingOff();
>>>>>
>>>>> then the result is exactly the same as it was before I reverted that commit.
>>>>>
>>>>>
>>>>> If I use this:
>>>>>
>>>>>   mapper->InterpolateScalarsBeforeMappingOn();
>>>>>
>>>>> then the result looks like the attached image, i.e. like it did in my previous
>>>>> email with property->SetAmbient(0.49), property->SetDiffuse(0.51), but when
>>>>> I reverse these I don't get the greyscale ambient lighting like in the
>>>>> right side
>>>>> of the image from my previous email.
>>>>>
>>>>>
>>>>> Still, I don't get what I expect unless I set one of either the ambient or the
>>>>> diffuse coefficient to zero.  Whenever they are both nonzero, I get the wrong
>>>>> result.
>>>>>
>>>>>  - David
>>>>>
>>>>>
>>>>> On Mon, Sep 8, 2014 at 5:17 PM, Utkarsh Ayachit
>>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>>> This sounds familiar.
>>>>>>
>>>>>> Can you try reverting the following commit and see if that makes any difference:
>>>>>>
>>>>>> commit daf8c6e76ec7bb02f56dda17ce260141b7e960a5
>>>>>> Author: Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
>>>>>> Date:   Fri Jul 18 15:30:37 2014 -0400
>>>>>>
>>>>>>     BUG #14828: Keep surface color from interacting with scalar color.
>>>>>>
>>>>>>     When using scalar coloring, if vtkScalarsToColorsPainter decided to use
>>>>>>     a texture for mapping the scalars to colors, we ended up with the
>>>>>>     surface color bleeding through the texture. This commit ensures that
>>>>>>     such bleeding is avoided.
>>>>>>
>>>>>>     We don't simply use glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
>>>>>>     GL_REPLACE), since that results in the diffuse highlights being lost.
>>>>>>     By enabling GL_COLOR_MATERIAL and calling glColor3f(1,1,1), we follow
>>>>>>     the same lighting/coloring path as we would when not using the texture
>>>>>>     for scalar coloring.
>>>>>>
>>>>>>     Change-Id: I9c4db15dd0db699d5d045fa7ae27696d18828988
>>>>>>
>>>>>>
>>>>>> Utkarsh
>>>>>>
>>>>>> On Mon, Sep 8, 2014 at 4:55 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>>>> Any comments on the "scalar color mapping" problem that I sent to the
>>>>>>> list last week?
>>>>>>>
>>>>>>>  - David
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Sep 4, 2014 at 5:33 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>>>>>>> I've run into very odd behavior when I use Ambient and Diffuse
>>>>>>>> coefficients in combination with vtkDataSetMapper.  This is with
>>>>>>>> VTK master.
>>>>>>> [ snip ]
>>>>>>> _______________________________________________
>>>>>>> Powered by www.kitware.com
>>>>>>>
>>>>>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>>>>>
>>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>>>>>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScalarColors.py
Type: text/x-python
Size: 2646 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20140909/ec89321a/attachment-0002.py>


More information about the vtk-developers mailing list