Hot answers tagged

9

TextureAtlas#findRegion(String) returns a region with a name that matches the name specified. It does not copy the region, therefore any changes you make to the region will be reflected in the TextureAtlas. To overcome this issue, simply instantiate a new TextureRegion object and pass it the region found inside your TextureAtlas: background1 = new ...


8

since you admittedly don't have much experience with 3D and (presumably) OpenGL, I'll give you a "bird's eye" overview of the process. I'll do my considerations about OpenGL, but the basic reasoning yields for other APIs too. When you render something with a modern version of OpenGL you create objects that will reside into the GPU memory, and then mostly ...


4

You shouldn't really worry about cutting of the other half of the sphere since Unity doesn't render faces that are looking away anyway. That doesn't solve your problem however. Try to save your sphere as a .blend file. Or if you did that, export it as an .fbx. If you really want to save resources you should bake(bake texture) your full sphere unto a ...


3

So you're not using a modelling program- thus you'll have to provide the cube/texture information yourself from code. Let's start out simple with one textured triangle. VertexPositionTextures contains Vertex (location of points in space) and texture (where does that point match to a point on an image). Keep in mind that the location for the texture is on a ...


3

As /u/slime73 pointed out, you are missing , after your T coordinates. float vertices[] = {// X Y R G B S T -0.5f, +0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f // Top-left +0.5f, +0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f // Top-right +0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f // ...


3

Yes, it can. But certain devices will suffer. For example, iOS PVRTC texture compression doesn't work without square textures. I think Unity makes them square, so you end up with your textures taking up a bunch more RAM to accommodate PVRTC. See Unity Documentation: 2D Textures for more details.


3

1. Creating textured model in Blender First, add a new texture by going to texture panel on the right. Select type "Image or Movie", click "Open" and locate your texture file. Then, move your mouse to the 3d view, press Tab to select the default cube, then press "U" and select Unwrap. Go to UV Image Editor: and select the texture: At this point, the ...


3

You are checking how many bytes there are per pixel, but you are not checking how colours are ordered, and it could be RGBA or BGRA (or possibly something else). You need something like this instead of mode = GL_RGBA (little-endian machines): if (surface->format->Rmask == 0x000000ff) mode = GL_RGBA; else mode = GL_BGRA; If you want a more ...


3

To get rid of the jagged lines add 1 line of transparent pixels around the rectangle texture. The issue with the dark lines is that you are most likely using black transparent pixels (color #000000). The issue is most likely to be gone if you use colored transparency instead. - Repeating the border pixels of your sprite - but simply with alpha=0


3

This depends on the details of your rendering setup, but here are the most common out-of-the-box behaviours: 1. Painter's Algorithm Many 2D frameworks simply layer sprites in the order they are drawn (so you need to draw your background before your foreground). In this case, whichever sprite occurs later in your drawing (ie. drawn from a later command, or ...


3

The texture regions inside don't need to be powers of two. But texture compression cells are often 4x4 so you have to be careful when using compressed textures that the edges of two texture regions don't share the same cell or they'll be compressed together which will degrade the quality if they have different colors. You should leave a N pixel border ...


3

The sourceRect is much better for this. Watch this if like a funny video explaining why: https://www.codeandweb.com/what-is-a-sprite-sheet-performance The more technical explanation: I am using pseudo code - the exact number of commands required might vary - but you should see what I am talking about. If you use isolated sprites the game engine has to ...


3

Release does not return an HRESULT, it returns a ULONG. That ULONG is the new reference count on the object (after the release). hr == S_FALSE in your code because Release is returning 1 (which is what S_FALSE is defined as), which means there's one pending reference count to the object after you release it (that's not necessarily a problem, it could be an ...


3

It looks like the issue is that you are doing non uniform scaling (different scale on x and y axis) and using nearest neighbour texture sampling. If you switch to using uniform scaling and/or bilinear texture sampling (or better, like bicubic) the problem should go away.


2

It looks like the Wings3D object doesn't have texture coordinates. There is a texture applied, it's just not applied correctly. Without texture coordinates, it'll just stretch a single pixel of the texture over the entire object.


2

Explicitly enabling texture samplers is not necessary if you're drawing using the programmable shader pipeline (since whether or not you're sampling from textures, and what type of sampling to do across those textures is explicit in the shader code that you're using) However, based upon your code sample you appear to be rendering using the fixed function ...


2

If you open the image above in its full resolution and look closely (with something like Magnifier on Windows), you should see that all the pixels simply have something like a blurred edge. Since there can be seen standalone "edges" of pixels, it is clearly not a post-processing method. When looking at screenshots in different resolutions, the edge ...


2

A tough one. Let's try. Let noise be your (infinite) noise function. Let Seam_noise be a seamless noise function in the dimension of your tiles. (here is an example , you can download c# code with a seamless perlin noise implementation ) Follow an example of seamless perlin repeated 4X4 times (the red quad is your tile dimension) Consider a "filter" ...


2

A possible problem is in your SetInStartPosition(). For setting the Y position it should be position.Y = screenBounds.Height - texture.Height... not screenBounds.Width - texture.Width...


2

I don't think it's possible to specify a source pitch for the buffer in CPU memory like you could with a lower level API. However, you can specify an offset into your pixels using a DataView, so you could upload a 1000x100 portion of the texture that way.


2

Try turning off backface culling. In your shader, put "Cull Off" in the "SubShader" section.


2

This deserves a very broad answer because texturing is historically THE one big job of graphics renderers. Put shortly, this happens during rasterization. Rasterization is a process in the rendering pipeline, where the graphic card generates pixels (fragments) from geometry and then passes it on to the next stage of the pipeline, the pixel (fragment) ...


2

Yes, you can use that code to update a Unity RenderTexture (not simply a Texture2D). You need to make sure that code executes on the render thread. To do that, make sure you only call it in response to the GL.IssuePluginEvent (which will translate to the C++ function UnityRenderEvent).


2

Ok, so I tried executing these 2 pieces of code: (camera is camera=new OrthographicCamera(); camera.setToOrtho(true, 100, 100*screenW/screenH);, and the 2 texture regions are of size 64*64, from the same textureAtlas) Code 1: rendering on-screen public void renderGameScreen(){ spriteBatch.setProjectionMatrix(camera.combined); spriteBatch.begin(); ...


2

I'm going to take a stab at answering this, though YMMV. I use the Steam Hardware Survey ( http://store.steampowered.com/hwsurvey?platform=pc ) to determine what is the video RAM (VRAM) available on most computers. Looking at the results as of 2015-10-13 (today), nearly 85% of people have 1024 MB VRAM. Your question is very broad, since it doesn't state ...


2

I know this is a couple years late but maybe someone searching for a solution will come across this. So in order to change the "Default" file type assigned to new Output Elements created in Render to Texture, you can do the following. 1 MaxScript > Open Script 2 Navigate to the MacroScripts folder in you installation directory 3 Open ...


2

What are the texture coordinates that you're using for those vertices? With D3DTADDRESS_CLAMP, they must be in the [0;1] range, anything else will be clamped to [0;1]. So, for example, using the [-1;0] coordinate range could cause this as it would make all of them effectively 0.


2

Firstly, why aren't you using GL_COMPRESSED_RGB_ARB for your textures which don't have an alpha channel? I'm not that familiar with OpenGL, but I think that should reduce their size in memory significantly. By default on Windows 32-bit applications only get 2GB of address space. You can improve that so that when run on a 64-bit operating system they get 4GB ...


2

You shouldn't call dispose directly on a Texture loaded by an AssetManager, they are disposed the the AssetManager is cleared or disposed or if you call unload on the AssetManager and pass the Texture. The reason you shouldn't dispose assets from an AssetManager is that they can be shared between many other assets (two fonts may use the same texture for ...


2

As suggested in the comments, you should try to use Tri-Linear filtering and MipMaps. The reason using TextureFilter.MipMapLinearLinear results in a black box is that you haven't generated the texture with MipMaps. In order to do so, simply pass a second parameter to the Texture constructor as true like so: img = new Texture("circle.png", true);



Only top voted, non community-wiki answers of a minimum length are eligible