texture-mapping

OpenGL - 2D Texture Mapping

时光总嘲笑我的痴心妄想 提交于 2019-12-03 15:25:56
I'm trying to render a simple texture(64x64) to a 64x64 quad. The quad itself is rendering, but, not the texture. (It's rendering a blank white 64x64 quad.) I'm using SOIL to load the image. static GLuint LoadPNG(char* filename) { GLuint texture = SOIL_load_OGL_texture ( filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT ); if (texture == 0) Log("Texture Load Error: " + string(filename)); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); return

D3D11: Creating a cube map from 6 images

一曲冷凌霜 提交于 2019-12-03 13:44:13
问题 How do I create a cube map in D3D11 from 6 images? All the examples I've found use only one .dds. Specifically, how do I upload individual faces of the cube texture? 回答1: It works like this: D3D11_TEXTURE2D_DESC texDesc; texDesc.Width = description.width; texDesc.Height = description.height; texDesc.MipLevels = 1; texDesc.ArraySize = 6; texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; texDesc.CPUAccessFlags = 0; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11

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

梦想与她 提交于 2019-12-03 10:00:29
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 = 10) GLfloat textureCoords[]= { 10.1f, 10.1f, 10.3f, 10.1f, 10.1f, 10.3f, 10.3f, 10.3f }; We're

OpenGL4.5 - bind multiple textures and samplers

六月ゝ 毕业季﹏ 提交于 2019-12-03 05:56:54
I'm trying to understand Textures, Texture Units and Samplers in OpenGL 4.5. I'm attaching a picture of what I'm trying to figure out. I think in my example everything is correct, but I am not so sure about the 1D Sampler on the right side with the question mark. So, I know OpenGL offers a number of texture units/binding points where textures and samplers can be bound so they work together. Each of these binding points can support one of each texture targets (in my case, I'm binding targets GL_TEXTURE_2D and GL_TEXTURE_1D to binding point 0 , and another GL_TEXTURE_2D to binding point 1 ).

Texture map for a 2D grid

你。 提交于 2019-12-03 03:50:11
I have a set of points [x,y]=meshgrid(1:N,1:M) defined on a regular 2D, N x M grid. I have another set of points [u,v] that are some deformation of the original grid, i.e [u,v]=f(x,y)' (however I do not have the actual f that caused the deformation). How can I map a texture to the "deformed" grid defined by u,v ? i.e., given an image with aspect-ratio N/M how can I map it to the deformed grid? I think you are asking to get samples of the original texture at [u,v] . You can use interp2 . Let's say that the texture samples are in z and you want new samples z2 . To interpolate the original

D3D11: Creating a cube map from 6 images

走远了吗. 提交于 2019-12-03 03:42:10
How do I create a cube map in D3D11 from 6 images? All the examples I've found use only one .dds. Specifically, how do I upload individual faces of the cube texture? It works like this: D3D11_TEXTURE2D_DESC texDesc; texDesc.Width = description.width; texDesc.Height = description.height; texDesc.MipLevels = 1; texDesc.ArraySize = 6; texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; texDesc.CPUAccessFlags = 0; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11_USAGE_DEFAULT; texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; texDesc.CPUAccessFlags = 0; texDesc.MiscFlags

THREE.js Geometry map does not appear

删除回忆录丶 提交于 2019-12-02 16:35:13
问题 Following I'm loading a image map on a custom geometry, it represents the brown colored geometry on the picture above: var aqua_ground_geo = new THREE.Geometry(); var top0 = new THREE.Vector3(aqua_ground_geo_x_NEG, user_data['aqua_soil_calc_b_y'], aqua_ground_geo_z_NEG); var top1 = new THREE.Vector3(aqua_ground_geo_x_POS, user_data['aqua_soil_calc_b_y'], aqua_ground_geo_z_NEG); var top2 = new THREE.Vector3(aqua_ground_geo_x_NEG, user_data['aqua_soil_calc_f_y'], aqua_ground_geo_z_POS); aqua

Creating texture from getImageData (Javascript)

百般思念 提交于 2019-12-02 09:09:29
问题 It is possibile to create a texture (to use on a element in a canvas) from the getImageData array of another canvas (in the same html page)? maybe without three.js? Thanks a lot, Jennifer 回答1: The coolest thing about WebGL's texImage2D method is that its last argument can be a DOM element instead of an ArrayBuffer, in which case it copies its rendered content into your texture object. For example: var canvas2d = document.getElementById('canvas2d'); gl.bindTexture(gl.TEXTURE_2D, myTexture); gl

glsl & perspective correction of varying values

核能气质少年 提交于 2019-12-02 07:58:54
问题 is every varying vertex value (or in newer versions of glsl values that go "out" of a vertex shader) interpolated by the rasterizer using perspective correction? is this hardware dependant? when clipping occurs, how are the values at the clipping vertices calculated? I try to undo perspective correction and notice strange behaviour for polygons that are clipped and I would like to understand better what is going on behind the scenes. 回答1: Pre-GL 3.0, the only way to affect perspective-correct

Creating texture from getImageData (Javascript)

孤街醉人 提交于 2019-12-02 06:03:11
It is possibile to create a texture (to use on a element in a canvas) from the getImageData array of another canvas (in the same html page)? maybe without three.js? Thanks a lot, Jennifer The coolest thing about WebGL's texImage2D method is that its last argument can be a DOM element instead of an ArrayBuffer, in which case it copies its rendered content into your texture object. For example: var canvas2d = document.getElementById('canvas2d'); gl.bindTexture(gl.TEXTURE_2D, myTexture); gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED