[osg-users] Optimizing texture power of two resizing
168 views
Skip to first unread message
Chris Kuliukas
unread,
Dec 15, 2015, 9:30:55 PM12/15/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to osg-...@lists.openscenegraph.org
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)
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to OpenSceneGraph Users
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.
Chris Kuliukas
unread,
Dec 16, 2015, 9:56:13 PM12/16/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to osg-...@lists.openscenegraph.org
Thanks Robert, that sounds like a better solution.