Smoke Shader - Frame Buffer
How do I make an smoke shader - frame buffer?
What is a smoke shader - frame buffer? How do you make a smoke shader - frame buffer? This script and codes were developed by Omar Shehata on 13 August 2022, Saturday.
Smoke Shader - Frame Buffer - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Smoke Shader - Frame Buffer</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script id="fragShader" type="shader-code"> uniform vec2 res;//The width and height of our screen uniform sampler2D bufferTexture;//Our input texture void main() { vec2 pixel = gl_FragCoord.xy / res.xy; gl_FragColor = texture2D( bufferTexture, pixel ); } </script> <script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Smoke Shader - Frame Buffer - Script Codes CSS Codes
/* We want our scene to span the entire window */ body { margin: 0; }
Smoke Shader - Frame Buffer - Script Codes JS Codes
//@author Omar Shehata. 2015. //We are loading the Three.js library from the cdn here: http://cdnjs.com/libraries/three.js/ var scene; var camera; var renderer; function scene_setup(){ //This is the basic scene setup scene = new THREE.Scene(); var width = window.innerWidth; var height = window.innerHeight; //Note that we're using an orthographic camera here rather than a prespective camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); camera.position.z = 2; renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); } //Initialize the Threejs scene scene_setup(); var bufferScene; var textureA; var textureB; var bufferMaterial; var plane; var bufferObject; var finalMaterial; var quad; function buffer_texture_setup(){ //Create buffer scene bufferScene = new THREE.Scene(); //Create 2 buffer textures textureA = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter}); textureB = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter} ); //Pass textureA to shader bufferMaterial = new THREE.ShaderMaterial( { uniforms: { bufferTexture: { type: "t", value: textureA }, res : {type: 'v2',value:new THREE.Vector2(window.innerWidth,window.innerHeight)}//Keeps the resolution }, fragmentShader: document.getElementById( 'fragShader' ).innerHTML } ); plane = new THREE.PlaneBufferGeometry( window.innerWidth, window.innerHeight ); bufferObject = new THREE.Mesh( plane, bufferMaterial ); bufferScene.add(bufferObject); //Draw textureB to screen finalMaterial = new THREE.MeshBasicMaterial({map: textureB}); quad = new THREE.Mesh( plane, finalMaterial ); scene.add(quad); } buffer_texture_setup(); //Render everything! function render() { requestAnimationFrame( render ); //Draw to textureB renderer.render(bufferScene,camera,textureB,true); //Swap textureA and B var t = textureA; textureA = textureB; textureB = t; quad.material.map = textureB; bufferMaterial.uniforms.bufferTexture.value = textureA; //Finally, draw to the screen renderer.render( scene, camera ); } render();
Developer | Omar Shehata |
Username | omarshe7ta |
Uploaded | August 13, 2022 |
Rating | 3 |
Size | 2,672 Kb |
Views | 56,672 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Framebuffer - Final | 2,491 Kb |
Cube Sides | 2,390 Kb |
ACM Drawing Practice | 1,802 Kb |
Smoke Shader - Frame Buffer | 2,672 Kb |
Pixijs.v3 Shader Example | 3,213 Kb |
Pixijs.v3 Basic Shader | 2,269 Kb |
Framebuffer - Basic Scene | 2,217 Kb |
Framebuffer - Texture Render | 2,402 Kb |
Basic Threejs Scene | 2,188 Kb |
WebMonkey Test | 8,206 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Experiment - SCSS SVG Background Image with Variables | See8ch | 3,270 Kb |
Another brick in the wall | Fivera | 1,955 Kb |
Pure CSS Animated Photo Stack | Depthdev | 2,486 Kb |
Growing Root - Scroll control - CANVAS | Cjonasw | 2,342 Kb |
Scroll to view if element partially out of view port height | ChrisMaki | 2,104 Kb |
Pure CSS Read More Arrow | Zephyr | 1,747 Kb |
Sassy Buttons | Elyseholladay | 2,299 Kb |
Html5-canvas-snow-effect | MariamMassadeh | 2,609 Kb |
Fixed with using Calc | Tomleo | 2,542 Kb |
A Pen by Miro Olma | Programiro | 2,342 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!