Dimensions of Sampler2D

Very quick newbie query:
How do I get the pixel dimensions of a Sampler2D in a Fragment shader?

Cheers,

alx

You pass the dimensions as uniforms to the shader :wink:

With SM4.0 you can use textureSize2D(sampler2D sampler, int lod) :smiley:

Hi Zengar,

Thanks for getting back to me!
I was hoping to be able to get the dimensions of the texture in the the shader itself, however, I may have to fall back on the method you suggest.

Cheers,

alx

Hi HexCat,

thanks for your reply.

I don’t think this method works on my system (MacOS X 10.5 ‘Leopard’, Quartz Composer 3.0 development environment, PowerMac G5, GeForce 7800GS graphics card).

Guess I’ll just have to pass the values in from outside the shader (which I can do easily, anyway).

Cheers!

alx

textureSize is part of EXT_gpu_shader4, which the 7800 can’t support.

Cheers arrekkusu,

so much to learn…
:wink:

alx

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.