In the last two days I have been coding a shader to compute a cellular automaton (well, actually, it is a partial differential equation, but for practical reasons there's no difference). Everything works perfect, but when I try to export it for web, it does not work at all.
This is how my Scene Tree looks like
Node2D
-- Sprite
-- Viewport
----ColorRect
----Camera2D
The setup is the following:
- The sprite's texture is the Viewport's one. You can consider the sprite as the "renderer" for the viewport.
- The ColorRect is configured to have a simple black color, and it has a Material with a shader, which has the main logic to compute the automaton.
- The Shader has a uniform sampler2D texture as an argument, which is set to the Viewport's texture. It uses this as an input to compute the next state of the system.
- For this reason, Viewport's clear mode is configured to be "Only next frame".
Basically, this creates a feedback loop between the Viewport's output and the shader, effectively simulating my automata step by step. As I said, it works pretty well locally, but on web, only a dark rectangle appears. If you have any hint on what could be wrong or what is missing please let me know. I'll happy to share also the whole project if needed, or the exported HTML5 if you want to check anything.
The project is running in GLES2, with Godot 3.3.4. My OS is Ubuntu 16, in case it matters.