[vtkusers] flat shading in vtk

David Doria daviddoria+vtk at gmail.com
Wed Jan 27 09:54:33 EST 2010


On Mon, Jan 25, 2010 at 4:55 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> Oh, that's what you meant. Set "Ambient" to 1, and set "Diffuse" and
> "Specular" to 0.  That should completely eliminate all directional
> lighting.
>
>   David
>
>
> On Mon, Jan 25, 2010 at 2:43 PM, Liam Kurmos
> <quantum.leaf at googlemail.com> wrote:
>> On Mon, Jan 25, 2010 at 9:18 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>> Try property->SetInterpolationToFlat().
>>
>> That produced flat shading, but the shading is still dependant on the
>> surface normals. (just not interpolated/smoothed like gourad).
>> What i want is a constant colour. Obviously that will mean object
>> won't look very 3d but that is what i want in this case (i want to
>> measure how much area of an object i can see by how many pixels of its
>> colour i can count in the render window)
>>
>> I thought property->ShadingOff()/SetShading(0) sounded promising but
>> they don't seem to be having any effect (i have a coloured sphere and
>> it still gourad shaded).
>>
>> Also, I managed to turn the lights of with
>> ren1->SetAutomaticLightCreation(0);
>> but then i discovered there isn't an 'emissive color' property in vtk.
>>
>> Liam
>>
>>
>>
>>>
>>>  David
>>>
>>> On Mon, Jan 25, 2010 at 2:05 PM, Liam Kurmos
>>> <quantum.leaf at googlemail.com> wrote:
>>>> Is there an easy way to disable shading in vtk?
>>>> I want all pixels drawn for a polygon to be constant colour,
>>>> independent of surface normals.
>>>>
>>>> I'm going to try having only an emissive color and turning off a
>>>> lights, but now i'm stuck turning off the default light.
>>>>
>>>> ren1->RemoveAllLights();
>>>>
>>>> doesn't seem to be having any effect.
>>>>
>>>> searches like
>>>>
>>>> "site:vtk.org/Wiki/VTK/Examples getLights"
>>>>
>>>> are coming up blank, so i wonder if i'm on the right track.
>>>>
>>>> any help much appreciated,
>>>>
>>>>
>>>> Liam

Here is a demo:

http://www.vtk.org/Wiki/VTK/Examples/Visualization/FlatShading2

SetDiffuse(0) and SetSpecular(0) make the actor black, but adding
SetAmbient(1) makes it so bright that it is just a white window!
SetAmbient(.5) seems to do the trick.

Thanks,

David



More information about the vtkusers mailing list