textures

Blending transparent textures with depth

故事扮演 提交于 2019-11-30 15:45:40
问题 I am trying to blend textures which have transparent areas: glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, ...); glVertexPointer( 2, GL_FLOAT, 0, ... ); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 ); Unless I add glDisable(GL_DEPTH_TEST), transparent parts of the top textures overwrite everything beneath them (instead of blending). Is there any way to do this without disabling depth? I have tried various blending functions

Blending transparent textures with depth

℡╲_俬逩灬. 提交于 2019-11-30 15:21:40
I am trying to blend textures which have transparent areas: glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, ...); glVertexPointer( 2, GL_FLOAT, 0, ... ); glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 ); Unless I add glDisable(GL_DEPTH_TEST), transparent parts of the top textures overwrite everything beneath them (instead of blending). Is there any way to do this without disabling depth? I have tried various blending functions but none of the helped. Enabling depth test doesn’t actually sort your geometry by depth—in the usual

How to make a wave warp effect in shader?

五迷三道 提交于 2019-11-30 15:13:43
问题 I want to make a wave warp effect like this: But I can only create the normal sine wave. Here is my fragment shader: precision mediump float; varying vec2 v_texCoord; uniform sampler2D s_baseMap; vec2 SineWave( vec2 p ){ float pi = 3.14159; float A = 0.15; float w = 10.0 * pi; float t = 30.0*pi/180.0; float y = sin( w*p.x + t) * A; return vec2(p.x, p.y+y);  } void main(){ vec2 p = v_texCoord; vec2 uv = SineWave( p ); vec4 tcolor = texture2D(s_baseMap, uv); gl_FragColor = tcolor; } and result

OpenGL ES Texture Coordinates Slightly Off

吃可爱长大的小学妹 提交于 2019-11-30 11:53:12
问题 I'm trying to draw a subregion of a texture in OpenGL by specifying the coordinates I want. What's happening though is that, depending on the size of the image, it seems there's a slight offset in the origin of where it selects the texture coordinates. The offset amount seems to be less than the size of a pixel & the output is is blurred combination of neighboring pixels. Here's an idea of what I'm describing. In this case I'd want to select the 6x5 green/white region but what OpenGL is

Loading texture for OpenGL with OpenCV

99封情书 提交于 2019-11-30 11:42:35
问题 I have seen many code samples for loading textures for OpenGL , many of them a bit complicated to understand or requiring new functions with a lot of code. I was thinking that as OpenCV allows us to load any image format it can be a simple an efficient way to load textures to OpenGL , but I am missing something. I have this piece of code in c++ : cv::Mat texture_cv; GLuint texture[1]; int Status=FALSE; if( texture_cv = imread("stones.jpg")) { Status=TRUE; // Set The Status To TRUE

OpenGL ES 2.0 texture not showing on some device

瘦欲@ 提交于 2019-11-30 10:36:33
I found a 3D graphics framework for Android called Rajawali and I am learning how to use it. I followed the most basic tutorial which is rendering a shpere object with a 1024x512 size jpg image for the texture. It worked fine on Galaxy Nexus, but it didn't work on the Galaxy Player GB70. When I say it didn't work, I mean that the object appears but the texture is not rendered. Eventually, I changed some parameters that I use for the Rajawali framework when creating textures and got it to work. Here is what I found out. The cause was coming from where the GL_TEXTURE_MIN_FILTER was being set.

Cuda Create 3d texture and cudaArray(3d) from device memory

倖福魔咒の 提交于 2019-11-30 10:36:05
im trying to create a texture 3d from a part of a device array. To do this, these are my steps: malloc Device Array Write Device Array Create CudaArray (3D) Bind Texture to CudaArray The way im doing it it creates no compiler errors, but when i run cuda-memcheck it's failing when im trying to fetch data from the Texture. Invalid global read of size 8 .. Address 0x10dfaf3a0 is out of bounds Thats why i'm guessing i declared the texture Array wrong. here is how i access the texture: tex3D(NoiseTextures[i],x,y,z) The way im doing the steps mentioned above: 1.Malloc Device Array cudaMalloc((void *

Issue with transparent texture on 3D primitive, XNA 4.0

一世执手 提交于 2019-11-30 10:34:26
I need to draw a large set of cubes, all with (possibly) unique textures on each side. Some of the textures also have parts of transparency. The cubes that are behind ones with transparent textures should show through the transparent texture. However, it seems that the order in which I draw the cubes decides if the transparency works or not, which is something I want to avoid. Look here: cubeEffect.CurrentTechnique = cubeEffect.Techniques["Textured"]; Block[] cubes = new Block[4]; cubes[0] = new Block(BlockType.leaves, new Vector3(0, 0, 3)); cubes[1] = new Block(BlockType.dirt, new Vector3(0,

OpenGL texture atlas bleeding

拜拜、爱过 提交于 2019-11-30 09:52:46
I'm trying to draw a basic 2d ground mesh made up of smaller tiles from a texture atlas (note the 1 pixel transparent border): I render the tiles as texture quads using the following code: glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_SHORT, 0, &m_coords[0]); glTexCoordPointer(2, GL_FLOAT, 0, &m_uvs[0]); glDrawArrays(GL_TRIANGLES, 0, m

Simple OpenGL texture map not working?

风流意气都作罢 提交于 2019-11-30 09:50:06
I'm trying to figure out texture mapping in OpenGL and I can't get a simple example to work. The polygon is being drawn, though it's not textured but just a solid color. Also the bitmap is being loaded correctly into sprite1[] as I was successfully using glDrawPixels up til now. I use glGenTextures to get my tex name, but I notice it doesn't change texName1; this GLuint is whatever I initialize it to, even after the call to glGenTextures... I have enabled GL_TEXTURE_2D. Heres the code: GLuint texName1 = 0; glGenTextures(1, &texName1); glBindTexture(GL_TEXTURE_2D, texName1); glPixelStorei(GL