I have used all the shaders as it is.

And I have mode sure there are no shader compiling issues.

And also there is no glGetError issues.

And I have a loaded a completely different model(a car model of triangles only) using glDrawElements.

It is not working.

I have started learning the shaders now only.

Can some one help me on this why my code will not work.

I can provide any data or even my code also if you have any doubts or if you want any info. ]]>

My dynamic data array of

Code :

osg::ref_ptr<osg::Image> image = new osg::Image;
image->setImage(myVec3Array->size(), 1, 1, GL_RGBA8, GL_RGBA, GL_FLOAT, (unsigned char*) &myVec3Array[0], osg::Image::NO_DELETE);
// Pass the texture to GLSL as uniform
osg::StateSet* ss = scene->getOrCreateStateSet();
ss->addUniform( new osg::Uniform("vertexMap", texture) );

For now, I would like to retrieve my raw array of

Thanks in advance. ]]>

My goal is to simulate the reverberation process for an acoustic sensor as follows: primary reflections by rasterization; and secondary reflections by ray tracing. When a ray hits the object's surface, the distance and normal values are measured.

My scene with all objects is modeled using OpenSceneGraph, and I have used GLSL to handle the normal and position data from the viewpoint on GPU.

Follows below my current GLSL code. At this moment, I am able to calculate the ray parameters (world position and direction vector values, for each pixel), however I do not know how to calculate the data when a ray hits a surface.

Thanks in advance. Any help is very much welcome.

Code :

#version 130
uniform mat4 osg_ViewMatrixInverse;
out vec3 positionEyeSpace;
out vec3 normalEyeSpace;
uniform vec3 cameraPos;
// ray definition, with an origin point and a direction vector
struct Ray {
vec3 origin;
vec3 direction;
};
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// world space
mat4 modelWorld = osg_ViewMatrixInverse * gl_ModelViewMatrix;
vec3 positionWorldSpace = vec3(modelWorld * gl_Vertex);
vec3 normalWorldSpace = mat3(modelWorld) * gl_Normal;
// eye space
positionEyeSpace = vec3(gl_ModelViewMatrix * gl_Vertex);
normalEyeSpace = gl_NormalMatrix * gl_Normal;
// calculate the reflection direction for an incident vector
vec3 I = normalize(positionWorldSpace - cameraPos);
vec3 N = normalize(normalWorldSpace);
vec3 reflectedDirection = normalize(reflect(I, N));
}

Code :

#version 130
in vec3 positionEyeSpace;
in vec3 normalEyeSpace;
uniform float farPlane;
uniform bool drawNormal;
uniform bool drawDepth;
out vec4 out_data;
void main() {
vec3 nNormalEyeSpace = normalize(normalEyeSpace);
vec3 nPositionEyeSpace = normalize(-positionEyeSpace);
float linearDepth = sqrt(positionEyeSpace.x * positionEyeSpace.x +
positionEyeSpace.y * positionEyeSpace.y +
positionEyeSpace.z * positionEyeSpace.z);
linearDepth = linearDepth / farPlane;
// output the normal and depth data as matrix
out_data = vec4(0, 0, 0, 1);
if (linearDepth <= 1) {
if (drawNormal) out_data.z = abs(dot(nPositionEyeSpace, nNormalEyeSpace));
if (drawDepth) out_data.y = linearDepth;
}
gl_FragDepth = linearDepth;
}