Skip to content

Fisheye effect #4

Description

@rostidev

I think the formula is incomplete. How I know this? I've ported your demonstration code to C with SDL3 library and made it showing more than one object. In my case there is one penguin and eight cubes - all rotating together. I've also made it rotating round both xz and yz. With more objects the fisheye effect could be seen better.

To workaround the fisheye effect I added a focal distance factor:

point_t project(point3d_t p) {
    const float focal = 2.5f;  // Focal distance of virtual lens
    return (point_t){
        x: (p.x / p.z) * focal,
        y: (p.y / p.z) * focal
    };
}

You can find the whole code of this port in my GitHub: https://github.com/rostidev/formula

It looks like this:

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions