on 23-04-2012 08:05 PM
How can i create a custom texture file ? basically what i need is this :
byte vbuffer[256*256]; // plot a pixel vbuffer[y * 256 + x] = Rgba(255,255,0,0);
and then move that into a texture 2d :
texture.setPixels(0,vbuffer);
Thanks for the help in advance!
23-04-2012 08:32 PM - edited 23-04-2012 08:34 PM
here's what i did to get it working:
[code]
uint[] vBuffer = new uint[256*256];
//Fill buffer to red
for(int i=0;i<256*256;i++) vBuffer[i] = 0xFF0000FF;
//Creature a RGBA texture.
Texture2D texture= new Texture2D(256, 256, false, PixelFormat.Rgba);
texture.SetPixels(0, vBuffer);
[/code]
edit: also, how exactly did u add the code tag?
on 23-04-2012 08:50 PM
I'm already very thankful for the answer (it totally solves my problem).
But to make my life a bit easier; is there a easy way to convert a Rgba type to byte ?
on 23-04-2012 09:00 PM
Rgba requires 32 bit's per each pixel, and a byte is only 8 bit's
for your implementation to work, you'd have to do:
[code]
byte[] vBuffer = new byte[16*16*4];
for(int i=0;i<16*16*4;i+=4){
vBuffer[i+0] = 0xFF; //Red
vBuffer[i+1] = 0x0; //Green
vBuffer[i+2] = 0x0; //Blue
vBuffer[i+3] = 0xFF; //Alpha
}
Texture2D texture= new Texture2D(16, 16, false, PixelFormat.Rgba);
texture.SetPixels(0, vBuffer);
[/code]
on 23-04-2012 09:07 PM
yes, i know. I just thought if there was a easy way convert rgba to 0xFF0000FF would be easier ![]()
but thanks a million anyway, it totally solves my problems!
23-04-2012 09:21 PM - edited 23-04-2012 09:36 PM
ah, do you mean like so:
[code]
public static uint RGBA(byte r, byte g, byte b, byte a){
//Seems uploading to set pixels expect RGBA as ABGR
return (uint)((a<<24)|(b<<16)|(g<<8)|r);
}
uint[] vBuffer = new uint[16*16];
for(int i=0;i<16*16;i++) vBuffer[i] = RGBA (0,255,0,255);
Texture2D tex= new Texture2D(16, 16, false, PixelFormat.Rgba);
tex.SetPixels(0, vBuffer);
[/code]
edit: again, how exactly did you format your first post?
26-04-2012 02:42 PM - edited 26-04-2012 02:43 PM
liquidwater91, when you want to insert program code into the body of your reply, click on the 5th icon on the toolbar just above the textbox you type your reply in (looks like a clipboard with a "C" on it) and then insert your code into the popup.
Like this:
10 PRINT "HELLO" 20 GOTO 10
on 26-04-2012 09:42 PM
27-04-2012 01:31 AM - edited 27-04-2012 01:31 AM
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870