Jump to content

Random link of interest


Jason

Recommended Posts

  • 2 weeks later...
  • 4 months later...
  • 6 months later...
  • 1 month later...
  • 2 months later...
  • 2 weeks later...
  • 1 month later...
  • 1 month later...

@theotheo
vex --
 

/*
 * PROPRIETARY INFORMATION.  This software is proprietary to
 * Side Effects Software Inc., and is not to be reproduced,
 * transmitted, or disclosed in any way without written permission.
 *
 * Produced by:
 *      Side Effects Software Inc
 *      123 Front Street West, Suite 1401
 *      Toronto, Ontario
 *      Canada   M5J 2M2
 *      416-504-9876
 *
 * NAME:        asadlens.vfl ( VEX )
 *
 * COMMENTS:    A simple lens shader to mimic the built-in perspective
 *              camera.  The shader supports curvature and depth of field.
 */

#pragma opname          v_asadlens
#pragma oplabel         "ASAD Lens"

#pragma hint    x       hidden
#pragma hint    y       hidden
#pragma hint    Time    hidden
#pragma hint    dofx    hidden
#pragma hint    dofy    hidden
#pragma hint    aspect  hidden
#pragma hint    P       hidden
#pragma hint    I       hidden

#pragma label   projection      "Projection"
#pragma label   zoom            "Zoom"
#pragma label   curvature       "Lens Curvature"
#pragma label   focus           "Focus Distance"
#pragma label   coc             "Circle Of Confusion"

#pragma choice  projection      perspective "Perspective"
#pragma choice  projection      polar "Polar (panoramic)"
#pragma choice  projection      cylinder "Cylinder (panoramic)"

#pragma range   curvature       -1 1
#pragma range   zoom            0 10
#pragma range   focus           0 10
#pragma range   coc             0 1

#include "math.h"

cvex
asadlens(
        // Inputs
        float x = 0;
        float y = 0;
        float Time = 0;
        float dofx = 0;
        float dofy = 0;
        float aspect = 1;

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

        // Shader arguments
        string projection = "perspective";
        float zoom = 1;
        float curvature = 0;
        float focus = 1;
        float coc = 1;
        )
{
    if (projection == "perspective")
    {
        P = set(-focus*coc*dofx, -focus*coc*dofy, 0);
        I = set(x/zoom, y/(zoom*aspect), 1 + (1 - 2*(x*x + y*y))*curvature);
        I += set(coc*dofx, coc*dofy, 0);
    }
    else if (projection == "polar")
    {
        float   xa = -PI*x;
        float   ya = (0.5*PI)*y;
        float   sx = sin(xa);
        float   cx = cos(xa);
        float   sy = sin(ya);
        float   cy = cos(ya);

        P = 0;
        I = set(cx*cy, sy, sx*cy);
    }
    else if (projection == "cylinder")
    {
        float   xa = -PI*x;
        float   sx = sin(xa);
        float   cx = cos(xa);

        P = set(0, 0.5*y/(zoom*aspect), 0);
        I = set(cx, 0, sx);
    }
}

 

gtff.jpg

Edited by Librarian
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
  • 2 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...