texture-mapping

2D Texture gets distorted when making a sub-pixel translation

空扰寡人 提交于 2019-12-07 16:23:10
问题 I would like to know a theoretical reasoning why is this even possible: how translation of the geometry is related to the texture mapping. I can only notice this effect when making a sub-pixel translation, texture looks fine if translated by entire pixel(s). I am using orthographic projection, GL_CLAMP_TO_EDGE , GL_NEAREST , fragment shader is highp . Texture coordinates is a subregion of the atlas, but I can see the distortion even if the entire atlas is mapped. Using OpenGL ES (Android and

Fixed texture size in Three.js

[亡魂溺海] 提交于 2019-12-07 07:49:56
问题 I am building quite a complex 3D environment in Three.js (FPS-a-like). For this purpose I wanted to structure the loading of textures and materials in an object oriënted way. For example; materials.wood.brownplank is a reusable material with a certain texture and other properties. Below is a simplified visualisation of the process where models uses materials and materials uses textures. loadTextures(); loadMaterials(); loadModels(); //start doing stuff in the scene I want to use that material

Mapping a square texture to a triangle

二次信任 提交于 2019-12-07 07:31:16
I started to play with a OpenGL ES 1.0 and I run into some (beginners) problem: I tried to map a square texture to the cube described by triangles. // Turn necessary features on glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_SRC_COLOR); glEnable(GL_CULL_FACE); //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Bind the number of textures we need, in this case one. glGenTextures(1, &texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

Android: OpenGL ES 2.0 - Texture always black

雨燕双飞 提交于 2019-12-06 10:36:56
问题 I'm trying to show a simple texture in OpenGL ES 2.0 (Android 4.0.4, Galaxy Nexus) as fullscreen background using a vertex and a fragment shader. The final result should be to display the camera image there, but for a start, simple texture from a file would be sufficient. I tested many things and for a short while it worked as I used OpenGL ES 1.x but as I plan to use shader for YUV->RGB conversion, I have to go with 2.0. I have the following vertex shader: attribute vec4 position; attribute

sphere texture mapping error

為{幸葍}努か 提交于 2019-12-06 07:47:39
i use D3DXCreateSphere method to create sphere mesh. and i want to apply an earth texture on it. i calculate the texture coordinate in pixel shader with following code: sampler ShadeSampler = sampler_state { Texture = (ShadeTex); AddressU = Mirror; AddressV = Mirror; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; }; PS_OUTPUT PSMain(VS_OUTPUT input){ PS_OUTPUT output = (PS_OUTPUT)0; vector uv; uv.x = 0.5 + atan2(input.normal.z, input.normal.x) / piMul2; uv.y = 0.5f - asin(input.normal.y) / pi; vector b = tex2D(ShadeSampler, uv.xy); output.diffuse = b * input.diffuse; return output

How to texture a random convex quad in openGL

浪子不回头ぞ 提交于 2019-12-06 07:37:55
Alright, so I started looking up tutorials on openGL for the sake of making a minecraft mod. I still don't know too much about it because I figured that I really shouldn't have to when it comes to making the small modification that I want, but this is giving me such a headache. All I want to do is be able to properly map a texture to an irregular concave quad. Like this: I went into openGL to figure out how to do this before I tried running code in the game. I've read that I need to do a perspective-correct transformation, and I've gotten it to work for trapezoids, but for the life of me I can

interpolated texture coordinates

*爱你&永不变心* 提交于 2019-12-06 06:40:52
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 I render the quad (as a triangle strip) into a 128x128 texture map attached to a FBO as follows:

GLES20 Texture Not Working on Some Devices

偶尔善良 提交于 2019-12-06 05:05:12
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 how to specifically architect GL textures for these devices (maybe there are issues with the devices).

Texture mapping using a 1d texture with OpenGL 4.x

强颜欢笑 提交于 2019-12-06 03:48:27
I want to use a 1d texture (color ramp) to texture a simple triangle. My fragment shader looks like this: #version 420 uniform sampler1D colorRamp; in float height; out vec4 FragColor; void main() { FragColor = texture(colorRamp, height).rgba; } My vertex shader looks like this: #version 420 layout(location = 0) in vec3 position; out float height; void main() { height = (position.y + 0.75f) / (2 * 0.75f); gl_Position = vec4( position, 1.0); } When drawing the triangle I proceed this way (I removed error checking form code for better readability): glUseProgram(program_); GLuint samplerLocation

2D Texture gets distorted when making a sub-pixel translation

我与影子孤独终老i 提交于 2019-12-06 02:28:57
I would like to know a theoretical reasoning why is this even possible: how translation of the geometry is related to the texture mapping. I can only notice this effect when making a sub-pixel translation, texture looks fine if translated by entire pixel(s). I am using orthographic projection, GL_CLAMP_TO_EDGE , GL_NEAREST , fragment shader is highp . Texture coordinates is a subregion of the atlas, but I can see the distortion even if the entire atlas is mapped. Using OpenGL ES (Android and iOS), but please before retagging could anyone explain that this is not an issue in OpenGL. Things I've