[vtkusers] Scalars and diffuse lighting

Ken Martin ken.martin at kitware.com
Wed Oct 26 09:13:07 EDT 2016


It sounds like something is stuck in a bad state. You could try marking the
property modified after you turn the scalar visibility back off. ala

actor.GetProperty().Modified();

if that doesn't fix it then you could also try forcing the mapper to
rebuild by doing something like

mapper->GetInput()->Modified();

last resort also turn off InterpolateScalarsBeforeMapping and call
actor->ReleaseGraphicsResources(renderWindow);

Hope one of those works for you.

Thanks
Ken



On Fri, Oct 14, 2016 at 4:11 AM, CARD Student <cardstudent at balgrist.ch>
wrote:

> Hi Ken
>
>
> My issue is the following: I have an OpenGl Actor, created like this:
>
>
>             var mapper = vtkPolyDataMapper.New();
>             mapper.SetInput(polyData);
>             mapper.ImmediateModeRenderingOn();
>
>             var actor = vtkActor.New();
>             actor.SetProperty(vtkProperty.New());
>             actor.GetProperty().SetColor(0.5, 0.5, 0.5);
>             actor.GetProperty().SetInterpolationToFlat();
>             actor.GetProperty().SetAmbient(0.45);
>             actor.GetProperty().SetDiffuse(0.55);
>
>
> At this point, the model looks like this:
>
>
>
>
> Then scalars get added:
>
>
>             polyData.GetPointData().AddArray(data);
>             polyData.GetPointData().SetActiveScalars("name");
>             actor.GetMapper().SetScalarMode(1); // this is
> VTK_SCALAR_MODE_USE_POINT_DATA
>             actor.GetMapper().SetInterpolateScalarsBeforeMapping(1);
>             actor.GetMapper().SetScalarVisibility(1);
>
> Then it looks like this (which is fine):
>
>
>
> To disable the scalars again, we do the following:
>
>             actor.GetMapper().SetScalarVisibility(0);
>
> But now, the orignial color is rendered brighter, like this:
>
>
> So my question is, how can I get back to the original state (with the
> darker grey)? I'm stuck using VTK 5.8 since we use the free Kitware ActiViz
> C# wrapper. After some googling I suspected that my problem is related to
> the thread I answered to, but any help is appreciated.
>
> I tried messing with the scalars material mode, resetting the scalars
> using 'polyData.GetPointData().GetScalars().Reset();' and resetting the
> diffuse lighting to 0.55. None of which helped. The current workaround is
> to have separate PolyDataMappers, one with the original state, and another
> where scalars are never set to active. And instead of showing and hiding
> scalars, we swap the mapper. But this seems like a hack...
>
> Best regards,
> Frederik
>
> ------------------------------
> *Von:* Ken Martin <ken.martin at kitware.com>
> *Gesendet:* Donnerstag, 13. Oktober 2016 17:22
> *An:* CARD Student
> *Cc:* vtk
> *Betreff:* Re: [vtkusers] Scalars and diffuse lighting
>
> I am not completely following your issue. But .. if you are using VTK with
> the OpenGL2 back end then the diffuse is based the actor's property when
> scalars are not visible. Note that colors and intensity in the actor's
> property cover a range of 0.0 to 1.0 not 0.0 to 255.0. If you can explain
> your problem a bit more specifically, including what version of VTK you are
> using and what rendering backend, the I might be able to help more.
>
> Thanks
> Ken
>
>
> On Thu, Oct 13, 2016 at 9:28 AM, Zivi, Der <cardstudent at balgrist.ch>
> wrote:
>
>> Hi David
>>
>> Sorry for digging out this ancient post, but I'm now having the same
>> problem.
>>
>> More specifically, I don't mind that the diffuse coefficient is 1 when
>> scalars are shown. But at some point the scalar visibility is reset to 0,
>> but the diffues coefficient stays at 1. How can I switch back to using the
>> diffuse coefficient set in the actor properties?
>>
>> Because the diffuse coefficient is only set to 1 once the active scalar is
>> set, and there is no reset method...
>>
>> Frederik
>>
>>
>>
>> --
>> View this message in context: http://vtk.1045678.n5.nabble.c
>> om/Scalars-and-diffuse-lighting-tp4298628p5740758.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>
>
>
> --
> Ken Martin PhD
> Chairman & CFO
> Kitware Inc.
> 28 Corporate Drive
> Clifton Park NY 12065
> 518 371 3971
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee.  Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message.  Thank you.
>



-- 
Ken Martin PhD
Chairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee.  Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161026/6d240ee3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scalars.PNG
Type: image/png
Size: 59898 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161026/6d240ee3/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: after.PNG
Type: image/png
Size: 14515 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161026/6d240ee3/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before.PNG
Type: image/png
Size: 17654 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161026/6d240ee3/attachment-0005.png>


More information about the vtkusers mailing list