[osg-users] Limit rendering a texture up to a given pixel

Bruno Oliveira bruno.manata.oliveira at gmail.com
Thu Jun 29 02:28:50 PDT 2017


Hello,


I have a big image to be rendered (100k pixels each side), hence I am
partitioning that image in Image Tiles.

Each tile has 256 x 256 pixels. Each tile consists of a osg::Geometry quad,
with a texture bound to it. I put all those tiles in an osg::Group.
I use a fragment shader that is global to all tiles (I apply it to the
osg::Group's StateSet). It is a very simple shader and consists only of a
texture lookup in each tile:

    gl_FragColor = texture2D(texture, vec2(x, y));

The problem now is that in the image limits, some extra pixels are rendered
(because my images' size is not multiple of 256). For instance, if my image
size is 1000 pixels in x, the last 24 pixels are not valid and shall be
transparent (because it will have 4 tiles = 256 * 4 pixels = 1024). The
last tile should only be rendered up to the pixel 232 ( 256 - 24 = 232)

What is the best way of limiting my rendering up to that pixel, WITHOUT
defining a new shader for EVERY tile? ( I really want a single fragment
shader bound to the whole group for performance reasons)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170629/b0aa7b1e/attachment-0001.htm>


More information about the osg-users mailing list