Hi

If that makes any difference, by default coordinates contained in gl_FragCoord 
point to pixel center, so for leftmost-bottom pixel you will get (0.5, 0.5). If 
you need integer value you'll get correct result with 
ivec2(floor(gl_FragCoord.xy))

Cheers

14.01.2012, 23:57, "Sebastian Messerschmidt" <sebastian.messerschm...@gmx.de>:
> Hi Shuiying,
>
> The fragments coordinates(or index as you call it) can be accessed via
> gl_FragCoord. This will give unnormalized device coordinates (i.e.
> [0,xRes] [0,yRes]) which are also called window relative coordinates
> If you pass your screen resolution as uniform vec2 you can normalize
> them to device coordinates easily.
>
> cheers
> Sebastian
>
>>  Hello,
>>
>>  In fragment shader, I would like to chage the fragment colour
>>  according to the fragment's index. Here index means integer number
>>  pair(x,y), where 0<x<xRes, 0<y<yRes, provided that viewPort has xRes *
>>  yRes pixels.
>>
>>  Is there a way to achieve that?
>>
>>  Thank you in advance!
>>
>>  Shuiying
>>  _______________________________________________
>>  osg-users mailing list
>>  osg-users@lists.openscenegraph.org
>>  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to