Hi, Shuiying
There are three interpolation qualifiers which states how values would be interpolated between vertex (or geometry) -> fragment shaders (no FFP here, sry)
no qualifier - perspective corrected interpolation
flat - no interpolation, value taken from 1st(?) vertex of poly (iirc)
noperspective - interpolation linear in screen space (you are rarely, if ever, want to use this)
centroid - have any effect only when using multisampling, on primitive edges. This gurantees that value interpolated for coord which lies whithin rasterized fragment and inside primitive being rendered.
so by default if you write in vertex shader:
out vec3 eyeSpaceCoord;//so we use default interpolation
main{
eyeSpaceCoord = gl_ModelViewMatrix * gl_Vertex;// that is eye-space coord
...
}
in fragment shader eyeSpaceCoord input variable would contain correct eye-space position of fragment(linearly interpolated in eye space), which is what you want, if i understand you correctly.
Cheers
11.01.2012, 00:57, "wang shuiying" <[email protected]>:
Hi,
To Jason Daly,
Thank you for your reply.
In my case, I record positions of the vertexes in eye coordinate in vertex shader, and I want the rasterization to perform the linear interpolation function with eye coordinate so that I can get the position value of certain "vertex produced by interpolation".
In a nutshell, I want to change the way how opengl interpolates such attributes as those defined by "varying variables" in vertex shader.
So from your reply, only texture coordinates can be generated in different ways. As to general attributes, one has no way to change the interpolation method performed on them?
Can I at least get to know, if can not change, the interpolation method used by the openGl in my implemention?
Thank you.
Shuiying
Message: 16
Date: Tue, 10 Jan 2012 15:00:12 -0500
From: Jason Daly <[email protected]>
To: OpenSceneGraph Users <[email protected]>
Subject: Re: [osg-users] Help:How to control rasterization stage
through osg?
Message-ID: <[email protected]>
Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
On 01/10/2012 02:55 PM, wang shuiying wrote:Hello,
we know that in openGL rendering pipeline, there is a stage called
rasterization after per-vertex operation and before per-fragment
operation. In rasterization stage, openGl generates certain properties
(e.g. texture coordinates)for each fragment as a linear function of the
eye-space or object-space or windows space coordinates. My question is
, how to check which coordinate is used in osg implementations? And how
to change the coordinate that is used?The per-fragment attributes you're talking about are just interpolated
from the same attributes that are assigned to the surrounding vertices.
AFAIK, there's no way to change how these are computed, even with
shaders (they're just simple linear interpolations).
It sounds like you might actually be talking about TexGen (texture
coordinate generation), which in the fixed-function world can be set to
OBJECT_LINEAR, EYE_LINEAR, SPHERE_MAP, NORMAL_MAP, or REFLECTION_MAP.
TexGen will automatically compute the texture coordinates on the
vertices (which will then be interpolated for each fragment, as
mentioned above). In OSG, the TexGen StateAttribute controls texture
coordinate generation. If you're using shaders, it's up to you to do
the texture coordinate generation math yourself.
--"J"_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

