# Texture Traget Rectangle?

Hi, is it possible to specify for a image to use a Rectangle as opengl target? so that i can use the pixel coordinates in uv instead of 0-1? As this would save me around 2million divisons in the shader per frame.?

http://www.opengl.org/wiki/Rectangle_Texture

Why is it a division not a multiplication? (imagewidth * uv.x = pixel x)

@zarch said:
Why is it a division not a multiplication? (imagewidth * uv.x = pixel x)
I guess he wants texture coordinate from texel position and not the other way around.

@EmpirePhoenix
AFAIK we don’t support this.
A way to avoid division though is to have a constant 1/imageWidth that is computed once (you can even pass it as a uniform), and then multiply by this value your texel value.
That’s a cheap trick, but multiplication is a lot faster than division.

1 Like

ah ok, i will try this, and see if it makes any difference.

Yes, i have a texel position represeting a height, and need the surrounding values for lod morphing for my terrain system Can you not calculate that in your vertex shader and then have it just interpolated across for the pixel shader? I guess its a little bit tricky to get the vertex shader right - but you need to deal with edge cases anyway (i.e. being at pixel x 0 and wanting to read the pixel left of it).

Edit to add - for surrounding values could just calculate a uOffet and vOffset at each vertex… they will then be interpolated between and it becomes a simple addition/subtraction to get the surrounding pixels in the pixel shader.

Well it is already done in the vertex shader, but with 2m polygons it adds up. It is more complex, since i need different exact hits for the sourrounding vertex positions, and its impossible to directly acess other vertexes from the vertex shader. So basically this is a workaround for a workaround for a workaround. ^^