Loop of texture feedback in three.js (fbo pingpong?)

I am in the process of converting a hlsl shader I created with vvvv into a web version, and although I am new to web programming, I have decided that using three.js/webGL is the best approach.

Everything has been going smoothly so far, but I have hit a roadblock at the most challenging part, which involves texture feedback. Specifically, the output texture of one render pass needs to be the input texture for the next frame (a task easily achieved in vvvv using a "frameDelay" function).

To simplify things, let's say I want to increment the red component of a pixel by 0.1 in each frame (wrapping around from 0 to 1). How can I accomplish this in three.js?

I have not been able to find any examples of something similar being done. Through my research, I have learned that it should be possible in GLSL using techniques like "fbo pingpong" or "double-buffering," but I have had no success implementing them.

Before sharing all of my code, I would like to confirm the necessary steps. Any assistance would be greatly appreciated:

- Set up scene1 and geometry. - Create material1: the "red counter" shader. (- set up scene2 and material2.) - Set up 2 WebGLRenderTargets, Texture1 and Texture2.

- Render scene1 to Texture1, with Texture2 as a uniform input for material1. (- Render Texture1 to the screen using scene2/material2.) - Swap Texture1 with Texture2 and reset uniforms for material1.

Answer №1

After successfully implementing a feedback loop using fbo texture swapping in three.js, I encountered new challenges that led to more questions. If anyone is working on achieving texture feedback, feel free to check out my latest post where I have shared the code (you can simplify the render loop by removing the if statement and retaining only what's inside the else block).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the importance of utilizing `document.createElementNS` when incorporating `svg` elements into an HTML webpage using JavaScript?

Not Working Example: const svg = document.createElement('svg') svg.setAttribute('height', '100') svg.setAttribute('width', '100') document.body.appendChild(svg) const rect = document.createElement(&apos ...

Is it better to return JSON before streaming a file through an iframe or sending HTTP headers?

I have created a form that utilizes a hidden iframe to submit a file to a script which then modifies the file and returns the altered version. I have realized that I can avoid saving the file anywhere by simply using echo file_get_contents(tmp);, where tmp ...

Ending iteration upon encountering an error | Harnessing Node.js and MongoDB

I've come across a problem that has been puzzling me for quite some time now. I can't seem to figure it out, and I feel silly because it seems like it should be an easy fix. Here's the code snippet: get_online = function (err, result) { ...

Guide on extracting the ID within a for loop and incorporating it into a Vue.js function

In order to make an API request, I need to retrieve the id. However, whenever I try to include <a v-on:click="showRecipe({{inf.Id}})">Recipe</a> in my code, the entire page crashes. Removing this line resolves the issue. How can I pass the id ...

A creative way to display a div upon hovering over a link dynamically

My website has dynamically generated a tags, each with its own corresponding div containing unique content and height. I want to make it so that when a user hovers over an a tag, the matching div is displayed. The div should appear at the position of the m ...

Populate the AngularJS scope with a dynamically generated array

My Angular Application is functioning properly with <script> var app = angular.module('MyApp', []); app.controller('myCtrl', function ($scope, $sce) { $scope.urls = [ { "url": $sce.t ...

Navigate to the Vuejs component's element that has a specified class name

When a component is loaded, I want it to automatically scroll down to display the element with a class name of 'actual-month' within an unordered list. <b-card no-body header="<i class='fa fa-align-justify'></i> Unorder ...

When utilizing ThreeJS video texture, it is necessary to ensure that CORS headers are included, regardless of whether the <video> tag typically requires it or

I am facing an issue with my localhost web server where a remote video from Firestore Storage is being played on a page using a <video> tag. The video plays correctly on the web page. However, I am now trying to use the same video as a texture in a T ...

Need help maintaining selected div in navbar as active even after page refresh?

I've been struggling to maintain the selected tab as active on page reload. I have tried various solutions found here but none seem to work for me. Currently, the active class is applied correctly when clicked, but upon navigating to a new page, it re ...

What can cause my function to return true on the server but false on the client side in Meteor.js?

I am facing an issue with the hasCompleted function which returns true or false on the server side: Smaples.helpers({ hasCompleted(userId) { // … switch (this.frequency) { case Frequency.ONE_TIME:{ return measures.fetch().every(mea ...

Angular dependencies cannot be injected because $scope is not defined

Currently, I am utilizing the latest version of angularjs (1.3.3): I have integrated 3 JavaScript libraries into my project. <script src="framework/jquery-1.9.1.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3 ...

What is the best way to trigger a flash animation on the front end?

CODE: login.ejs <script> req.flash('success_msg', 'You have logged in'); </script> header.ejs <div class = "alertMessage"> <% if (success_msg != false){ %> <span class="alert alert-success ...

Comparing the distinction between assigning values to res and res.locals in a Node.js application using Express

Greetings! I am inquiring about the utilization of res (Express response object) and res.locals in Express. During my exploration of nodejs, I came across a code snippet that consists of a middleware (messages.js), a server (app.js), and a template (messa ...

Issue with Component: Data is not being injected into controller from ui-router resolve, resulting in undefined data

Encountering an issue with resolve when using a component and ui-router: the data returned after resolving the promise is displaying as "undefined" in the controller. Service: class userService { constructor ($http, ConfigService, authService) { th ...

Checking for the existence of a file in JavaScript

I rely heavily on the scripts and images on my website, but the problem is that everything gets saved to the cache. This means that users can't see updates unless they clear their cache or open the site in private browsing mode. I'm working on cr ...

What distinguishes defining a function through a prototype versus as a class property?

Check out this code snippet: Apple defines its function using a prototype. Banana defines its function using a class property. var Apple = function(){} Apple.prototype.say = function(){ console.debug('HelloWorld'); } var Banana = functio ...

Design my div layout to resemble a tree shape

Take a look at this URL. I have dynamically created divs in a nested structure for a sports tournament. I need help styling the divs to match the tournament structure. This is how I want my structure to look. The code is functioning properly, it's ju ...

Cannot use Object.keys function in AngularJS

For my UI.Bootstrap accordion, I have set up the heading as follows: <accordion-group ng=repeat="(cname, stations) in byClient"> <accordion-heading> {{ cname }} <span class="pull-right"> {{ Object.keys(stations).length }} Sta ...

What is preventing WebRTC from re-establishing connection after being disconnected?

In my current React web application project, I am implementing a feature where users can engage in group calls using WebRTC through a NodeJS server running Socket.IO. The setup allows for seamless joining and leaving of the call, similar to platforms like ...

Exploring Angular 2 Application Testing: Tips for Interacting with HTML Elements

In my Angular 2 Frontend testing journey, I came across a blog post ( ) where the author utilized ng-test TestBed for core testing in Angular. While the example provided was helpful for basic understanding, it lacked details on how to manipulate Elements. ...