[osg-users] Optimizing texture power of two resizing

Robert Osfield robert.osfield at gmail.com
Wed Dec 16 00:27:00 PST 2015


Hi Chris,

On modern graphics cards you can change the osg::Texture
ResizeNonPowerOfTwoHint setting so that non power of two textures are
passed to the GL driver without resizing.  From the include/osg/Texture
header:

         /** Sets whether to force the texture to resize images that have
dimensions
          * that are not a power of two. If enabled, NPOT images will be
resized,
          * whether or not NPOT textures are supported by the hardware. If
disabled,
          * NPOT images will not be resized if supported by hardware. */
        inline void setResizeNonPowerOfTwoHint(bool flag) {
_resizeNonPowerOfTwoHint = flag; }


Another alternative is to simply pre-process the osg::Image by rescaling
them with a custom visitor that is applied to a newly loaded subgraph that
does the reszie - there should be no need to hack osg::Image to this.

Robert.


On 16 December 2015 at 02:34, Chris Kuliukas <chris at kuliukas.com> wrote:

> Hi,
>
> We've had some troubles with stuttering when going from one screen to
> another, and a big part of the problem seems to be that we have textures
> that aren't to the power of two and need to be resized.
>
> This resize happens right at the last minute before the data is sent to
> the graphics card, and it happens every time the texture needs to be
> reloaded.
>
>
> I hacked osg/Image.cpp Image::setImage so that images are resized as they
> are loaded instead, but I had to set it to only resize images with a width
> above 50 so that it doesn't resize font textures, which causes an exception.
>
> This does seem to be having a positive effect and working fine, but it
> also feels like a hack. I'm wondering how would someone who knows OSG well
> do this? Or if there's some other alternative I haven't thought of?
>
> (Resizing all the textures offline would be ideal, but would take too long
> given the amount of models we use and import)
>
>
> Thank you!
>
> Cheers,
> Chris
>
> ------------------------
> http://www.hrwallingford.com/facilities/ship-simulation-centre (
> http://www.hrwallingford.com/facilities/ship-simulation-centre)
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65877#65877
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151216/d596ca7e/attachment-0002.htm>


More information about the osg-users mailing list