Can we get a fisheye lens shader in Karma xpu 1.0

   2418   7   0
User Avatar
Member
10 posts
Joined: June 2009
Offline
Hi, can we make fisheye lens shader working in karma xpu 1.0? since physicallens is working, how to render a 180 degree fisheye image?
Thanks for any help.
User Avatar
Member
10 posts
Joined: June 2009
Offline
Is karma physicallens made with vex? if so, is it posible to add the fisheye mode to it?

#pragma opname          fishLens
#pragma oplabel         "Fisheye Lens"

#pragma hint    x       hidden
#pragma hint    y       hidden
#pragma hint    P       hidden
#pragma hint    I       hidden
#pragma hint   valid   hidden

//CUSTOM
#pragma lable fov    "Fov"
#pragma range  fov   0 180

#include "math.h"

cvex fisheye_lens(
        /*equiangular fisheye lens shader with adjustable FOV and circular image format*/
        
        // Inputs
        float x = 0;
        float y = 0;

        // Outputs
        export vector P = 0;
        export vector I = 0;
        export int valid = 0;

        // Shader arguments
        float fov = 180.0;
        )
{
        float radius = sqrt(x*x+y*y); /*calculate distance from center of image plane*/
        /*following if statement means I is only computed inside r<=1, so that areas of image outside circular format aren't rendered*/
        if (radius <= 1){  /*using 1.0 produces blurriness(bug?), but 1.01 works fine*/
            float phi = atan2(y,x);
            float theta = radians(fov/2.0 * radius);
            I = set(sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta));
            valid = 1;

        }
}
Edited by zzhj - Nov. 9, 2023 03:47:34
User Avatar
Member
8833 posts
Joined: July 2007
Offline
zzhj
Is karma physicallens made with vex? if so, is it posible to add the fisheye mode to it?
I believe only CPU version uses vex, XPU most likely uses equivalent but blackbox shader
So if you modify the VEX shader you are essentially just modifying the CPU version, introducing disparity
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
8045 posts
Joined: Sept. 2011
Offline
zzhj
Hi, can we make fisheye lens shader working in karma xpu 1.0? since physicallens is working, how to render a 180 degree fisheye image?
Thanks for any help.

In Houdini 20, the physical lens shader has all four fisheye projections: Stereographic, Equidistant, Equisolid, and Orthographic. It also has the non-fisheye fisheye "rectilinear" projection for completeness.

Your shader code looks like an equidistant projection since radius maps directly to angle.
Edited by jsmack - Nov. 12, 2023 13:56:00
User Avatar
Member
10 posts
Joined: June 2009
Offline
Thanks for your help, I'll try it out later
User Avatar
Member
10 posts
Joined: June 2009
Offline
I'm trying to render a 150 degree fisheye with the physicallens shader, tweaking the quadratic distortion type(curvature at 0.51), don't know how to match the same result as the equidistant projection(150 degree), the best result I can get is a similar render checking with eye.
Is there any tips? thanks anyway.

Attachments:
test_fisheye.png (1.2 MB)

User Avatar
Member
8045 posts
Joined: Sept. 2011
Offline
They match for me without any additional curvature.

your shader 150º fov:


Karma Physical Lens Polar Equidistant 150º fov:

Attachments:
fishLens.jpg (374.0 KB)
physicalLens.jpg (367.7 KB)
fishLens_test.hip (743.7 KB)

User Avatar
Member
10 posts
Joined: June 2009
Offline
Wow, your sample file helped a lot! thank you
  • Quick Links