Tag Info

New answers tagged

0

I have a 'full width UI' script that deduces the aspect ratio of the screen relative to some reference screen dimensions, and adds a scale to the transform to compensate for a change in aspect ratio. Then I build my UI to the reference screen dimensions (in my case 1024 x 768). At runtime, the actual screen width is asked for, and the adjustment ratio ...


1

Without seeing your code, it's hard to give on solid answer, but here's an idea that might help you: The tail always points away from the previous piece of the snake. If we see the last piece of the snake as the tail, then the one that comes before it gives the direction of the connecting end of the tail, and the opposite direction is then the direction of ...


1

It should be either from the image file itself, or from a shader which rejects all perfectly white pixels, or something like that, but since the shader isn't the simplest thing to implement, I'll bet it's the image file. I'll also bet you made or found this image with a white background, then tried to delete that white to make the background transparent. ...


2

A simple method using only Photoshop: Crop the image vertically to remove anything that should be below the horizon (ie. not part of the sky dome) Scale up the height of the image to make it square Filter -> Distort -> Polar Coordinates


1

As Ben suggested, you could use a dummy call to glTexImage2D(). If setting a 0x0 texture doesn't work, you should be able to create a 1x1 texture. I've seen the WebKit source code do something similar to "allocate" texture IDs, and then call glTexImage2D/glTexSubImage2D to upload the actual texture data later. Of course, it's up to the driver whether it ...


1

No, there is not a simpler way. As you said, you must recreate all sampler objects that are affected by a change. However, it doesn't have to be a lot of work. Typically, you can share a few samplers across many shaders. I typically have a single sampler with trilinear/aniso filtering and repeat addressing, reused for textures across all shaders. If the ...


1

This is possible using GL 1.x and here's how. So as you've found using vertex colors, a smooth transition is where it blends the two colors. This is a called a linear interpolation, or a "lerp" for short. It can be generalized to any dimension by operating on the elements of the vector individually and indeed colors are treated like a lerp in 3D -- blend R1 ...


0

Neither. You want to load a single tile sheet once and load that single texture into the GPU with no cropping or copying. It's most efficient to actually draw from the tile sheet by figuring out the correct UV coordinates for a sprite in the sheet and then passing those to your draw commands. Individual textures should be avoided if you can, at least for ...


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


0

I assume you want to create something like a "jigsaw" puzzle. Off the top of my head, an algorithm that might get you started is as follows. Begin by splitting your image into equal pieces, it seems like the TextureRegion.split can do this for you. After this, you will have some pieces that have been split. Generate a 2D array mapping each puzzle pieces ...


1

You need a couple of things here - Something that will randomly spawn things Some way of knowing where sprites already exist so you don't spawn there It looks like you have a handle on the former so I will cover the latter here. For unity sprites you have a component called SpriteRenderer from which you can obtain the size of a sprite: Vector2 size = ...


1

You have to do two things here: Create a repeating sprite Mask it with the shape For the repeating sprite you will need a texture that has POT (Power Of Two) sides, e.g. 256x256. When you load your tiled texture you need to set its parameters to repeat: CCSprite* sprite = [CCSprite spriteWithFile:@"tiled_tex.png"]; ccTexParams params; params.minFilter ...


4

For texture spaces, in Direct3D (0, 0) is top-left, in OpenGL (0, 0) is bottom-left. Therefore the v-coordinate will be upside down in one of these APIs. However, I wouldn't recommend negating the v-coordinate as this will only work if you're using a sampler with wrapping. You can fix the v-coordinate as follows: v = 1.0f - v;


0

OK! I got it... The problem was that my program was using old dll opengl32.dll that was located in the same folder. After removing the old dll the rendering context automatically switched to the local dll's: atioglxx.dll for AMD and nvoglv32.dll for NVidia. So basically now the glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT); ...


-2

you will have to use random.range in which you will have to provide the minimum value and the maximum value . Hope this helps.


0

I changed the texture size to 1x1 instead of 2x2 and that seemed to fix it.


0

Firs things first, The texture coordinates are probably not that what you want. You probably want 0, 0, 0, 1, 1, 0, 1, 1 with a size of 2. Further you are using glVertexPointer and glTexCoordPointer with the value vertexSize, it is unclear what that is. It is probably 3 or the code would not render. Ensure that this is the number of values per vertex. The ...


4

Loading up DirectX (via SharpDX or XNA) to do the conversion is probably overkill. Why not simply decode the format on the CPU? It's simple enough. There is a DXT decoder in MonoGame you might be able to borrow. (In case the file changes, the latest revision at time of writing is here.) BC3_UNORM is equivalent to DXT5, which that will happily decode. ...


1

OpenGL provides blending function. glEnable(GL_BLEND);// you enable blending function glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // then you will set flags to achieve desired blending effect. For further different usage, read http://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml However for your particular case, the desired effect, ...


1

I do not believe that this is directly possible using OpenGL 1.x. If you're using OpenGL 1.3, you can use Texture Combiners to merge two textures together in various ways, and you can even specify different sets of texture coordinates for the two textures, but I do not believe it's possible to set different opacities for the different textures per vertex ...


0

The code you are using to switch between 2D and 3D seems OK. Your problem should be on the GL states. Usually, when rendering sprites and 2D GUI, I use the following states: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); Then when switching back to 3D, I normally set: ...


0

Yes, you can do that exactly as you describe. I made a 2D game a few years ago where an artist decided to make all our "sprites" as meshes in Blender, due partly to a limitation in the v1.0 of the engine that didn't support textures (the engine I wrote for the shipping version did, but the character art was already made and the meshes were smaller than the ...


0

A vertex is not just a spatial position, but a whole bag of attributes. A position p is a point in some spatial space or a homogeneous coordinate. A texcoord tc is a point in texture space. A normal n is a bivector, and so on. If you represented a vertex with multiple indices, a vertex V_k could be represented by a tuple of indices {p_a, tc_b, n_c}. In a ...


0

Not realistically, no. When you pack an image into a color channel, you make one of two trade-offs: 1) The first case is when you only need a single color channel (greyscale image). This is not true is the usual case. Your wood.png likely has a mix of RGB colors (giving it the brown tint). Note that you can actually ignore color in your images in some ...


3

It looks like you're applying way too much noise. You want to multiply the noise value by a small factor so it has a very small amplitude, corresponding to just a few pixels of distortion. Right now you're distorting it so much that every pixel is being sent to a completely different location in the texture, just making a hash of the whole thing. Also, ...


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


2

I would not use the content pipeline for this image. Instead I would load the image into a buffer using your choice of image loader (eg: System.Drawing.Bitmap). Then create a Texture2D of the desired final size and use SetData to fill it with the desired pixel data. Then unload the original image. There are two major reasons for doing this. First of all, it ...



Top 50 recent answers are included