Giter VIP home page Giter VIP logo

Comments (1)

MathiasWorm avatar MathiasWorm commented on May 18, 2024

thank @all-iver

the solution looks like that:

open your shapes.shader file and insert the lines flagged with //Inserted

struct appdata_t {
    float4 vertex : POSITION;
    float4 color : COLOR;
    float2 texcoord : TEXCOORD0;
    UNITY_VERTEX_INPUT_INSTANCE_ID  // Inserted
    };
            
struct v2f {
    float4 pos : SV_POSITION;
    float2 uv : TEXCOORD0;
    float4 modelPos : TEXCOORD1;
    fixed4 color : COLOR;

    UNITY_VERTEX_OUTPUT_STEREO  // Inserted
    };

v2f vert(appdata_t v) {
    v2f o;

    UNITY_SETUP_INSTANCE_ID(v);     // Inserted
    UNITY_INITIALIZE_OUTPUT(v2f, o);    // Inserted
    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);   // Inserted

    o.pos = UnityObjectToClipPos(v.vertex);
    // translate input uv coords (which are from 0 - 1 on either dimension) to something more 
    // useful (-0.5 to 0.5).
    o.uv = v.texcoord.xy - 0.5;
    o.modelPos = v.vertex;
    // hijack modelPos.z to be distance from camera plane since it 
    // isn't being used for anything else.  used for pixel size.
    o.modelPos.z = -UnityObjectToViewPos(v.vertex).z;
    // for Unity versions < 5.4.0f3
    // o.modelPos.z = -mul(UNITY_MATRIX_MV, v.vertex).z;
    o.color = v.color;
    return o;
    }

from shapes2d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.