textures

two meshes, same texture, different offset?

不打扰是莪最后的温柔 提交于 2019-12-05 09:34:57
Using three.js, I'm working on a web page to display a flip cube (a.k.a. magic cube; see e.g. the video on this page ). On a flip cube, there are typically images that are spread out across multiple pieces of the cube. For example, the boat image shown above is spread across the faces of four cubelets. In three.js terms, there are multiple meshes that need to use the same image for their material texture, but each at a different offset. As far as I understand it, in three.js, offset is a property of a texture , not of a material or a mesh. Therefore, it would appear that you cannot have a

Bound CUDA texture reads zero

家住魔仙堡 提交于 2019-12-05 09:31:08
I try to read values from a texture and write them back to global memory. I am sure the writing part works, beause I can put constant values in the kernel and I can see them in the output: __global__ void bartureKernel( float* g_odata, int width, int height) { unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; if(x < width && y < height) { unsigned int idx = (y*width + x); g_odata[idx] = tex2D(texGrad, (float)x, (float)y).x; } } The texture I want to use is a 2D float texture with two channels, so I defined it as: texture<float2, 2,

webgl: share texture with other program/shader

浪尽此生 提交于 2019-12-05 08:53:20
问题 i have two shaders that use different vertexarrays and different uniform values but they use the same texture (spritesheet/atlas). is it possible for them to share the same texture (without causing the texture to be sent to the gpu twice)? background: My game has some serious performance issues on my laptop and they seem to be gpu related. My current implementation uses two canvases, one for my background and one for my foreground. they then get composed for the final image (draw onto 3rd

How to copy frontBuffer data to texture DirectX 9

送分小仙女□ 提交于 2019-12-05 08:33:55
问题 I can't seem to find a way to create a texture from the surface data I acquire through the front buffer data of my application This is the code I'm pretty sure is working (Direct X 9, C++) // capture screen IDirect3DSurface9* pSurface; g_pd3dDevice->CreateOffscreenPlainSurface(640, 480, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pSurface, NULL); g_pd3dDevice->GetFrontBufferData(0, pSurface); Now that I've got my frontBufferData, I would like to create a IDirect3DTexture9 object with it. This function

Texture Image processing on the GPU?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 08:07:14
I'm rendering a certain scene into a texture and then I need to process that image in some simple way. How I'm doing this now is to read the texture using glReadPixels() and then process it on the CPU. This is however too slow so I was thinking about moving the processing to the GPU. The simplest setup to do this I could think of is to display a simple white quad that takes up the entire viewport in an orthogonal projection and then write the image processing bit as a fragment shader. This will allow many instances of the processing to run in parallel as well as to access any pixel of the

How to apply textures to a quad in order to texture a cube?

我的未来我决定 提交于 2019-12-05 06:45:10
问题 Recently I have been looking into OpenGL, and I've got up to the stage were I want to texture things. I thought I would start with texturing a simple cube. I currently have this code, and understand fully how it works: #include <glut.h> #define WINDOW_WIDTH 400 #define WINDOW_HEIGHT 400 float angle = 30.0f; void Draw() { glLoadIdentity(); //Reset the drawing perspective glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clears the buffers //Add positioned light GLfloat lightColor0[] = {0

How to draw a texture into a quad with OpenGL ES 2?

狂风中的少年 提交于 2019-12-05 06:44:06
Quads are not included in OpenGL ES 2.0 as they were in 1.1. With the programmable pipeline offered by OpenGL ES 2.0, how can I simply draw a texture (originally a png file) into 4 defined points? Do I need a VBO? Do I need to compute a perspective matrix? All these things are messy for me... The platform used is the iPhone. Stéphane Péchard I found the answer. It is mandatory to use a perspective matrix and a shader, even for such a simple task. This answer helped me to do it. Here is the code I used, with functions es*() from this book : // generate an orthographic matrix

Directx 11, send multiple textures to shader

守給你的承諾、 提交于 2019-12-05 06:42:47
using this code I can send one texture to the shader: devcon->PSSetShaderResources(0, 1, &pTexture); Of course i made the pTexture by: D3DX11CreateShaderResourceViewFromFile Shader: Texture2D Texture; return color * Texture.Sample(ss, texcoord); I'm currently only sending one texture to the shader, but I would like to send multiple textures, how is this possible? Thank You. By using Texture Arrays . When you fill out your D3D11_TEXTURE2D_DESC look at the ArraySize member. This desc struct is the one that gets passed to ID3D11Device::CreateTexture2D . Then in your shader you use a 3rd texcoord

Losing OpenGL Textures in Android after a resume

强颜欢笑 提交于 2019-12-05 05:14:16
My game is working correctly except in the case where I press the HOME button then resume. What needs to be done to use the textures again? I have tried calling onPause and onResume on the GLSurfaceView (when the activity's onPause and onResume are called). Any ideas what I could be doing wrong? If all else fails, reload the textures: Pseudocode for tex in textures: if glIsTexture(tex.opengl_name) == false: glGenTextures(1, &tex.opengl_name) glBindTexture(tex.texture_target); glTexImage(..., texture.image); Even if you fixed your problem, just to give a bit of explanation that might help

Xna 4.0 3D Vertex example

感情迁移 提交于 2019-12-05 04:29:13
问题 I'm currently trying to make a simple square by combining two triangles, like in the tutorials by Riemer (Link to tutorial), but since a lot has changed from 3.x to 4.0, I find it difficult. I would also like to know how to texture this "square", so if anyone could help me by giving some example or whatsoever, I would appreciate it :) Thanks! Basic 回答1: Here is an example XNA 4.0 program that draws a simple textured square. It requires the Green-gel-x texture (from wiki-commons - link in code