Re: [osg-users] Help:How to control rasterization stage through osg?
Hi Shuiying 2) geometry shader. You can create one with osg::Shader* sh = new osg::Shader(osg::Shader::GEOMETRY) usage same as with other osg shaders in cpp code 3) If they are supported by your opengl implementation: a) you should use declaration of shader version where they are supported with #version 400 (iirc this is first version with double support in gl core) in your shaders (must be first line on some platforms) OR b) you should enable extension GL_ARB_gpu_shader_fp64 which enables double's support in glsl with #extension GL_ARB_gpu_shader_fp64 : enable Cant say anything about 1st question. Cheers 12.01.2012, 22:14, wang shuiying shuiying.w...@fu-berlin.de: Hi, Thank you all a lot for your help. That really helps me a lot. Now I know that polygon triangulation and rasterization algorithms have something to do with the imperfectness of my programm. I have some other questions: (1) According to triangle raterization function (3.9), p185 in http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf if the eye direction of osg camera is on the same line with the polygon normal vector, there would be less distortion in the generated fragment attributes (in my case, the eyecoord position corresponding to each fragement) than if they are not on the same line. Is the conclusion I said above right? (2) in http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf on P.7, there is a geometry processor, which is notated as a Programmable unit. Is it possible to use this programmable unit as the way vertex and fragment shader are used in open scene graph? (3) also in http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf on P.19, it is said that the variable type include double. But when I change float into double in my shader, the programme doesn't work. Why? It is not possible to use double type in Open scene graph? 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
Re: [osg-users] Help:How to control rasterization stage through osg?
Hi, Thank you all a lot for your help. That really helps me a lot. Now I know that polygon triangulation and rasterization algorithms have something to do with the imperfectness of my programm. I have some other questions: (1) According to triangle raterization function (3.9), p185 in http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf if the eye direction of osg camera is on the same line with the polygon normal vector, there would be less distortion in the generated fragment attributes (in my case, the eyecoord position corresponding to each fragement) than if they are not on the same line. Is the conclusion I said above right? (2) in http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf on P.7, there is a geometry processor, which is notated as a Programmable unit. Is it possible to use this programmable unit as the way vertex and fragment shader are used in open scene graph? (3) also in http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf on P.19, it is said that the variable type include double. But when I change float into double in my shader, the programme doesn't work. Why? It is not possible to use double type in Open scene graph? Thank you in advance! Shuiying ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Help:How to control rasterization stage through osg?
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 interpolationflat - 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 interpolationmain{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. Cheers11.01.2012, 00:57, "wang shuiying" shuiying.w...@fu-berlin.de: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: 16Date: Tue, 10 Jan 2012 15:00:12 -0500From: Jason Daly jd...@ist.ucf.eduTo: OpenSceneGraph Users osg-users@lists.openscenegraph.orgSubject: Re: [osg-users] Help:How to control rasterization stage through osg?Message-ID: 4f0c98cc.8010...@ist.ucf.eduContent-Type: text/plain; charset="ISO-8859-1"; format=flowedOn 01/10/2012 02:55 PM, wang shuiying wrote:Hello,we know that in openGL rendering pipeline, there is a stage calledrasterization after per-vertex operation and before per-fragmentoperation. In rasterization stage, openGl generates certain properties(e.g. texture coordinates)for each fragment as a linear function of theeye-space or object-space or windows space coordinates. My question is, how to check which coordinate is used in osg implementations? And howto 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 listosg-users@lists.openscenegraph.orghttp://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:How to control rasterization stage through osg?
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? Thank you in advance. Best regards Shuiying ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Help:How to control rasterization stage through osg?
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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Help:How to control rasterization stage through osg?
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 Dalyjd...@ist.ucf.edu To: OpenSceneGraph Usersosg-users@lists.openscenegraph.org Subject: Re: [osg-users] Help:How to control rasterization stage through osg? Message-ID:4f0c98cc.8010...@ist.ucf.edu 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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Help:How to control rasterization stage through osg?
On 01/10/2012 03:57 PM, wang shuiying wrote: 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? I don't know of any way to change the rasterization behavior. As far as I know, that's still part of the fixed-function pipeline. I don't think there are even any parameters to control it, outside of the shade model, and anti-aliasing and multisampling parameters. Can I at least get to know, if can not change, the interpolation method used by the openGl in my implemention? Section 3.6 of the current OpenGL specification has all of the equations for this: http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf --J ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Help:How to control rasterization stage through osg?
On 01/10/2012 03:57 PM, wang shuiying wrote: 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? I don't know of any way to change the interpolation functions used for rasterization. As far as I know, that's still part of the fixed-function pipeline. I don't think there are even any parameters to control it, Can I at least get to know, if can not change, the interpolation method used by the openGl in my implemention? Section 3.6 of the current OpenGL specification has all of the equations for this: http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf --J ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Help:How to control rasterization stage through osg?
On 1/10/2012 1:55 PM, Jason Daly wrote: On 01/10/2012 03:57 PM, wang shuiying wrote: Can I at least get to know, if can not change, the interpolation method used by the openGl in my implemention? Section 3.6 of the current OpenGL specification has all of the equations for this: http://www.opengl.org/registry/doc/glspec42.core.20110808.pdf Other sections too, 3.10.1 for example. Try searching the spec for centroid or noperspective; information on shader variable interpolation is scattered around in several places. I'd think simple linear interpolation could be accomplished using the noperspective qualifier: noperspective out vec3 eyeCoord; // for example ...but I haven't played with this. You might consider searching/posting at the opengl.org discussion boards. -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Help:How to control rasterization stage through osg?
On 01/10/2012 04:39 PM, Paul Martz wrote: Other sections too, 3.10.1 for example. Try searching the spec for centroid or noperspective; information on shader variable interpolation is scattered around in several places. I'd think simple linear interpolation could be accomplished using the noperspective qualifier: noperspective out vec3 eyeCoord; // for example ...but I haven't played with this. You might consider searching/posting at the opengl.org discussion boards. Good call, Paul. I don't remember hearing about the interpolation qualifiers. Those are covered in section 4.5 of the GLSL spec... http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.clean.pdf --J ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org