Jump to content

how to get Render Texture to create a a png from multiple texture


dullman
 Share

Recommended Posts

Hello i created a code that uses pixi filter to change color pallete of multiple textures that by operation merging textures into one i get a character, but getting data for every single texture by extract was painful for my engine if i had more than two characters on map, so i decided to modify my code to first render all textures (sprite) into one render texture and than extract data form this, it faster also still takes half second to complete with ~20 characters so maybe you can as additional tell me tricks to improve farther, but my question is not about that but when i retrieve data i get the glasses of character without alpha data, and orginal texture has alpha data, also when using one texture per one render texture than manually extract pixels and draw it onto texture i get glasses with opacity (or transparent).

Here my code:

var text = bit._baseTexture;
var texture = new PIXI.Texture(text);

var mySprite = new PIXI.Sprite(texture);
var shader = new ChangeColorPallete(usedColors, newColors, 0.00001);

mySprite.filters = [shader];
										
container.addChild(mySprite);
Graphics._renderer.render(container, renderTex);

and here the code in which i retrieve pixels

var pixels = Graphics._renderer.extract.canvas(renderTex);
this.bitmap._context.drawImage(pixels, 0, 0);

and ones for declaring render texture and containet

var renderTex = null;
var container = new PIXI.Container();

if (!renderTex)
	renderTex = PIXI.RenderTexture.create(bit.width, bit.height)

 

ps. If someone i'm using as a base rpg maker mv engine as a base.

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...