PDA

View Full Version : textureRect (again)



mikef
07-14-2005, 05:50 AM
Hello,

Does anyone know how I go about writing portable GLSL that uses texture rectangles?

Tex-rects work ok in current nVidia drivers but in a way that contradicts the GLSL spec, so I don't have much faith that this won't change. Plus, the fact that the GLSL portion of the ARB/NV tex rect spec is basically nonsense doesn't help matters.

Any suggestions?

yooyo
07-14-2005, 06:29 AM
Hmm.. Use regular sampler2DRect and texture2DRect.

Can you explain, why NVidia tex-rects is contradict to GLSL spec?

This shader work properly:

uniform sampler2DRect tex0;

void main(void)
{
gl_FragColor = texture2DRect(tex0, gl_TexCoord[0].st);
}yooyo

Relic
07-14-2005, 07:48 AM
According to the ARB_texture_rectangle spec it should be

uniform samplerRect tex0;
void main(void)
{
gl_FragColor = textureRect(tex0, gl_TexCoord[0].st);
}

yooyo
07-14-2005, 10:27 AM
According to GLSLangSpec.Full.1.10.59.pdf reserved keywords are: sampler2DRect sampler3DRect sampler2DRectShadow

Something is wrong...

yooyo

mikef
07-14-2005, 03:45 PM
Originally posted by yooyo:
According to GLSLangSpec.Full.1.10.59.pdf reserved keywords are: sampler2DRect sampler3DRect sampler2DRectShadow

Something is wrong...

yooyoYep. Sorry, I should have been more specific in my post: Basically, the extension spec, the GLSL spec and the only implementation I've got access to all contradict each other.

The ext spec
- probably has the names textureRect/samplerRect wrong
- restricts the texcoord parameter to textureRect() to a single float(!)
- makes no mention of the #extension directive
- defines samplerRectShadow, but no function for actually using it
- describes itself as functionally identical to EXT_texture_rectangle, when in fact that extension has no GLSL support at all

Plus, the GLSL section is pretty bare; extensions usually add language to the spec instead of just dropping in the new keywords.

The GLSL spec says that any new extension functionality must be explicitly enabled with the #extension directive; the nv driver ignores this, and just puts some new keywords into the global namespace. Keywords which, I might add, don't follow the GLSL extension naming rules. Further, if you add
#extension ARB_texture_rectangle : require
to a shader, the driver barfs complaining of an unsupported extension.

So sorry for whinging; I'm finding texture-rects incredibly useful, and I'm loving what they can do in combination with GLSL, FBO and PBO. But I'd like to know how to write code that will work on other hardware as opposed to code that happens to work ok on the machine I've got, and that it won't break if/when the spec gets fixed.