texture-mapping

Texture mapping using a 1d texture with OpenGL 4.x

ぃ、小莉子 提交于 2020-01-02 07:26:12
问题 I want to use a 1d texture (color ramp) to texture a simple triangle. My fragment shader looks like this: #version 420 uniform sampler1D colorRamp; in float height; out vec4 FragColor; void main() { FragColor = texture(colorRamp, height).rgba; } My vertex shader looks like this: #version 420 layout(location = 0) in vec3 position; out float height; void main() { height = (position.y + 0.75f) / (2 * 0.75f); gl_Position = vec4( position, 1.0); } When drawing the triangle I proceed this way (I

How to use GL_REPEAT to repeat only a selection of a texture atlas? (OpenGL)

南楼画角 提交于 2020-01-01 04:03:06
问题 How can I repeat a selection of a texture atlas? For example, my sprite (selection) is within the texture coordinates: GLfloat textureCoords[]= { .1f, .1f, .3f, .1f, .1f, .3f, .3f, .3f }; Then I want to repeat that sprite N times to a triangle strip (or quad) defined by: GLfloat vertices[]= { -100.f, -100.f, 100.f, -100.f, -100.f, 100.f, 100.f, 100.f }; I know it has something to do with GL_REPEAT and textureCoords going passed the range [0,1] . This however, doesn't work: (trying to repeat N

How to plot a surface with a texture map

孤街醉人 提交于 2019-12-30 05:15:07
问题 I want to plot a surface with a texture map on it, but the conditions are not the "ideal" ones. first lets explain what I have. I have a set of points (~7000) that are image coordinates, in a grid. This points do NOT define perfect squares. IT IS NOT A MESHGRID . For the sake of the question, lets assume that we have 9 points. Lets ilustrate what we have with an image: X=[310,270,330,430,410,400,480,500,520] Y=[300,400,500,300,400,500,300,400,500] Lets say we can get the "structure" of the

correct glsl affine texture mapping

主宰稳场 提交于 2019-12-29 07:53:09
问题 i'm trying to code correct 2D affine texture mapping in GLSL. Explanation: ...NONE of this images is correct for my purposes. Right (labeled Correct) has perspective correction which i do not want. So this: Getting to know the Q texture coordinate solution (without further improvements) is not what I'm looking for. I'd like to simply "stretch" texture inside quadrilateral, something like this: but composed from two triangles. Any advice (GLSL) please? 回答1: This works well as long as you have

Why can I not load a texture into my app?

可紊 提交于 2019-12-24 15:44:57
问题 I think texture mapping is a really easy task. Actually, I implemented it many times but failed in this time and don't know why? And I can guarantee that the route to load the texture is right. Any other reasons for my confusion? Here is my code: GLuint mytexture; // two functions below come from NeHe's tut. I think it works well. AUX_RGBImageRec *LoadBMP(CHAR *Filename) { FILE *File=NULL; if (!Filename) { return NULL; } File=fopen(Filename,"r"); if (File) { fclose(File); return

Colouring individual triangles in a TriangleMesh through texture map is inaccurate

我的未来我决定 提交于 2019-12-24 07:42:00
问题 The problem I am having is that I want to color complex models (+4k triangles) without having to split the models up into many TriangleMesh objects. From my understanding this can only be done through mapping the colors onto an image and then calculate the texture coordinates of each color pixel in the image. Which I have done below: val uniqueColors = colors.toHashSet() val colorTexCoordsMap = HashMap<Color, FloatArray>() val atlas = WritableImage(uniqueColors.size, 1) for((index, color) in

opengl texture mapping off by 5-8 pixels

爱⌒轻易说出口 提交于 2019-12-23 20:56:21
问题 I've got a bunch of thumbnails/icons packed right up next to each other in a texture map / sprite sheet. From a pixel to pixel relationship, these are being scaled up from being 145 pixels square to 238 screen pixels square. I was expecting to get +-1 or 2 pixel accuracy on the edges of the box when accessing the texture coordinates, so I'm also drawing a 4 pixel outline overtop of the thumbnail to hide this probable artifact. But I'm seeing huge variations in accuracy. Sometimes it's off in

Mapping irregular shapes or other polygons (cartoons, sprites) to triangles in OpenGL ES

拥有回忆 提交于 2019-12-23 13:03:28
问题 I don't understand the concept of showing sprites mapped into OpenGL Triangles. If OpenGL ES only draws triangles and points, How do you display/map non-triangular shapes? Why would a shape mapped to a triangle not be distorted? To explain: In my mind, mapping, say, a sprite of Mario, to a triangle would produce a distorted or cropped Mario. In such a case, the head would be squished or invisible. 回答1: If I've understood the concern correctly: you simply divide the square into two triangles,

iphone opengl es 2.0 non power of two

醉酒当歌 提交于 2019-12-23 04:22:12
问题 I thought the image file size doesn't have to be power of two in 2.0 but when I tried, it just showed black screen. But it works fine with power of two images. Can anyone give me some hint what I am missing or I should do to use NPOT images? Thank you 回答1: OpenGL ES for iOS requires Power-of-Two images, unfortunately, as it is a rather strict implementation (case in point, look at all of the stuff that is not available in OpenGL ES). If your image is non-power-of-two there are a few solutions

OpenGL Texture Sampling not working

心已入冬 提交于 2019-12-23 02:47:07
问题 I'm using VC++10 + OpenGL + the Assimp Library to consume and then render some 3D models. The code is rendering the positions correctly, but for some reason the textures are seriously bugged. My texcoords appear to be loading correctly as are the texture files themselves - however I can't help but feel that the issue must be located with the loaded textures themselves. www.flickr.com/photos/95269725@N02/8685913640/in/photostream { i seem to have a lack of rep to post inline images } * ** * **