Re: [osg-users] Help:Is there a way for a single fragment to know its index during per-fragment operation?

2012-01-16 Thread Sergey Polischuk
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" :
> 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>  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


Re: [osg-users] Help:Is there a way for a single fragment to know its index during per-fragment operation?

2012-01-14 Thread Sebastian Messerschmidt

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 0yRes 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] Help:Is there a way for a single fragment to know its index during per-fragment operation?

2012-01-14 Thread wang shuiying

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

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