I’ve some doubts/questions about DynamicTexture that I would like to share with you:
I cannot find a way to draw the content of a DynamicTexture directly on the screen at a specific position. As I understood I cannot use directly the canvas context.
I would like to apply some glitchy effects on my texture. I don’t know if it is possible to apply a shader to a texture (maybe I have to code a shader for a material that have a texture? Sorry, never worked with shader )
Is it possible to convert a DynamicTexture to a RawTexture? I was thinking to avoid shader and just offset the RGB buffer of some pixels randomly to obtain a glitch effect
For 1 you can use a GUI image and put this image where you want in a fullscreen GUI (you will need to copy the texture content to the image context, though, which could be slow if you do this each frame).
You can also use a regular 3D plane always facing the camera. You will need to perform some computations if you want this plane to be positioned at some specific pixel coordinates but it can be done.
I’ve already tried @sebavan suggestion for point 1, it works pretty well. Just one little question/confirmation more. If I got it right in order to draw/write whatever I want in my 2D screen I need to create a DynamicTexture with the same canvas size. So every time that canvas change size (browser is resized) I have to dispose the texture and create new one, right?
I will try to understand how to use post process to obtain my glitch effect.
P.S.:
About 3rd point: I was not thinking to copy all the RGB buffer at every frame, but just take an offseted pointer to them, but then I realized that we are not working with C/C++, so this kind of trick are not available here
Oh, PostProcess is so funny with custom shader!
I think I’m going to spend some time with it! At the moment I was able to just make this basic idea, but I am already happy : https://playground.babylonjs.com/#DAC1WM#26