Jump to content

Dynamic Texture Questions


Pryme8
 Share

Recommended Posts

I cant find much documentation on how to use the Dynamic Texture.
What I am trying to do is per pixel manipulation of the DataBuffer.

Is there a way to make a Dynamic texture that is not square, does it have the same call backs as a texture being created? 

I am trying to effectively do this but with a dynamic texture of set width and height:
var self = this;
    this._tiles = new BABYLON.Texture(url, this.parent.scene, true, false, 1, ()=>{            
            self.inverseTextureSize = new BABYLON.Vector2(1/self._tiles._texture._width, 1/self._tiles._texture._height);
            console.log("inverseTextureSize", self.inverseTextureSize);
            self._setShader();
            self.parent._tasks--;
    });

 

and then be able to get the context of the texture and manipulate it per pixel as necessary then make sure its pushed to the shader.

This might be best done with a dynamic texture, but Im not sure where to start.


*EDIT**

well that was easier then I thought:
 

var dTex = new BABYLON.DynamicTexture('dtest', {width:32, height:8}, scene, false, 1);
 
var context = dTex._context;
    var size = dTex.getSize();
    
        context.fillStyle = 'black';
        context.fillRect(0, 0, size.width, size.height);
    
  dTex.update();
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...