textures

THREE JS TextureLoader

廉价感情. 提交于 2019-11-27 22:39:37
问题 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

Cluster texture based on features extracted from Gabor

时光总嘲笑我的痴心妄想 提交于 2019-11-27 22:30:27
I'm trying to cluster textures based on the features extracted from Gabor bank that I've created, but the result is far from what is typically expected so here is what I'm doing >> 1-generate a filter bank (based on the Miki's answer here I'm getting both real and imaginary part so that I can later extract Magnitude feature) void Gabor::generateFilterbank(int bankRows,int bankCols) { bankCol=bankCols; bankRow=bankRows; setBankSize(); int thetaStep=pos_th_max/bankCols; int lambadaStep=(pos_lm_max/bankRows) /10; for (int i = 1; i <= bankRows; i++) // cols = theta rows = lambda for (int j = 1; j

cuda alignment 256bytes seriously?

穿精又带淫゛_ 提交于 2019-11-27 22:26:52
In "CUDA C Programming Guide 5.0", p73 ( also here ) says "Any address of a variable residing in global memory or returned by one of the memory allocation routines from the driver or runtime API is always aligned to at least 256 bytes". I do not know the exact meaning of this sentence. Could anyone show an example for me? Many thanks. A derivative question: So, what about allocating an one-dimensional array of basic elements (like int) or self-defined ones? The starting address of the array will be multiples of 256B, while the address of each element in the array is not necessarily multiples

Read pixels from a WebGL texture

三世轮回 提交于 2019-11-27 22:25:49
I have a WebGLTexture object. How do I get pixels of that texture (similar to WebGL's readPixels, but for a texture)? One idea I have is to create a canvas and a WebGL context with preserveDrawingBuffer=true, and render my texture on this canvas so that it shows 2D flat, and then use readPixels. Is this approach reasonable? Does anyone have a sample code for this? You can try attaching the texture to a framebuffer and then calling readPixels on the frame buffer. at init time // make a framebuffer fb = gl.createFramebuffer(); // make this the current frame buffer gl.bindFramebuffer(gl

Android OpenGL2.0 showing black textures

一曲冷凌霜 提交于 2019-11-27 21:36:22
I am trying to draw textures onto quads in OpenGL2.0. So far I got the quads to show up and everything, but the textures are not there - the quads are all black. My main suspicion is that i'm not mapping the textures correctly - my textures are not powers of 2, nor are they square - their width is in the field mWidth and their height in mRowHeight. The quads are drawn in a vertical list, which is done with a translate matrix. I'll be very grateful if anyone can go over this cause I'm desperate! Here's related code: Initializing the buffers: void initBuffers() { float r = (float) mRowHeight /

How can I find the maximum texture size for different phones?

回眸只為那壹抹淺笑 提交于 2019-11-27 21:22:30
I'm trying to find out the maximum texture size for the original Motorola Droid. I believe the G1 has a maximum texture size of 512, but it would be nice if there was a more official way I could find out so I can build a proper tile system. You can request the max texture size using glGetIntegerv: int[] maxTextureSize = new int[1]; gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0); Log.i("glinfo", "Max texture size = " + maxTextureSize[0]); Also check out http://www.glbenchmark.com/ - it has an extensive database of OpenGL environment and performance details for mobile devices 来源:

Threading textures load process for android opengl game

旧巷老猫 提交于 2019-11-27 20:49:46
I have a large amount of textures in JPG format. And I need to preload them in opengl memory before the actual drawing starts. I've asked a question and I've been told that the way to do this is to separate JPEG unpacking from glTexImage2D(...) calls to another thread. The problem is I'm not quite sure how to do this. OpenGL (handler?), needed to execute glTexImage2D is only available in GLSurfaceView.Renderer's onSurfaceCreated and OnDrawFrame methods. I can't unpack all my textures and then in onSurfaceCreated(...) load them in opnegl, because they probably won't fit in limited vm's memory

Multiple textures in GLSL - only one works

非 Y 不嫁゛ 提交于 2019-11-27 20:07:41
My problem is getting more than one texture accessible in a GLSL shader. Here's what I'm doing: Shader: uniform sampler2D sampler0; uniform sampler2D sampler1; uniform float blend; void main( void ) { vec2 coords = gl_TexCoord[0]; vec4 col = texture2D(sampler0, coords); vec4 col2 = texture2D(sampler1, coords); if (blend > 0.5){ gl_FragColor = col; } else { gl_FragColor = col2; } }; So, I simply choose between the two color values based on a uniform variable. Simple enough (this is a test), but instead of the expected behavior, I get all black when blend <= 0.5 . OpenGL code: m_sampler0location

Read texture bytes with glReadPixels?

家住魔仙堡 提交于 2019-11-27 19:51:58
I want to dump raw texture data to disk (to read back later), and I'm not sure about glReadPixel will read from the currently bound texture. How can I read the buffer from my texture? glReadPixels function reads from framebuffers, not textures. To read a texture object you must use glGetTexImage but it isn't available in OpenGL ES :( If you want to read the buffer from your texture then you can bind it to an FBO (FrameBuffer Object) and use glReadPixels : //Generate a new FBO. It will contain your texture. glGenFramebuffersOES(1, &offscreen_framebuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES

Three.js Update Texture image

不打扰是莪最后的温柔 提交于 2019-11-27 18:23:07
问题 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+'/'