Giter VIP home page Giter VIP logo

Comments (2)

casperhart avatar casperhart commented on August 11, 2024

Some more notes on the shader changes that would be required for a shape aesthetic:

  • In the TS code, the point shape needs to be added as an attribute to the points geometry. I.e. this.points.geometry.setAttribute("shape", ...)
  • In the vertex shaders you would add something like this so that the shape information gets passed through to the fragment shader:
attribute float shape;
varying float vShape;

// in the main() function
vShape = shape;

In the fragment shader, you would add a test to determine whether a pixel should be kept or discarded, based on the value of vShape and gl_PointCoord.

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_PointCoord.xhtml

E.g. for a square, you would not discard any pixels.

For the circles, we currently use:

    // make points circular
    float distance = length(2.0 * gl_PointCoord - 1.0);
    if (distance > 1.0) {
        discard;
    }

For a diamond, maybe something like the following (which I haven't tested):

    // map from [0,1] to [-1, 1]
    float coord = 2.0 * gl_PointCoord - 1.0;
    if (abs(coord.s) + abs(coord.t) > 1.0) {
        discard;
    }

Here's a link to my current branch with the simplified shaders:detourr/shaders.ts at vignette-interactivity · casperhart/detourr (github.com)

from detourr.

Corlio5994 avatar Corlio5994 commented on August 11, 2024

Thanks for all of this, Casper! I worked through the shader tutorial yesterday, and I'll get started on my actual implementation tomorrow. I'll let you know if any issues arise!

from detourr.

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.