textures

How do I apply proper perspective to this OpenGL ES texture?

旧城冷巷雨未停 提交于 2019-11-29 05:22:32
I would like to describe my objective and get some feedback of a proposed solution. I am quite new to OpenGL ES (or OpenGL at all), so please be gentle. I would also like to mention that the platform is iPad (iOS) with it's belonging restrictions. Objective: To let the user place vertices in which a texture should be drawn properly in the correct perspective (or at least adjustable perspective). To explain what I mean, consider the following example. Let's say that we have a photograph of a house with a corresponding lawn in front of it. Now, I want to pave a (user) specified path with tiles

THREE JS TextureLoader

走远了吗. 提交于 2019-11-29 05:13:33
I am trying to add texture to a model that I converted to json and imported from 3ds Max. I searched but didn't find any code online which applies texture to json models using three.js r53. I guess the way Three.js handles textures changed from previous version. Any guidance? Following is my code: var texloader = new THREE.TextureLoader(); var tex=texloader.load("second.jpg"); var mat = new THREE.MeshBasicMaterial({ map: tex }); loader = new THREE.JSONLoader(); loader.load( "js/JsonModels/toothz.js", function( geometry, mat ) { mat[0].shading = THREE.SmoothShading; var material = new THREE

Three.js Update Texture image

守給你的承諾、 提交于 2019-11-29 04:28:59
I'm using three.js to create a minecraft texture editor, similar to this . I'm just trying to get the basic click-and-paint functionality down, but I can't seem to figure it out. I currently have textures for each face of each cube and apply them by making shader materials with the following functions. this.createBodyShaderTexture = function(part, update) { sides = ['left', 'right', 'top', 'bottom', 'front', 'back']; images = []; for (i = 0; i < sides.length; i++) { images[i] = 'img/'+part+'/'+sides[i]+'.png'; } texCube = new THREE.ImageUtils.loadTextureCube(images); texCube.magFilter = THREE

How do I blend two textures with different co-ordinates in OpenGL ES 2.0 on iPhone?

帅比萌擦擦* 提交于 2019-11-29 04:06:17
I can blend two textures with different blending modes in the fragment shader when both the textures covers the same rectangles. But now my problem is, one texture is a plain rectangle with no rotation and the other texture is another rectangle with a rotation/scale and translation. How do I merge these textures in the way I want? (In the picture) I know how to do this... But not sure how to do this... For blending textures in one rectangle (the first image), I used the following code.. Objective C code... - (void) display { [EAGLContext setCurrentContext:context]; glBindFramebuffer(GL

How to use GL_HALF_FLOAT_OES typed textures in iOS?

瘦欲@ 提交于 2019-11-29 02:02:46
I'm trying to create a float texture to store intermediate results of my rendering pipeline created by a fragment shader. I need the values of the fragments to be signed floats . I understand that there is the OES_texture_float extension which should be supported by all new iOS devices (i.e. beginning from iPhone 3GS/iPod Touch 3/iPad according to the Apple guide ). However, when I create such a texture using glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_HALF_FLOAT_OES, NULL); start my app and inspect it in Instruments, it tells me: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,

How to remove gaps between tiled textures?

ε祈祈猫儿з 提交于 2019-11-29 01:53:14
I'm using LibGDX to make a platformer. I'm using square tiles for the platforms but when they are drawn some of them have gaps between them. When I zoom in/out or move the camera around the gaps move position. More details: Tiles are 32x32 and I have tried both 32x32 and 64x64. Tiles are lined up 32 pixels apart (e.g. first tile would be x=0 y=0, second x=32 y=0, and so on in both x and y directions). The gaps are not texture artifacts as I have checked this. I use the TexturePacker with padding. My best guess is that it is a problem when converting the textures to screen coords but have no

How to get texture data using textureID's in openGL

孤人 提交于 2019-11-29 01:08:44
I'm writing some code where all I have access to is a textureID to get access to the required texture. Is there any way that I can get access to the RGB values of this texture so I can perform some computations on it? EDIT: I am looking for the inverse of glTexSubImage2D . I want to get the texture data rather than replace it. You are probably looking for glGetTexImage (see https://www.khronos.org/opengl/wiki/GLAPI/glGetTexImage for further information). Before using glGetTexImage , don't forget to use glBindTexture ( https://www.khronos.org/opengl/wiki/GLAPI/glBindTexture ) with your texture

How to copy texture1 to texture2 efficiently?

我怕爱的太早我们不能终老 提交于 2019-11-28 23:32:41
I want to copy texture1 to texture2. The most stupid way is copying tex1 data from GPU to CPU, and then copy CPU data to GPU. The stupid code is as below: float *data = new float[width*height*4]; glBindTexture(GL_TEXTURE_2D, tex1); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, data); glBindTexture(GL_TEXTURE_2D, tex2]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, data); As I know, it must exist a method that supports data copying from GPU tex to GPU tex without CPU involved. I consider about using FBO that rendering a tex1 quad to tex2. But somehow I

WebGL create Texture

假装没事ソ 提交于 2019-11-28 23:21:21
I successfully created a WebGL texture from an image and drew it into a canvas element. function initTexture(src) { texture = gl.createTexture(); texture.image = new Image(); texture.image.onload = function() { handleLoadedTexture(texture) } texture.image.src = src; } I also tried to create a texture from one of these datatypes, but without success. [object ImageData] [object CanvasPixelArray] [object CanvasRenderingContext2D] Is it possible to create a texture just with an image's pixel array ? Or in other words: Is it possible to create a JS Image object out of a pixel array? Edit: The pixel

Three.js - multiple material plane

被刻印的时光 ゝ 提交于 2019-11-28 22:05:28
I'm trying to have mutiple materials on a single plane to make a simple terrain editor. So I create a couple of materials, and try to assign a matetrial index to each vertex in my plane: var materials = []; materials.push(new THREE.MeshFaceMaterial( { color: 0xff0000 })); materials.push(new THREE.MeshFaceMaterial( { color: 0x00ff00 })); materials.push(new THREE.MeshFaceMaterial( { color: 0x0000ff })); // Plane var planegeo = new THREE.PlaneGeometry( 500, 500, 10, 10 ); planegeo.materials = materials; for(var i = 0; i < planegeo.faces.length; i++) { planegeo.faces[i].materialIndex = (i%3); }