Coder Social home page Coder Social logo

andrewlowndes / texture-filtering Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 64.69 MB

Texture filtering using triangle summed area maps

Rust 30.62% TypeScript 67.98% JavaScript 1.40%
texture-mapping texture-generation webgl rendering-algorithm summed-area integral

texture-filtering's Introduction

Texture filtering using triangle summed area maps

A new technique for approximating the averaged texels for a polygon over a surface.

Demos

Visit https://andrewlowndes.github.io/texture-filtering/dist/ to see a set of demos showing the various techniques used in this repo.

Run

  1. Ensure NodeJS installed
  2. Run npm i to install dependencies
  3. Run npm start to open the demos in a web app

Roadmap

  • Summed area tables
    • Image lookup (CPU)
    • Fast blur (CPU)
    • Fast blur (GPU)
  • Triangle coverage
    • Exact triangle coverage (CPU)
    • Generator
      • CPU - JS (Slow)
      • CPU - Rust (Still slow for high resolutions)
      • GPU - WebGL (Fast)
    • Approximated triangle fitting (CPU)
  • Triangle summed area tables
    • Generator - WebGL
    • Approximated triangle fitting (CPU)
    • Mipmap 3D comparison

How it works - Triangle summed area maps

  1. A grid is overlaid onto a texture at a specified resolution
  2. Every combination for each vertex for a line is specified for each coordinate on the grid
  3. A triangle is formed from each line with the coordinate at (0, 0)
  4. The accumulative area under each triangle is calculated
    1. The triangle is rasterised
    2. The colour of pixel fully covered within the triangle is added
    3. The boundary pixels are intersected with the triangle and the colour of the pixel is divided by the area of the new shape
    4. The accumulated colour is divided by the area of the triangle
  5. Each triangle colour is store in a texture coordinate

Looking up a triangles averaged colour:

  1. A polygon on the texture surface in 2D is broken down into it's lines
  2. The line is looked up in the triangle summed area map to give the area for the line
  3. Each line area is added or subtracted based on the direction of the line
  4. The total area is then divided by the area of the triangle to give the average colour over the triangle

Usages

  • Render textures in 3D space, where a multiple texels covers a pixel - alternative to mipmapping/anisotropic filtering.

Future development

  1. Generalise to work with vector graphics
  2. Global illumination

Development

Install VS Code and the following extensions:

  • EditorConfig for VS Code
  • ESLint
  • Prettier

texture-filtering's People

Contributors

andrewlowndes avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.