I'm working on taking a picture in 3D model by Nvidia Optix sample. I modified Optix SDK progressivePhotonMap to reach my goal. I have same camera position,same camera direction and same field of view(FOV) in my progressovePhotonMap code and OpenGL code. However, the view of camera are much different from each other, like below.
Output image:
On the left handside is output picture from progressivePhotonMap, the other side is output from OpenGL. You can see the left down power point(indicate by intersection of two red line) are not locate on same position in two pictures.
I know Optix is written base on OpenGL, so I'm very confused why these two pictures(camera view) are not same in same camera parameter.
Here is my thought of the reason:
1.Maybe the problem is near and far parameter, because of displaying frames in GlutDisplay.cpp, the gluPerspective() are useless. I can not give near and far parameter.(even in ppm.cpp)So how and where can I add these two parameter?
2.Maybe optix projection plane is not at near plane? In OpenGL, we can see near plane as projection plane, but not in optix?
3.Maybe the presentation of 3D model in optix is just different from OpenGL??? (I found that these two pictures have different distortion with each other) So I can not avoid this situation?
I traced entire project and didn't find anything useful information, can anyone help me or give some idea/advice about why this situation happen? I will very appreciate any response. Thank you!
There is some short source code, hope it would be helpful.
In OpenGL:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluPerspective(FOV,(GLdouble)windWidth / (GLdouble)windHeight , NEAR, FAR);
gluLookAt(camera_pos[0],camera_pos[1],camera_pos[2],
look_at_target[0],look_at_target[1],look_at_target[2],
up_vector[0], up_vector[1], up_vector[2]);
In optix:
InitialCameraData init_camera;
init_camera = InitialCameraData( make_float3( camera_pos[0], camera_pos[1],camera_pos[2]),make_float3(look_at_target[0],look_at_target[1],look_at_target[2]),make_float3( 0.0f, 1.0f, 0.0f )/*up*/,FOV );
GLUTDisplay::setCamera(init_camera);
signalCameraChanged();
update in 4/21 16:11 Reoutput images
I reoutput pictures and find hfov(horizontal FOV) maybe the reason, it seems in two pictures the height of window are same in my screen.In my knowledgement, hfov and vfov are same in gluPerspective in OpenGL. So I think the hfov is the reason why these two view of camera are different in my optix code.
However,I still don't know how to modify hfov in ppm.cpp. I always think that FOV,which I give to InitialCameraData, can be indicate hfov and vfov. If this idea is wrong, where should I modify hfov? I can only adjust vfov parameter as source code showing. Could anyone,who is familiar with progressivePhotonMap sample, tell me where do I modify hfov? Thanks any response!
The main difference/problem is that in Optix, I do not see a Projection Matrix. At best, I see that Optix sets Field of View at the same time that it sets the camera information, but the lack of an Aspect Ratio parameter troubles me, especially since looking at the Optix image more closely, the chair appears to be greatly distorted in the horizontal axis, which is less of a problem in the OpenGL render (which correctly provides information about the aspect ratio).
The other thing I would observe is that you should check how Optix expects the Field of View parameter to be provided. GLU expects it in Degrees, and is treating it as the y-Field-Of-View. I don't know how Optix expects it, but many APIs expect Field of View to be provided relative to the x-axis.