Tag Info

Hot answers tagged

15

The zip-format supports several different compression algorithms. You can use a different algorithm for each file in the archive. When you want to store already compressed files which do not benefit from additional compression (like PNG) in a zip-archive, you can encode these files with the "stored" algorithm which doesn't compress at all. The "Add to ...


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;


7

Don't worry about it. When the "deflate" algorithm used in .zip files encounters a block of data that's already well-compressed, like the pixel data of a .png image, it finds that it can't compress it effectively, and it will store it as literal uncompressed data. This takes very little overhead on the decompression end to copy out. ...


6

You might look into ImageMagick. It's open-source and contains code for resampling images using a variety of filters including Lanczos, Kaiser, Gaussian, etc. It can be used as a library linked into your code, and/or as a set of command-line tools you can call from shell scripts and suchlike.


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

The task is actually highly parallelisable on the GPU. Here is an algorithm that should work, assuming e.g. a 1024×1024 source texture ST. create a 256×256 render target, RT1 run a fragment shader that reads from ST and writes to RT1 and does the following: for each fragment in the render target get the (x,y) fragment coordinates sample 16 pixels from ...


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


4

About a decade ago, GL_TEXTURE_2D_ARRAY wasn't widely available, people could only get an array of 2D textures using texture atlases. This means that people stored the data in a faily big 2D texture and when they wanted to fetch a texel, they offseted the texture coordinates with a function of the slice value (the "depth"). This worked well, since the 2D ...


4

You absolutely can combine them! Many 3D games contain an image for the characters body and one for the head, and some combine the two for a single texture for the entire a model. Here's an example of a whole head's texture: Also check out this PDF if you'd like to learn more about texture mapping in general.


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


3

This is expected behaviour. If you look over your code, you'll see that you're getting a new texture name, binding it, then calling glTexSubImage. The problem here is that when you call glTexSubImage the texture does not actually exist yet. Textures are not created by glGenTextures; all that glGenTextures does is give you a free texture object name for ...


3

No can do; the format and array size are both members of the D3D11_TEXTURE2D_DESC structure, so an ID3D11Texture2D will always have the same format for any value of array size. Depending on how you use the texture, you could create different shader resource views specifying subranges of the full array, provided the SRV format is compatible with the texture ...


3

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


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

A line is a list of connected points. For each point you'll need to calculate the X-Texture coordinate of that point, the Y coordinate will always be 0 for the upper point and 1 for the lower point. After you have defined how long one texture segment is you can do so by stepping through all the segments you have generated and noting how much distance you ...


3

You can convert .dds to .tga with a variety of tools, such as the command-line NVIDIA texture tools, the NVIDIA Photoshop plugins if you have Photoshop, or the image editor built into recent Visual Studio versions.


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

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

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


2

Maybe by moving the texture coordinates or something? Yes, the simplest way to do this is to animate the texture coordinates of the relevant geometry over time. You could either: Create a shader uniform variable representing "time," which you periodically update before rendering, and use to offset the texture coordinate U or V component (as desired) ...


2

SFML 2.0+ makes it even easier to load a texture; sf::Texture texLid; std::string image2="images/top.jpg"; if (!texLid.loadFromFile(image2)) { std::cout << "Could not load" << image2; char c; std::cin>>c; return false; } glEnable(GL_TEXTURE_2D);//tell OpenGL to use textures when drawing ...


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

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


2

The first formula you mentioned is not suitable for the result you want to achieve. I suggest the following formula instead: float3 n = abs(input.normal.xyz); float2 tileUV = float2(dot(n, input.pos3D.zxx), dot(-n, input.pos3D.yzy)); The n vector basically selects the side of the cube, as exactly one coordinate is 1, the others are ...


2

Any thing drawn by OnGUI will be rendered or drawn in front of all 3d objects. however if your creating the GUITexture GameObject Then there is a way to do that The way to do this is to use two cameras. one purely a GUI camera with depth lower than that camera used to render 3d object. In the 3d cam set the culling mask to the layer on which your 3d ...



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