All Projects → vaneenige → Phenomenon

vaneenige / Phenomenon

Licence: mit
⚡️ A fast 2kB low-level WebGL API.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Phenomenon

Glchaos.p
3D GPUs Strange Attractors and Hypercomplex Fractals explorer - up to 256 Million particles in RealTime
Stars: ✭ 590 (-61.96%)
Mutual labels:  webgl, rendering, particles, gpu
Simplerenderengine
Small C++14 render engine
Stars: ✭ 253 (-83.69%)
Mutual labels:  webgl, shaders, rendering
MoravaEngine
2D/3D graphics engine written in C++ language. It currently supports the following graphics APIs: OpenGL 3.3+, Vulkan 1.2, DirectX 11. Its current purpose is to experiment with various CG concepts and techniques.
Stars: ✭ 129 (-91.68%)
Mutual labels:  shaders, rendering, particles
Fsynth
Web-based and pixels-based collaborative synthesizer
Stars: ✭ 146 (-90.59%)
Mutual labels:  webgl, shaders, gpu
Webglstudio.js
A full open source 3D graphics editor in the browser, with scene editor, coding pad, graph editor, virtual file system, and many features more.
Stars: ✭ 4,508 (+190.65%)
Mutual labels:  webgl, shaders, rendering
Webgl Wind
Wind power visualization with WebGL particles
Stars: ✭ 601 (-61.25%)
Mutual labels:  webgl, particles, gpu
Fieldplay
A vector field explorer
Stars: ✭ 922 (-40.55%)
Mutual labels:  webgl, particles, gpu
Solarsys
Realistic Solar System simulation with three.js
Stars: ✭ 49 (-96.84%)
Mutual labels:  webgl, shaders
Gpu Spline Deformation
Baking spline deformation to a texture then applying it to a mesh via a shader.
Stars: ✭ 52 (-96.65%)
Mutual labels:  shaders, gpu
Glsl Worley
Worley noise implementation for WebGL shaders
Stars: ✭ 66 (-95.74%)
Mutual labels:  webgl, shaders
Aardvark.rendering
The dependency-aware, high-performance aardvark rendering engine. This repo is part of aardvark - an open-source platform for visual computing, real-time graphics and visualization.
Stars: ✭ 79 (-94.91%)
Mutual labels:  rendering, gpu
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (-33.01%)
Mutual labels:  webgl, shaders
Shaderworkshop
Interactive GLSL fragment shaders editor made with Qt
Stars: ✭ 43 (-97.23%)
Mutual labels:  shaders, rendering
Glslcanvas
Simple tool to load GLSL shaders on HTML Canvas using WebGL
Stars: ✭ 1,067 (-31.21%)
Mutual labels:  webgl, shaders
Infinite Webl Gallery
Infinite Auto-Scrolling Gallery using WebGL and GLSL Shaders.
Stars: ✭ 42 (-97.29%)
Mutual labels:  webgl, shaders
Phenomenon Px
⚡️ The fastest way to create pixel shaders.
Stars: ✭ 77 (-95.04%)
Mutual labels:  webgl, gpu
Shadergraph
Unity ShaderGraph project
Stars: ✭ 1,009 (-34.95%)
Mutual labels:  shaders, rendering
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+654.22%)
Mutual labels:  webgl, shaders
Mpr
Reference implementation for "Massively Parallel Rendering of Complex Closed-Form Implicit Surfaces" (SIGGRAPH 2020)
Stars: ✭ 84 (-94.58%)
Mutual labels:  rendering, gpu
Videngine
3D graphics for iOS using Metal and Swift
Stars: ✭ 86 (-94.46%)
Mutual labels:  shaders, gpu

Phenomenon

npm version travis build gzip size license dependencies TypeScript

Phenomenon is a very small, low-level WebGL library that provides the essentials to deliver a high performance experience. Its core functionality is built around the idea of moving millions of particles around using the power of the GPU.

Features:

  • Small in size, no dependencies
  • GPU based for high performance
  • Low-level & highly configurable
  • Helper functions with options
  • Add & destroy instances dynamically
  • Dynamic attribute switching

Want to see some magic right away? Have a look here!

Install

$ npm install --save phenomenon

Usage

// Import the library
import Phenomenon from 'phenomenon';

// Create a renderer
const phenomenon = new Phenomenon(options);

// Add an instance
phenomenon.add("particles", options);

For a better understanding of how to use the library, read along or have a look at the demo!

API

Phenomenon(options)

Returns an instance of Phenomenon.

Throughout this documentation we'll refer to an instance of this as renderer.

options.canvas

Type: HTMLElement
Default: document.querySelector('canvas')

The element where the scene, with all of its instances, will be rendered to. The provided element has to be <canvas> otherwise it won't work.

options.context

Type: Object
Default: {}

Overrides that are used when getting the WebGL context from the canvas. The library overrides two settings by default.

Name Default Description
Alpha false Setting this property to true will result in the canvas having a transparent background. By default clearColor is used instead.
Antialias false Setting this property to true will make the edges sharper, but could negatively impact performance. See for yourself if it's worth it!

Read more about all the possible overrides on MDN.

options.contextType

Type: String
Default: webgl

The context identifier defining the drawing context associated to the canvas. For WebGL 2.0 use webgl2.

options.settings

Type: Object
Default: {}

Overrides that can be used to alter the behaviour of the experience.

Name Value Default Description
devicePixelRatio number 1 The resolution multiplier by which the scene is rendered relative to the canvas' resolution. Use window.devicePixelRatio for the highest possible quality, 1 for the best performance.
clearColor array [1,1,1,1] The color in rgba that is used as the background of the scene.
clip array [0.001, 100] The near and far clip plane in 3D space.
position number {x:0,y:0,z:2} The distance in 3D space between the center of the scene and the camera.
shouldRender boolean true A boolean indicating whether the scene should start rendering automatically.
uniforms object {} Shared values between all instances that can be updated at any given moment. By default this feature is used to render all the instances with the same uProjectionMatrix, uModelMatrix and uViewMatrix. It's also useful for moving everything around with the same progress value; uProgress.
onSetup(gl) function undefined A setup hook that is called before first render which can be used for gl context changes.
onRender(renderer) function undefined A render hook that is invoked after every rendered frame. Use this to update renderer.uniforms.
debug boolean false Whether or not the console should log shader compilation warnings.

.resize()

Update all values that are based on the dimensions of the canvas to make it look good on all screen sizes.

.toggle(shouldRender)

Toggle the rendering state of the scene. When shouldRender is false requestAnimationFrame is disabled so no resources are used.

shouldRender

Type: Boolean
Default: undefined

An optional boolean to set the rendering state to a specific value. Leaving this value empty will result in a regular boolean switch.

.add(key, settings)

This function is used to add instances to the renderer. These instances can be as simple or complex as you'd like them to be. There's no limit to how many of these you can add. Make sure they all have a different key!

key

Type: String
Default: undefined

Every instance should have a unique name. This name can also be used to destroy the instance specifically later.

settings

Type: Object
Default: {}

An object containing overrides for parameters that are used when getting the WebGL context from the canvas.

Name Value Default Description
attributes array [] Values used in the program that are stored once, directly on the GPU.
uniforms object {} Values used in the program that can be updated on the fly.
vertex string - The vertex shader is used to position the geometry in 3D space.
fragment string - The fragment shader is used to provide the geometry with color or texture.
multiplier number 1 The amount of duplicates that will be created for the same instance.
mode number 0 The way the instance will be rendered. Particles = 0, triangles = 4.
geometry object {} Vertices (and optional normals) of a model.
modifiers object {} Modifiers to alter the attributes data on initialize.
onRender function undefined A render hook that is invoked after every rendered frame.

Note: Less instances with a higher multiplier will be faster than more instances with a lower multiplier!

.remove(key)

Remove an instance from the scene (and from memory) by its key.

.destroy()

Remove all instances and the renderer itself. The canvas element will remain in the DOM.

.prepareAttribute(attribute)

Dynamically override an attribute with the same logic that is used during initial creation of the instance. The function requires an object with a name, size and data attribute.

Note: The calculation of the data function is done on the CPU. Be sure to check for dropped frames with a lot of particles.

Attributes can also be switched. In the demo this is used to continue with a new start position identical to the end position. This can be achieved with .prepareBuffer(attribute) in which the data function is replaced with the final array.

Examples

  1. Particles
  2. Types
  3. Transition
  4. Easing
  5. Shapes
  6. Instances
  7. Movement
  8. Particle cube
  9. Dynamic intances

Contribute

Are you excited about this library and have interesting ideas on how to improve it? Please tell me or contribute directly! 🙌

npm install > npm start > http://localhost:8080

License

MIT © Colin van Eenige

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].