Re: [osg-users] Help: wrong ouput from frag shader

2012-01-19 Thread J.P. Delport
getImplementation); camera->attach(osg::CameraNode::COLOR_BUFFER, image); //read out data osg::Vec4f * rgbaData = (osg::Vec4f *) (image->data()); for (int h = 0; h < yRes; h++) { for (int w = 0; w < xRes; w++) { osg::Vec4f cur = rgbaData[xRes * h + w]; cout<<"cur[0]="<

Re: [osg-users] Help: wrong ouput from frag shader

2012-01-19 Thread wang shuiying
< xRes; w++) { osg::Vec4f cur = rgbaData[xRes * h + w]; cout<<"cur[0]="< } } Thank you for any advice! Shuiying Message: 3 Date: Wed, 18 Jan 2012 09:11:15 +0200 From: "J.P. Delport" To: OpenSceneGraph Users Subject: Re: [osg-users] Help: wrong ouput from frag s

Re: [osg-users] Help: wrong ouput from frag shader

2012-01-18 Thread J.P. Delport
CameraNode::COLOR_BUFFER, image); //read out data osg::Vec4f * rgbaData = (osg::Vec4f *) (image->data()); for (int h = 0; h < yRes; h++) { for (int w = 0; w < xRes; w++) { osg::Vec4f cur = rgbaData[xRes * h + w]; cout<<"cur[0]="< To: OpenSceneGraph Users Subject: Re: [osg-u

Re: [osg-users] Help: wrong ouput from frag shader

2012-01-18 Thread wang shuiying
advice! Shuiying Message: 3 Date: Wed, 18 Jan 2012 09:11:15 +0200 From: "J.P. Delport" To: OpenSceneGraph Users Subject: Re: [osg-users] Help: wrong ouput from frag shader. Message-ID:<4f167093.8090...@csir.co.za> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi,

Re: [osg-users] Help: wrong ouput from frag shader.

2012-01-18 Thread Sebastian Messerschmidt
tryFrag_Color = vec4(abs(dist2/100.0),0,0,1) instead of Frag_Color = vec4(abs(dist2/100),0,0,1); Hello, Sebastian There is also another strange problem . When Vertex shader is as follows: varying out vec3 pos; varying out float dist2; void m

Re: [osg-users] Help: wrong ouput from frag shader.

2012-01-18 Thread wang shuiying
Hello, Sebastian There is also another strange problem . When Vertex shader is as follows: varying out vec3 pos; varying out float dist2; void main() { vec3 pos1 = (gl_ModelViewMatrix * (gl_Vertex - vec4(0.0,0.0,0.0,0.0))).xyz;

Re: [osg-users] Help: wrong ouput from frag shader.

2012-01-18 Thread wang shuiying
Hello, Sebastian Thank you for your reply! In my programme, camera is set to be prerender, render target is FRAME_BUFFER_OBJECT, I attach the camera to an image, in order to get the bufferdata via image. (1) the fragment shader is as following: out vec4 Frag_Color; void main() { F

Re: [osg-users] Help: wrong ouput from frag shader.

2012-01-17 Thread Sebastian Messerschmidt
I suppose you are using a normal framebuffer. I this case it is pretty normal, that your original value that is in the image (you unfortunately didn't tell use if the value comes from a texture) doesn't exactly match the value in the framebuffer. Usually the framebuffer has 8bit per color channe

Re: [osg-users] Help: wrong ouput from frag shader.

2012-01-17 Thread J.P. Delport
Hi, what format is the texture you are rendering to? If it is UNSIGNED CHAR then your data would be discretised. e.g. 45/255 = 0.176471 jp On 17/01/2012 21:11, wang shuiying wrote: Hello, when I write gl_FragColor = vec4(0.174977,0,0,1) in Frag shader, then I get through a related image: f

[osg-users] Help: wrong ouput from frag shader.

2012-01-17 Thread wang shuiying
Hello, when I write gl_FragColor = vec4(0.174977,0,0,1) in Frag shader, then I get through a related image: float Vec4: (0.176471,0,0,1) so why 0.174977 changed into 0.176471? I think there should be no process there after per fragment operations that can change this element in the renderi