Tag Info

Hot answers tagged

10

The PNG files are small because they are compressed. When the images are loaded into memory they are uncompressed and therefore take up more space.


9

Try changing the filterMode to Point: t.filterMode = FilterMode.Point;


8

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


6

Basically, I think what you do is first of all create a tile for each of your terrain types that seamlessly tiles with itself. As you said there are many tutorials available on how to do this. Once you have those tiles, you can draw variants as well as transitions between different types of terrain by modifying copies of them. The only thing you need to ...


5

For one, nearest-neighbor will result in pixel perfect scaling only if it's used to upscale in integer multiples. Apart from that, you should not be conducting any scaling operations on your view/projection matrices. If you set your view to match the dimensions of the screen, and your projection matrix to be orthographic with dimensions that match the ...


5

If the textures are the same general "shape" (dimensions, mip levels, etc.) then use texture arrays. You can pack differently "shaped" textures into different arrays if you have any regularity, which you should. This approach gives you all the advantages of individual textures (e.g., no bleeding) plus all the advantages of a texture atlas (e.g. fewer state ...


4

SDL2 doesn't need any functionality to be added for either of those items. Texture batching You yourself can sort the sprites by texture used. The SDL backends can already do draw call batching if they wish to (nothing requires that the Copy command be executed immediately; the only requirement is that it be executed by the time any side effects are ...


4

glRotatef(GLfloat angle, Glfloat x, GLfloat y, GLfloat z); The Above function is what you need for your purpose. It " multiplies the current matrix by a rotation matrix", as the OpenGL documentation says. Here's how you use it- angle is the angle you want to rotate. (Duh.) The next three parameters define the axis around which you would like to rotate. You ...


4

Solution 1: Rotate your UVs in your vertex shader The vertex shader is where per-vertex attributes can be modified before rendering. These values are then linearly interpolated to generate values for all fragments of your polygons. As a rotation of your your UVs is a linear transformation, you only need to recalculate the values in the vertices, and linear ...


3

I'm not finding any way to do this within the cocos2d framework, so if someone can do that it would probably be a better answer. However, cc.Texture2D does have a getHtmlElementObj() function. Now, this function can return either an image element or a canvas element. If it returns an image, you need to make a canvas from it as shown in this answer: var ...


3

The only apparent error in your code is that you seem to specifying 4 mip-levels, from level 0 to level 3, however, you set GL_TEXTURE_MAX_LEVEL to 4. The max level is the zero-based index of the last mip-level, so in this case, it should be 3: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 3);


3

Yes. There an article about this by Chris­t­ian Schüler: http://www.thetenthplanet.de/archives/1180 It's a followup to a book article (ShaderX 5) which did exactly what you need. I've used it myself. Here is the part that you need: (p : world-space position, N : world-space normal) mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) { // get edge vectors ...


3

I'd go for a second shader that accepts two textures and does the desaturation. Performance loss will be minimal. uniform sampler2D tex; uniform sampler2D texA; void main() { vec4 texelColor = texture2D(tex, gl_TexCoord[0].xy); vec4 maskColor = texture2D(texA, gl_TexCoord[1].xy); vec4 desatColor = texelColor * vec4(0.3, 0.59, 0.11, 1.0); // ...


3

Inside one of the folders of PVRTexTool you find PVRTexToolCLI.exe, that is the command-line version of it. You can use a batch command on it like this: for %f in (*.pvr) do PVRTexToolCLI.exe -i "%f" -d -f r8g8b8a8


3

Since there's no accepted answer I add some info, I wanted just to add things not already said by Sean in his answer. TexelFetch treat the texture as a Image, so you can access exactly the content of pixels. You usually do that when you need exactly that content, wich is in few but usefull occasions: Certain post processing filters (Guassian blur exploits ...


3

If the only difference between the quads is their physical size in window coordinates ("one is bigger than the other on-screen"), and all other things (shader, textures, et cetera) are equal, then the only significant difference in the pipeline will be that the rasterizer must fill more fragments for the quad that is larger on-screen. This means that if the ...


3

Here are two approaches that I've used before: The approach I prefer is to create an indirection map: Render the UV coordinates themselves to a texture Iterate the raw pixels of the 3D view which need to be updated. Splat into the model texture for each UV pixel The other approach I've had success with is un-projecting and raytracing Invert your ...


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

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


2

There can be a texture with the pupils and generous padding around them. On render, geometry just changes UV coords to sample from texture - hence smooth pupils movement on static geometry.


2

The answer to this question here should help explain how to use the GetData function. Basically, the data is stored in the return array from the GetData call is formed by reading the 2D texture from left to right, top to bottom, transforming it as follows: AAAA BBBB => AAAABBBBCCCCDDDD CCCC DDDD To determine where a given pixel in the 1D array is, we ...


2

From your original equation a_position.x = a_position.x + amplitude * sin(phase + a_position.x); We'll just be taking at look at the sin portion as this is where this effect comes from sin(phase + a_position.x); Let's look at the sin function over a half of a period for different positions (phase is in degrees) Position 1 - a_position.x = 0 sin(0 + 0) ...


2

What exactly is the difference between Tiling the material and Offset of material? Those parameters set by the inspector are used inside the shader to scale the texture coordinates. A uniform float4 in the shader with the name of the texture and _ST suffix is populated with those values. For example considered the main texture: float2 scaled_uv = ...


2

The DDS file format changed between dx9 and dx10. dx9 had been supporting a lot of new features via kludges, these new features were finally added as full types with the switch to DXGI. What this means is that most existing DDS viewers do not support any of the new texture formats or even files saved from directXtex. (The new semi-open source microsoft ...


2

Your hunch is correct. There must be external information mapping regions of the image to sprites unless all the information the application needs can be derived from hardcoded knowledge and regularity. Even in your regular grid-based example, you lack some information for the general case. Common metadata for sprite sheets are: origin, a location inside ...


2

You need to combine texture atlas techniques with your existing triplanar shader so that you can easily switch the "textures" being used based on the terrain type in the voxel. One technique if you are using shared vertices between voxels might be to use vertex color or UV coords to encode all the terrain types associated with a particular vertex, then you ...


2

If you modify a material, it affects the objects that are using it. You need to duplicate that material, modify its texture and reassign it to the target object.


2

SharpDX is a DirectX wrapper, not an XNA one. XNA's GetData methods are higher-level abstractions on top of the underlying DirectX functionality. If you're using the D3D9 interface, you probably want a variant of LockRectangle. If you're using D3D11 you probably want some variant of MapSubresource (or the similar method for D3D10). Note that in D3D9 the ...


2

On iOS it seems that you are asking for trouble when the total memory usage for your app starts approaching half of the device's total memory (1gb for iPhone 5). But there's not a completely hard limit and it's not totally predictable. We have noticed that you get more leeway after a reboot of the device, for example. Anecdotally it seems that if your app ...


2

Your input layout defines POSITION as R32G32B32_FLOAT but Vertex's first member is an XMFloat4. This results in garbage in the TEX input. To fix the problem, switch to a XMFloat3 for the Vertex position member. Also, the offset for your NORMAL is set to zero - this should be D3D11_APPEND_ALIGNED_ELEMENT as well.



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