Tag Info

Hot answers tagged

42

This looks like the bottom layer of a volume texture that many games these days use to perform color correction. The idea is that the final RGB screen color, after rendering and tonemapping, is used as a texture coordinate to index into this texture, and the color found in the texture replaces the original color. This allows artists to arbitrarily modify ...


22

Sounds like the scaling algorithm you're using isn't interpolating pixels. Pictures are best explained with pictures: It's the Major, first in full, then scaled down with Lanczos (left) and nearest-pixel (a.k.a. no interpolation) (right) to two sizes. The same comparison, in 3x magnified: Make sure the scaling you're using is resampling sensibly. For ...


14

We have a similar case with our RTS Remake. All units and houses are sprites. We have 18 000 sprites for units and houses and terrain, plus another ~6 000 for team colors (applied as masks). Long-stretched we also have some ~30 000 characters used in fonts. So the main reason behind atlases are: less wasted RAM (in older days when you upload NPOT to GPU ...


13

Since you've asked for experiences, here are mine. Back in the days when I was programming PS2 games, the "layered alpha quads" approach was a way that we often implemented fog. Occasionally as ground fog, but much more commonly as full-screen fog. And it worked just fine in either case. So yes, it was viable in the pre-fragment-shader days. Well, sort ...


9

I have no source code to provide you, but I will point you in the correct direction. "Taking a Picture" is a simple task when rendering a game, you simply need to make a copy of the back buffer before it is swapped at the end of the render stage of your game loop. If you then want to blur it, you will need to filter your image using one of many blur ...


9

You only need the textures bound when you'd need to refer to them during the rendering of an object. You do not need every texture you will ever use bound to the pipeline at once. Thus, to render the floor, you bind only the textures you need for the floor; then you render the floor. Then you bind only the textures you need for the NPCs, and render all the ...


9

The problem with using texture atlases and adjacent texels leaking has to do with the way linear texture filtering works. For any point in the texture that is not sampled exactly at the center of a texel, linear sampling will sample 4 adjacent texels and compute the value at the location you asked as the weighted (based on distance from the sample point) ...


9

One way to choose texture sizes is to have a target texel density relative to the size of an object. For instance, if you wanted 128 texels per meter, then an object 4 meters in size should have a 512x512 texture, an object 8 meters in size should have a 1024x1024 texture, etc. The same guideline can be applied to tiling textures as well. Another thing to ...


8

There are many reasons why you may be getting those lines. I wrote a more detailed answer in here, but the bottom line is: Do not do atlasing and mipmapping at the same time. For 2D, in general, you don't want/need to do mipmapping. That's useful mostly in 3D where you don't know the size at which your textures will be rendered, but that's usually ...


7

The colors in a normal map represent the normals at each point. If a normal is (x, y, z), the corresponding pixel in the normal map will have each of x, y, and z mapped from the range (-1,1) to (0,255) to get the red, green, and blue components respectively. Now the z-axis is typically used as the direction away from the surface. A perfectly flat surface, ...


7

Option #1: Split tubes into 2 parts, the tube and the rim. So that you stretch the tube to be as long as you need it and the rim part is always the same size. Option #2: Make the tubes to be always the same length and hide the ends behind the walls.


7

UV interpolation needs to take into account the depth of the vertices. You need to perform perspective-correct interpolation, which involves dividing by the w coordinate of the interpolated homogeneous vector. The "folded plane" effect of affine interpolation becomes more pronounced at wide FOV or when the camera is close to an object, but it's not ...


6

What you're looking for is something called "seamless" textures. Here are some tutorials for popular image editing programs: Photoshop (Youtube) Photoshop Gimp


6

Displacement mapping can mean (but doesn't always mean) a vector displacement at each point on the surface. Height mapping implies only a scalar displacement value, i.e. each point gets pushed along its normal. The term "displacement mapping" can also be used for scalar displacements, though, so when vector displacements are discussed, people often ...


6

texelFetch is quite different from texture. texture is your usual texture access function which handles filtering and normalized ([0,1]) texture coordinates. texelFetch directly accesses a texel in the texture (no filtering) using unnormalized coordinates (e.g. (64,64) in the middle-ish texel in a 128x128 texture vs (.5,.5) in normalized coordinates).


6

Well, technically speaking you can generate textures using any language. Even if you don't have any output on screen, as far as your language can represent integer/float (could get away with integers) and arrays, you are good to go. The problem though is that not every texture could be generated procedurally. You usually need a formula as a stating point to ...


6

It's easy to produce an effect like this in a pixel shader, using threshold animation. The idea is that you have a monochrome texture and apply a threshold value to it; wherever the texture is lower than the threshold, the material is colored, and where the texture is higher than the threshold the material is blank. You animate the threshold value from 0 ...


5

It’s likely that when loaded by your framework, the texture is padded vertically and horizontally to the nearest power of two. For instance, if it’s a 320×200 image, it will be stored in a 512×256 texture. You have at least two options: use a texture with power of two dimensions or change your texture coordinates to the proper ones, for instance ...


5

Not all textures use texture coordinates that come from the mesh data. For example, with projective texturing, you transform the world into the space of the texture. Well, a lot of that world falls outside the [0, 1] range of the texture. Without some sort of clamping mode in place, you're going to get problems.


5

You never call glEnable(GL_TEXTURE_2D); to switch on texturing. And since you seem to use the fixed function pipeline that means that only the currently set color (which is white by default is used) to draw. As for why the texture dimensions are not printed correctly: the format specifier %f expects a 64 bit double value on the stack (floats are ...


5

I have a tangentially related answer in here, but the general idea is that, if you're loading and drawing textures at different times (you're not loading additional textures while you're rendering), then there are two places where what you do will affect your performance: Loading time: This is the moment where you upload your textures into memory. The ...


5

Multiple texture coordinates per mesh what is their purpose? Multiple texture coordinates set can be used to achieve different texture mapping per mesh, this helps achieve different visual effects that are otherwise hard to accomplish and may require multi-pass rendering. What scenario would these be present? For example Reflection mapping ...


5

I believe this is the line giving you trouble. position.Y = 455; The way you're doing this, the X component of the velocity is getting smaller. direction is always changing. Even though the distance is closing on the X axis, it stays the same on the Y-axis. So, when it's normalized, the Y distance is relatively greater, so X will get smaller. Something ...


4

For older shader models, "global" variables are just mapped to GPU registers. They may be faster at a micro-timing level than texture lookups, but you probably won't have enough of them to sufficiently represent the data you want. Updating each constant variable would also have some overhead, but since you said updates will be quite rare, that may not be a ...


4

An approach I've seen taken is to simply convert the diffuse texture map to grayscale, or copy one of its RGB channels, and then fuss with it a bit (for instance, altering the levels, inverting part or all of the image, etc.) This can be useful if the specularity is reasonably well correllated with the diffuse color. It's still a manual process though; ...


4

It's true that many tangent-space normal maps have only a limited range of colors. Object-space or world-space normal maps would have a wider range of colors, but if we're only using tangent-space normal maps in our game (as most developers do), it's a quite legitimate question to ask why we don't choose an encoding that trades off the range that we're not ...


4

Well S and T just mean U and V (or X and Y if you prefer), or in GLSL: vec4.xyzw == vec4.rgba == vec4.strq The GL_REPEAT mode has textures repeat when you go past (0,0) to (1,1) range The GL_CLAMP_TO_EDGE mode has textures stop at the last pixel when you fall off the edge. The GL_CLAMP and GL_CLAMP_TO_BORDER are depreciated because all texture borders ...


4

if( (NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ), "GL_ARB_texture_non_power_of_two" ) ) ) //############ it points here ############// You are creating an OpenGL 3.2 context. glGetString(GL_EXTENSIONS) returns NULL because it has been deprecated in 3.0 and removed in 3.1. It was replaced by glGetStringi(GL_EXTENSIONS, i). See ...


4

Anisotropic filtering is used to diminish aliasing and blur effects of textures that are rendered in planes with angles not oblique (multiple of 90 degrees) in relation with the camera. In the shading pass you will be rendering the light volumes only, which don't have any texture attached to their geometry. Indeed, the only textures you will use are the ...


4

I've changed the shader according to the article suggested by Seth Battin. Now it performs perspectively correct quad texturing. Phew, bacon delivered: For the future generations that may never happen. The input is in a form of the line vertexes A1/A2, B1/B2 that creates diagonals (rather then sequential vertexes): public static Vector3 ...



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