GithubHelp home page GithubHelp logo

webgl-matrix-demo's Introduction

webgl-matrix-demo

High Performance Matrix Multiplication Utilizing WebGL.

WebGL provides a way to access the high-performance hardware on your graphics card via Javascript in a web browser.

A vertex shader is used to provide vertex information. For this demo, the vertex shader simply passes through the vertexes for the two triangles that are rendered by the Javascript code.

The fragment shader is a bit more interesting. Fragment shaders are called on each pixel being drawn. This allows us to hang a computation off each pixel in the destination image. In this case, it's just a simply matrix multiply term.

To get the source matrices to the fragment shader, we encode them as floating point data in a texture. If float textures are supported, then this is easy, we just make the red channel of the text be the left hand matrix, and the blue channel be the right hand matrix.

For gpus that don't support float textures, we use two RGBA textures and pass the 32-bit float data in the 4 bytes available in each texel.

When the computation is complete, we extract the bytes and we have our matrix product.

Running on a Radeon 6850, the code gets about 23 GFlops, compared with about 0.6 for Javascript on a Core i7 in Firefox 28.

Click for demo

webgl-matrix-demo's People

Contributors

watmough avatar

Stargazers

Chi-Huang, Lin avatar  avatar Cong-Cong Pan avatar Nathan Rugg avatar Omar Azmi avatar Yicheng Luo avatar The Alchemist avatar Brian Cannard avatar  avatar Andrew Elgert avatar Vinodh Tankasala avatar  avatar 梅洛 avatar Marlon (陈金) avatar Roger Veciana i Rovira avatar gregor avatar Github Notification avatar max avatar Dennis Li avatar Takahiro "Poly" Horikawa avatar Nao Tokui avatar Andrew Boekhoff avatar Paul Ellis avatar Nguyen Huynh avatar Dimitriy avatar  avatar Nikos M. avatar Ricky Reusser avatar Kevin Kwok avatar Bryan Goldstein avatar Nathan Soufflet avatar Felipe Cruz avatar Rob Voss avatar Waylon Flinn avatar Michael Anthony avatar Trausti Kristjansson avatar Nick Desaulniers (paternity leave) avatar nik hanselmann avatar

Watchers

Ming-der Wang avatar Bryan Goldstein avatar  avatar James Cloos avatar Philip Zucker avatar Michael Anthony avatar Athan avatar  avatar  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.