[vtkusers] VTK 6.3 OpenGL2 - vtkTextActor blurred text when used with vtkFixedPointVolumeRayCastMapper
Simon ESNEAULT
simon.esneault at gmail.com
Mon Nov 16 06:08:44 EST 2015
Hello,
Trying to solve this problem, I found out that if one call
"vtkFreeTypeTools::GetInstance()->DebugTexturesOn();" before to render a
string with a vtkTextActor, the text is properly rendered with a yellow dot
at the anchor point, and with a transparent gray background.
- DebugTexturesOn : http://picpaste.com/pics/Blurred.1447668943.PNG
- DebugTexturesOff : http://picpaste.com/pics/Not-Blurred.1447669009.PNG
Now digging into the code in vtkFreeTypeTools.cxx, I suspect this is a
blending problem. When we activate Texture Debugging, a gray background is
first drawn, and after that in the method RenderCharacter( ... ) line 1887;
we either blend the rendered text with the background or not.
Attached is a diff file that solves the problem for me. I do not really
understand why, so maybe a developer with more VTK's knowledge can
integrate this properly :)
Thanks,
Simon
2015-11-13 16:43 GMT+01:00 Simon ESNEAULT <simon.esneault at gmail.com>:
> Hi All,
>
> All vtkTextActor are rendered blurred when using with
> vtkFixedPointVolumeRayCastMapper in the same renderer in vtk 6.3 with the
> new rendering backend.
>
> Here are some snapshots :
> - OpenGL1 <http://picpaste.com/pics/OGL1-not-blurred.1447428990.png>
> - OpenGL2 <http://picpaste.com/pics/OGL2-blurred.1447429027.png>
>
> Attached some code that reproduces the problem, to be used with this
> <https://www.dropbox.com/s/ptqwi0ebv75kt35/volume.zip> volume. Visible on
> OSX and Windows to our knowledge, probably on more OS.
>
> The text is rendered properly when used with the old backend or when using
> a vtkGPUVolumeRayCastMapper instead of the vtkFixedPointVolumeRayCastMapper.
>
> Shall I feel a bug, is this a known issue ?
>
> Thanks,
> Simon
>
> --
> ------------------------------------------------------------------
> Simon Esneault
> Rennes, France
> ------------------------------------------------------------------
>
--
------------------------------------------------------------------
Simon Esneault
Rennes, France
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151116/516ed6cf/attachment.html>
-------------- next part --------------
--- a/Rendering/FreeType/vtkFreeTypeTools.cxx Mon Nov 16 12:00:48 2015
+++ b/Rendering/FreeType/vtkFreeTypeTools.cxx Mon Nov 16 11:59:16 2015
@@ -1974,14 +1974,14 @@
}
else
{
- *ptr = fgRGB[0];
- ++ptr;
- *ptr = fgRGB[1];
- ++ptr;
- *ptr = fgRGB[2];
- ++ptr;
- *ptr = static_cast<unsigned char>((*glyphPtr) * fgA);
- ++ptr;
+ const float fg_blend = fgA * (*glyphPtr / 255.f);
+
+ ptr[0] = static_cast<unsigned char>(fg_blend * fgRGB[0]);
+ ptr[1] = static_cast<unsigned char>(fg_blend * fgRGB[1]);
+ ptr[2] = static_cast<unsigned char>(fg_blend * fgRGB[2]);
+ ptr[3] = static_cast<unsigned char>(fg_blend * 255.f);
+
+ ptr += 4;
}
++glyphPtr;
}
More information about the vtkusers
mailing list