textures

A red rectangle drawn on 2D texture disappears right after being drawn

喜夏-厌秋 提交于 2019-12-04 05:49:19
问题 following my another question, I have provided the code that draws the rectangle as follows: void COpenGLControl::DrawRectangleOnTopOfTexture() { wglMakeCurrent(hdc, hrc); glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT); glDisable(target); glColor3f(1.0f,0.0f,0.0f); glBegin(GL_LINE_LOOP); glVertex2f(RectangleToDraw.at(0),RectangleToDraw.at(1)); glVertex2f(RectangleToDraw.at(0),RectangleToDraw.at(3)); glVertex2f(RectangleToDraw.at(2),RectangleToDraw.at(3)); glVertex2f(RectangleToDraw.at(2)

texturing using texelFetch()

别等时光非礼了梦想. 提交于 2019-12-04 05:44:16
When I pass non max values into texture buffer, while rendering it draws geometry with colors at max values. I found this issue while using glTexBuffer() API. E.g. Let’s assume my texture data is GLubyte, when I pass any value less than 255, then the color is same as that of drawn with 255, instead of mixture of black and that color. I tried on AMD and nvidia card, but the results are same. Can you tell me where could be going wrong? I am copying my code here: Vert shader: in vec2 a_position; uniform float offset_x; void main() { gl_Position = vec4(a_position.x + offset_x, a_position.y, 1.0, 1

Workaround for Texture2D.GetData method

倾然丶 夕夏残阳落幕 提交于 2019-12-04 05:41:43
I’m converting a game from XNA to iOS with Monogame. In the code snippet below, smallDeform is a Texture2D on which I call the GetData method. smallDeform = Game.Content.Load<Texture2D>("Terrain/..."); smallDeform.GetData(smallDeformData, 0, smallDeform.Width * smallDeform.Height); I’m having some problem with Monogame because the feature in iOS has not been implemented yet because it returns this exception. #if IOS throw new NotImplementedException(); #elif ANDROID I tried to serialize the data in a XML file from Windows to load the whole file from iOS. The serialized files weight more than

Texture partially off screen - performance difference

吃可爱长大的小学妹 提交于 2019-12-04 05:18:26
问题 On the picture is an example of two situations, where a textured polygon is being rendered. All done by Opengl ES2. A) the polygon is partially off the viewport B) the polygon is completely inside it My question: Is situation 'A)' going to consume less system/gpu resources*, because the texture is partially off screen, or will it perform just the same as if i rendered it inside of the viewport and why? *"Resources" - meaning speed, not memory. I know that opengl does calculate vertices first,

Three.js, custom shader and png texture with transparency

…衆ロ難τιáo~ 提交于 2019-12-04 04:47:58
I have an extremely simple PNG texture: a grey circle with a transparent background. I use it as a uniform map for a THREE.ShaderMaterial : var uniforms = THREE.UniformsUtils.merge( [basicShader.uniforms] ); uniforms['map'].value = THREE.ImageUtils.loadTexture( "img/particle.png" ); uniforms['size'].value = 100; uniforms['opacity'].value = 0.5; uniforms['psColor'].value = new THREE.Color( 0xffffff ); Here is my fragment shader (just part of it): gl_FragColor = vec4( psColor, vOpacity ); gl_FragColor = gl_FragColor * texture2D( map,vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) ); gl_FragColor

LibGDX Saving textures to avoid context loss

纵然是瞬间 提交于 2019-12-04 04:36:33
问题 I have a texture in my LibGDX based Android app that is created procedurally through FrameBuffers that I need to preserve through context loss, and it seems that the only efficient way to do this is to simply save the data, whether as a full image or raw data, out, and load it back in when the time comes. I'm struggling to find any way to achieve this though, as every route I've taken has lead to complete failure in one way or another. I've searched around quite a bit, but nothing I've come

Flipping OpenGL texture

房东的猫 提交于 2019-12-04 04:02:45
When I load textures from images normally, they are upside down because of OpenGL's coordinate system. What would be the best way to flip them? glScalef(1.0f, -1.0f, 1.0f); mapping the y coordinates of the textures in reverse vertically flipping the image files manually (in Photoshop) flipping them programatically after loading them (I don't know how) This is the method I'm using to load png textures, in my Utilities.m file (Objective-C): + (TextureImageRef)loadPngTexture:(NSString *)name { CFURLRef textureURL = CFBundleCopyResourceURL( CFBundleGetMainBundle(), (CFStringRef)name, CFSTR("png"),

Casting shadow on MeshPhongMaterial or MeshLambertMaterial in Three.js

时间秒杀一切 提交于 2019-12-04 03:46:39
I feel like I'm missing something simple here. I used JSFiddle by @WestLangley , which demonstrates how to cast a shadow from an object onto a plane. Everything works as expected when the plane is filled with just color: var groundMaterial = new THREE.MeshLambertMaterial({ color: 0xFF0000 }); Then I change it to use texture instead: var groundMaterial = new THREE.MeshLambertMaterial({ // color: 0xFF0000, map: texture }); ..all of a sudden, shadow is gone: This happens with both MeshPhongMaterial and MeshLambertMaterial . Note that neither camera position nor shadow configuration is changed.

cuda 3D texture Interpolation

拜拜、爱过 提交于 2019-12-04 02:53:50
问题 I am trying to interpolate a 3D array with cuda using texture memory with the code below. I have plotted the input f[x][y][z] to a fixed z value, then I interpolate my array for x and y and plot i again and they look totally different. I also tried this in 1 dimension (with a different code) and there it works so i assume that there must be an error in my code. Can you help me finding it? #include <cuda_runtime.h> #include <cuda.h> #include <iostream> #include <fstream> typedef float myType;

Referencing texels in a data texture using indexes in the shader

こ雲淡風輕ζ 提交于 2019-12-04 02:38:32
问题 I have values in the texels of a DataTexture that I am trying to access using indexes in my shader. The indexes [0, 1, 2, 3, 4, 5, 6... 62, 63] are continuous, while the data texture has a height and width ( uTextureDimension ) of 8. After some research I wrote this function to take a particular index value, and reference the corresponding texel: vec2 customUV = vec2( mod(aIndex, uTextureDimension) / uTextureDimension, floor(aIndex / uTextureDimension) / uTextureDimension ); vec4 texelValues