texture-mapping

interpolated texture coordinates

余生长醉 提交于 2019-12-22 18:14:42
问题 I am working on an OpenGL ES fluid simulation which uses texture maps to hold grid values. I need to iterate thru the grid that mimics the following loop: for (int r = 0; r < 128; r++) for (int c = 0; c < 128; c++) process grid element at (c,r) To iterate through the grid I am simply filling a quadrilateral which causes my fragment program to be invoked for each fragment. The texture coordinates (0,0), (1,0), (0,1), (1,1) are associated with the vertices (-1,-1), (+1,-1), (-1,+1), (+1,+1) and

Write to texture GLSL

微笑、不失礼 提交于 2019-12-22 13:57:40
问题 I want to be able to (in fragment shader) add one texture to another. Right now I have projective texturing and want to expand on that. Here is what I have so far : Im also drawing the viewfrustum along which the blue/gray test image is projected onto the geometry that is in constant rotation. My vertex shader: ProjTexCoord = ProjectorMatrix * ModelTransform * raw_pos; My Fragment Shader: vec4 diffuse = texture(texture1, vs_st); vec4 projTexColor = textureProj(texture2, ProjTexCoord); vec4

GLES20 Texture Not Working on Some Devices

不打扰是莪最后的温柔 提交于 2019-12-22 12:57:20
问题 I have tried to add a fairly simple extension on top of Android's example OpenGL 2.0 project in order to add texturing to basic shapes. This seems pretty straightforward, but on certain devices (Samsung Nexus S, LG Optimus 3D, Samsung Galaxy S) the texture just does not render. This is actually a problem that I am having on a much larger project, but I was able to reproduce the issue with the simple project below in the hope that someone here has an idea of where my code presents issues, or

OpenGL 3D Texture Coordinates

流过昼夜 提交于 2019-12-22 11:35:40
问题 I've got a problem with a 3d texture in OpenGL. I set the texture via glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE, 640, 480, 8, 0, GL_RED, GL_UNSIGNED_BYTE, tex3Ddata); with tex3Ddata being in total 8 slices of 640x480 bitmaps. Now when I try to access the different slices with texture coordinates, for some reason the images blend into each other, thus I don't properly set the coordinates, yet I do not know why. The texture slices itself are 8bit monochrome. Code for the displaying: for

Mapping Wavefront .obj texture vertex on OpenGL

给你一囗甜甜゛ 提交于 2019-12-22 06:56:01
问题 An artist gave me all 3D models for me exporting to .obj and .mtl in order that I can render it using OpenGL. But I can't figure out why the texture vertex are greater than 1 and sometimes negative. Take a look at this example: (...) vn -0.000717425 0.00106739 -0.00991695 vn 3.49779e-09 -5.22866e-09 -0.01 vn -0.00142294 0.00211706 -0.00966919 vn -0.00831486 -0.00555545 0 vt 5.82424 -20.091 vt 6.97527 -20.1873 vt 5.81848 -20.1618 vt -7.48189 8.29159 (...) He sent me all textures on TGA format,

How do I texture a cylinder in OpenGL created with triangle_strip?

孤人 提交于 2019-12-20 02:49:10
问题 Here's the cylinder I have created: void drawCylinder(float r, float g, float b) { setMaterialColors(r, g, b); glColor4f(r, g, b, 1.0); /* top triangle */ double i, resolution = 0.1; double height = 1, radius = 0.5; glPushMatrix(); glTranslatef(0, -0.5, 0); glBegin(GL_TRIANGLE_FAN); glVertex3f(0, height, 0); /* center */ for (i = 0; i <= 2 * PI; i += resolution) glVertex3f(radius * cos(i), height, radius * sin(i)); glEnd(); /* bottom triangle: note: for is in reverse order */ glBegin(GL

Power of two textures

北城以北 提交于 2019-12-19 09:19:36
问题 Can you explain me, why hardware acceleration required for a long time textures be power of two? For PCs, since GeForce 6 we achieved npot textures with no-mips and simplified filtering. OpenGL ES 2.0 also supports npot textures without mipmaps and etc. What is the hardware restriction for this? Just simplified arithmetics? 回答1: I imagine it has to do with being able to use bitwise shift-left operations, rather than multiplication to convert an (x, y) coordinate to a memory offset from the

OpenGL ES 2.0 texture distortion on large geometry GL_REPEAT

落花浮王杯 提交于 2019-12-18 03:42:24
问题 OpenGL ES 2.0 has serious precision issues with texture sampling - I've seen topics with a similar problem, but I haven't seen a real solution to this "distorted OpenGL ES 2.0 texture" problem yet. This is not related to the texture's image format or OpenGL color buffers, it seems like it's a precision error. I don't know what specifically causes the precision to fail - it doesn't seem like it's just the size of geometry that causes this distortion, because simply scaling vertex position

Correct UV mapping Three.js

ぃ、小莉子 提交于 2019-12-17 20:31:35
问题 I'm trying to map the UV-texture correctly, but failing... I've got the next result in my app: The result isn't that I was awaiting. I want to have the next described view: The source code is here: http://pastebin.com/aDg981Bk 回答1: You need to look at PlaneGeometry.js and understand how the UVs are set. Then you will be able to figure out how to reset them. This should work -- there are two triangles per "face". for(var i = 0; i < geometry.faces.length / 2; i++) { geometry.faceVertexUvs[ 0 ]

Bump-map a sphere with a texture map

自作多情 提交于 2019-12-17 17:23:51
问题 We would like to bump-map a sphere with a texture map. However, the surface of the sphere has an area that is 10 times the area of the texture map(area for both in pixels). Describe different ways in which the texture map can be used for bump mapping. 回答1: usually rectangle texture is used for spheres texture (u,v) coordinates are used as angles for spherical coordinates. The result is that texels are bigger near equator and smaller near poles. At poles all the texels merge to single pixel.