Problem of environment mapping

Hi, all.

I encounter a odd phenomenon when I make a environment mapping effect on a cube.

It is shown as follow :

[ATTACH=CONFIG]413[/ATTACH]

Does some one encounter same situation as like as mine ?

(P.S I calculate the reflect vector in world matrix, I don’t use the gl_NormalMatrix. My cube only have a translation, no rotation and scale.)

hello
I want from y
to gave me delay instruction in opengl
ex i want to draw sphere in first time then in second time i will draw cube etc.

how can i make this?

[QUOTE=marahalsaidan;1250699]hello
I want from y
to gave me delay instruction in opengl
ex i want to draw sphere in first time then in second time i will draw cube etc.

how can i make this?[/QUOTE]

Does you mean that you want to draw sphere at current frame and then exchange the one to cube at next frame ?

If you want to do this thing, you can use the function glutSolidCube and glutSolidSphere with glut.

you can get the example and specification of those functions in Internet.

Then you can change drawn object by if-else statement in display function.

Hi, all.

Does someone happen the odd situation as like as mine?

[ATTACH=CONFIG]419[/ATTACH]

I attempt to check my matrix, but I think that isn’t related with my problem.

Because I saw my plane looked like two different plane in large reflect angle.

This problem confuse me already two weeks. :confused:

And I have no idea how and what I should check.

My code is as follow :

vertex shader :

varying vec4 object_reflect_dir;

(In calculate world information function)
world_vertex = world_matrix * gl_Vertex;
world_normal = normalize(world_matrix * vec4(gl_Normal,0.0));
(In calculate world eye information function)
world_e = vec4(normalize(eye_position.xyz - world_vertex.xyz),0.0);

(In calculate world reflect dir information function)
vec4 world_reflect_dir = vec4(normalize(reflect((-1.0) * world_e.xyz,world_normal.xyz)),0.0);
object_reflect_dir = normalize(world_reflect_dir);

Fragment Shader :

varying vec4 object_reflect_dir;

(calculate cube map color)

vec4 reflect_pixel_color = textureCube(environment_map,normalize(object_reflect_dir.xyz));

environment_color = reflect_pixel_color;

return environment_color;

Hi, All.

I already solve this problem.

The reason causing the odd situation is that I normalize the vector from world eye position to world vertex position before calculate the reflect vector.

Maybe I should to calculate the mathematics about reflect vector calculating.

I will got my answer afher I understand it.:wink:

Thans a lot.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.