tatsy / LightField

Light field viewer and virtual light field camera
55 stars 19 forks source link

What are the formulas you used in lightfield.frag? #4

Closed ZHAOZHIHAO closed 5 years ago

ZHAOZHIHAO commented 5 years ago

Thank you for your neat codes.

I would like to modify your codes to be compatible with light field images. But I got irrational results. I guess the reason may be that the way how you get refocused images is not suit for my light field images. Because I think I stored the input data in the codes as the same way you stored the gantry images. Do you still remember the formulas you used in lightfield.frag? A brief reference would be good enough.

tatsy commented 5 years ago

Hi @ZHAOZHIHAO, Actually, I did not refer to any book or paper. The formula that I used in the code is naturally derived from the standard imaging process of the camera.

Anyway, are you sure whether the problem of your images? As far as I know, the program fails to display the light field on some old GPUs, non-power-of-2 image sizes, and non-power-of-2 images for each axis on the 2D image array.

Hope it helps.

ZHAOZHIHAO commented 5 years ago

Hi tatsy,

Thank you very much. I don't think I can figure out this problem without your solution. Your solution works after I cropped my images(for each u and v) to be power-of-2, though my GTX 1070 should not be an old GPU. If I want to load and process a non-power-of-2-size image, what knowledge should I have? In other words, what makes non-power-of-2-size images not work?

tatsy commented 5 years ago

Hi @ZHAOZHIHAO,

I'm happy to hear that your problem is partially solved. I do not surely remember the reason but I think 1070 is new enough to process non-power-of-2 images in the program. Another possibility is that your images are too large to store a large light field texture on the GPU. Please check the maximum 2D texture size of GTX 1070 using OpenGL extension viewer and resize your images to fit the maximum data size. It can possibly solve the problem.

Hope it helps.

ZHAOZHIHAO commented 5 years ago

Hi tatsy,

Thank you for your suggestion. The code works for 128x128 size image and doesn't work for 127x127 size image. So it should not be a problem of how much texture size GTX 1070 can use. By saying "doesn't work", it means that when I load the 127x127 size image, sometimes the code exits with "Segmentation fault (core dumped)" and sometimes a wrong image shows up. I'll try to find the solution by myself if I have to.

Thank you.