[vtkusers] Scalars and diffuse lighting

CARD Student cardstudent at balgrist.ch
Fri Oct 14 04:11:15 EDT 2016


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:


[cid:d9f17763-1db4-4acb-8505-51aa685ba65c]


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):

[cid:b5c1ab6c-6c84-40df-8cb2-cfbf056fd6f0]

To disable the scalars again, we do the following:

            actor.GetMapper().SetScalarVisibility(0);

But now, the orignial color is rendered brighter, like this:

[cid:585b5372-dfe7-48fa-ac12-f38bbab10bea]

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<mailto: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.com/Scalars-and-diffuse-lighting-tp4298628p5740758.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com<http://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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161014/467cf580/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before.PNG
Type: image/png
Size: 17654 bytes
Desc: before.PNG
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161014/467cf580/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scalars.PNG
Type: image/png
Size: 59898 bytes
Desc: scalars.PNG
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161014/467cf580/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: after.PNG
Type: image/png
Size: 14515 bytes
Desc: after.PNG
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161014/467cf580/attachment-0002.png>


More information about the vtkusers mailing list