texture2d

generate texture from array in threejs

人走茶凉 提交于 2019-12-06 16:22:53
I am trying to generate a texture from an array in threeJS and it is not working as expected. It appears that the way I generate the texture is not correct. If I use the following texture, it works as expected. http://www.html5canvastutorials.com/demos/assets/crate.jpg crateTex = THREE.ImageUtils.loadTexture('data/crate.jpg'); If I generate a dummy texture and try to display it, it is all black... var dummyRGBA = new Uint8Array(4 * 4 * 4); for(var i=0; i< 4 * 4; i++){ // RGB from 0 to 255 dummyRGBA[4*i] = dummyRGBA[4*i + 1] = dummyRGBA[4*i + 2] = 255*i/(4*4); // OPACITY dummyRGBA[4*i + 3] =

Make texture2D readable in runtime/script Unity3D [duplicate]

心已入冬 提交于 2019-12-06 15:24:32
This question already has an answer here : How to make Texture2D Readable via script (1 answer) Closed 2 years ago . I have a plugin that allows me to access pictures from an Android phones gallery. This gives me a texture of the Texture2D type. I then want to edit it using the GetPixels function, but it is not set to readable by default. How would I make the texture readable so I can use GetPixels on it? Basically I am allowing the user to select a picture from the phone and then crop it. In the following example pic the picture would be cropped by the red rectangle. Which works if I make the

How to read data from a UTexture2D in C++

£可爱£侵袭症+ 提交于 2019-12-06 09:36:57
问题 I am trying to read the pixel data from a populated UTexture2D in an Unreal Engine C++ project. Before I post the question here, I tried to use the method described in this link: https://answers.unrealengine.com/questions/25594/accessing-pixel-values-of-texture2d.html. However, it doesn't work for me. All pixel values I got from the texture are some garbage data. I just want to get the depth values from the SceneCapture2D and a post-processing material that contains SceneTexture: Depth node.

GLES20 Texture Not Working on Some Devices

偶尔善良 提交于 2019-12-06 05:05:12
I have tried to add a fairly simple extension on top of Android's example OpenGL 2.0 project in order to add texturing to basic shapes. This seems pretty straightforward, but on certain devices (Samsung Nexus S, LG Optimus 3D, Samsung Galaxy S) the texture just does not render. This is actually a problem that I am having on a much larger project, but I was able to reproduce the issue with the simple project below in the hope that someone here has an idea of where my code presents issues, or how to specifically architect GL textures for these devices (maybe there are issues with the devices).

What is the correct Resource.Load path?

巧了我就是萌 提交于 2019-12-05 18:44:22
I'm trying to load a Texture2D (.png) resource using Resource.Load . I've tried following path patterns: Assets/CaseSensitivePath/TextureName CaseSensitivePath/TextureName Assets/CaseSensitivePath/TextureName.png CaseSensitivePath/TextureName.png Every time, Resource.Load(path, typeof(Texture2D)) returns null. This is my code and error handling: public class LazyResource<T> where T : UnityEngine.Object { //Path is read-only public string path { get { return _path; } } private string _path = ""; //Whether NOT FOUND warning was thrown //in that case, further load attemts are ommited and the

How to read data from a UTexture2D in C++

僤鯓⒐⒋嵵緔 提交于 2019-12-04 19:35:02
I am trying to read the pixel data from a populated UTexture2D in an Unreal Engine C++ project. Before I post the question here, I tried to use the method described in this link: https://answers.unrealengine.com/questions/25594/accessing-pixel-values-of-texture2d.html . However, it doesn't work for me. All pixel values I got from the texture are some garbage data. I just want to get the depth values from the SceneCapture2D and a post-processing material that contains SceneTexture: Depth node. I need the depth values available in C++ so that I can do further processing with OpenCV. In Directx11

Combine Array of Sprite objects into One Sprite - Unity

被刻印的时光 ゝ 提交于 2019-12-04 00:29:21
I have an array of Sprite objects in Unity. Their size vary depending on the image loaded. I want to combine them side by side like a tiled map into one image. I want them to be layout like your are forming a line of images, one after the other. (note: NOT one on top of the other) How may I be able to do this? The reason why I'm combining (just for those who want to know) is because I'm using a polygon2D Collider. Since there are some weird behaviors happening when I use multiple colliders side by side, I decided to just combine the images before adding one big polygon collider. Note that

How to switch the image of a CCSprite

佐手、 提交于 2019-12-03 14:46:41
I have a CCSprite that is initialized using [CCSprite spriteWithSpriteFrameName:@"plist_file_key_here.png"] . I have already added all the sprites from my plist file to CCSpriteFrameCache. I have tried setting the texture like this: CCSpriteFrame * frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:name]; NSAssert(frame.texture!=nil, @"frame.texture can't equal nil"); //this works fine [sprite setTexture:frame.texture]; //doesn't cause a white square to appear, just doesn't switch the image. As I said in my comments, this doesn't work. I think it has something to do with

Is there a fast alternative to creating a Texture2D from a Bitmap object in XNA?

半世苍凉 提交于 2019-12-03 07:40:21
问题 I've looked around a lot and the only methods I've found for creating a Texture2D from a Bitmap are: using (MemoryStream s = new MemoryStream()) { bmp.Save(s, System.Drawing.Imaging.ImageFormat.Png); s.Seek(0, SeekOrigin.Begin); Texture2D tx = Texture2D.FromFile(device, s); } and Texture2D tx = new Texture2D(device, bmp.Width, bmp.Height, 0, TextureUsage.None, SurfaceFormat.Color); tx.SetData<byte>(rgbValues, 0, rgbValues.Length, SetDataOptions.NoOverwrite); Where rgbValues is a byte array

Is there a fast alternative to creating a Texture2D from a Bitmap object in XNA?

China☆狼群 提交于 2019-12-02 21:06:00
I've looked around a lot and the only methods I've found for creating a Texture2D from a Bitmap are: using (MemoryStream s = new MemoryStream()) { bmp.Save(s, System.Drawing.Imaging.ImageFormat.Png); s.Seek(0, SeekOrigin.Begin); Texture2D tx = Texture2D.FromFile(device, s); } and Texture2D tx = new Texture2D(device, bmp.Width, bmp.Height, 0, TextureUsage.None, SurfaceFormat.Color); tx.SetData<byte>(rgbValues, 0, rgbValues.Length, SetDataOptions.NoOverwrite); Where rgbValues is a byte array containing the bitmap's pixel data in 32-bit ARGB format. My question is, are there any faster approaches