rectangular textures

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
drhenry
Posts: 16
Joined: Fri Mar 26, 2010 8:03 am

rectangular textures

Post by drhenry »

Hi,

is it possible to use rectangular textures in Irrlicht?
I'd like to use sample2DRect and texture2DRect in my GLSL shader, but texture coordinates seem to be floats in [0,1]x[0,1] instead of integers in [0,texWidth]x[0,texHeight].
I saw in the Irrlicht source code, that textures are always bound by GL_TEXTURE_2D, but GL_TEXTURE_RECTANGLE_ARB seems never been used, is that right?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

That's correct. We don't have support for this extension, and the hope was that NPOT support would become so good that it wouldn't be needed. I guess you'd have to create a new texture creation flag and signal usage of the extension that way. Can you provide an example application which uses Irrlicht's existing API and add comments to the places where you'd like to use a different way? I guess that 3d support at least could be feasible, the 2D and GUI parts are likely to support it less easily.
drhenry
Posts: 16
Joined: Fri Mar 26, 2010 8:03 am

Post by drhenry »

I took the XEffects project by BlindSide (see http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=30631) and wanted to replace SSAO by the way Unity engine does it.
Download my project at
http://rapidshare.com/files/411909598/S ... _forum.zip
It's still in development...blurring is commented out e.g. Maybe there's still a problem with depth and normal encoding/decoding from a single texture.

See SSAO.glsl for the pixel shader, in which I'd like to use a rectangular texture and integer texture coordinate access.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: rectangular textures

Post by Acki »

drhenry wrote:but texture coordinates seem to be floats in [0,1]x[0,1] instead of integers in [0,texWidth]x[0,texHeight].
I'm not sure if you understand texture coordinates !?!?!
well, just in case: ;)
yes, they go from 0.0 to 1.0 !!!
this is a percental value, where 1.0 is 100%
so you would use something like this:

Code: Select all

// get texture coordinate from pixel
f32 toX = texX / texWidth;
f32 toY = texY / texHeight;

// get pixel from texture coordinate
u32 texX = toX * texWidth;
u32 texY = toY * texHeight;
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: rectangular textures

Post by hybrid »

Acki wrote:
drhenry wrote:but texture coordinates seem to be floats in [0,1]x[0,1] instead of integers in [0,texWidth]x[0,texHeight].
I'm not sure if you understand texture coordinates !?!?!
well, just in case: ;)
Just in case you never heard aout teh rectangular texture handling on gfx cards: This is an extension that was developed somewhat before full NPOT handling. It allows to use a texture with arbitrary ratio, but without tiling (and also with some other restrictions). The thing is, that you have to use non-normalized texture coords. That's why a lot of additional stuff needs to happen in the texture classes and in the render methods.
Use google if you need to know more. :)
drhenry
Posts: 16
Joined: Fri Mar 26, 2010 8:03 am

Post by drhenry »

Don't bother, I think I can get along without the rectangular extension. It's just a matter of rewriting some texture access code.
Anyway, thanks for your information, hybrid, about support of rect textures in Irrlicht.
Post Reply