opengl-es

Directional lighting is not constant in OpenGL ES 2.0/3.0

柔情痞子 提交于 2021-01-28 13:42:23
问题 Problem: The direction of the directional light changes when the position of the object changes. I watched posts with a similar problem: Directional light in worldSpace is dependent on viewMatrix OpenGL directional light shader Diffuse lighting for a moving object Based on these posts, I tried to apply this: #version 300 es uniform mat4 u_mvMatrix; uniform mat4 u_vMatrix; in vec4 a_position; in vec3 a_normal; const vec3 lightDirection = vec3(-1.9, 0.0, -5.0); ... void main() { vec3

Trying to programmatically resize OpenGL cube

淺唱寂寞╮ 提交于 2021-01-28 12:26:12
问题 I am trying to implement functionality to resize my OpenGL cube, either via slider or button press. I have toyed around with a few things, none of which seem to work. The first thing I tried to do was create a function that returns the vertex array, and call this on button press passing in the value I would like to scale the cube by. This does not update the cube being rendered, however. I next tried to use glScalef , but this only made my shape disappear completely (i was scaling by non-zero

Convert an android.graphics.Matrix to a GL mat4?

元气小坏坏 提交于 2021-01-28 10:47:29
问题 I have a somewhat different issue than How to convert a 3x3 rotation matrix into 4x4 matrix?: I'm writing 2D OpenGL code that manipulates textures on a flat (z always equals 0) geometry. The android.graphics.Matrix class has many handy, debugged convenience methods that can do things like rotate about an explicit pivot point. Isn't converting a 3x3 matrix (that can do 2D affine transformations) to a 4x4 matrix a matter of a11 a12 a13 a11 a12 0 a13 a21 a22 a23 a21 a22 0 a23 a31 a32 a33 0 0 1 0

Convert an android.graphics.Matrix to a GL mat4?

亡梦爱人 提交于 2021-01-28 10:42:59
问题 I have a somewhat different issue than How to convert a 3x3 rotation matrix into 4x4 matrix?: I'm writing 2D OpenGL code that manipulates textures on a flat (z always equals 0) geometry. The android.graphics.Matrix class has many handy, debugged convenience methods that can do things like rotate about an explicit pivot point. Isn't converting a 3x3 matrix (that can do 2D affine transformations) to a 4x4 matrix a matter of a11 a12 a13 a11 a12 0 a13 a21 a22 a23 a21 a22 0 a23 a31 a32 a33 0 0 1 0

OpenGL ES:Purpose of calling glClear on every frame

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-27 15:06:10
问题 I'am new to OpenGL ES and I try to draw triangle,but I can't understand what is a purpose of calling glClear(GL10.GL_COLOR_BUFFER_BIT) on every frame?Without it some strange artifacts occur on screen.Should I call this every time at every frame beginning? Thanks 回答1: Simplified: If you draw a triangle, only the part of the framebuffer that actually contains the triangle is being redrawn. So if you draw it once, then shift it a little bit and draw it again in the next frame, without a call to

How to render OBJ or FBX in Android?

♀尐吖头ヾ 提交于 2021-01-27 06:53:26
问题 I have couple of 3D objects in .obj and .fbx format with included mtl and texture files. I would like to know which is the best library to render those in Android. All I want to achieve is to display the 3D object inside activity, and add touch gestures (drag and pinch zoom). 回答1: After trying both Rajawali and libGDX I can say Rajawali is a bit easier to implement if the intention is not game development. Here is the link to Rajawali library : GitHub Link Their support is really good and

How to render OBJ or FBX in Android?

时光毁灭记忆、已成空白 提交于 2021-01-27 06:51:57
问题 I have couple of 3D objects in .obj and .fbx format with included mtl and texture files. I would like to know which is the best library to render those in Android. All I want to achieve is to display the 3D object inside activity, and add touch gestures (drag and pinch zoom). 回答1: After trying both Rajawali and libGDX I can say Rajawali is a bit easier to implement if the intention is not game development. Here is the link to Rajawali library : GitHub Link Their support is really good and

Understanding the difference between a 2D texture array and a 3D texture?

六眼飞鱼酱① 提交于 2020-12-30 06:15:46
问题 If I understand correctly, if I was to set TEXTURE_MIN_FILTER to NEAREST then there's not much difference between sampler2DArray / TEXTURE_2D_ARRAY and sampler3D / TEXTURE_3D The differences seem to be GenerateMipmap will blend cross layers with 3D textures but not 2D arrays the Z coordinate passed to texture in GLSL is 0 to 1 with 3D textures but an 0 to N (depth) in 2D arrays. If filtering is not NEAREST 3D will blend across layers, 2D array will not. Correct? 回答1: Incorrect. There's one

Understanding the difference between a 2D texture array and a 3D texture?

对着背影说爱祢 提交于 2020-12-30 06:14:32
问题 If I understand correctly, if I was to set TEXTURE_MIN_FILTER to NEAREST then there's not much difference between sampler2DArray / TEXTURE_2D_ARRAY and sampler3D / TEXTURE_3D The differences seem to be GenerateMipmap will blend cross layers with 3D textures but not 2D arrays the Z coordinate passed to texture in GLSL is 0 to 1 with 3D textures but an 0 to N (depth) in 2D arrays. If filtering is not NEAREST 3D will blend across layers, 2D array will not. Correct? 回答1: Incorrect. There's one

Understanding the difference between a 2D texture array and a 3D texture?

假如想象 提交于 2020-12-30 06:12:27
问题 If I understand correctly, if I was to set TEXTURE_MIN_FILTER to NEAREST then there's not much difference between sampler2DArray / TEXTURE_2D_ARRAY and sampler3D / TEXTURE_3D The differences seem to be GenerateMipmap will blend cross layers with 3D textures but not 2D arrays the Z coordinate passed to texture in GLSL is 0 to 1 with 3D textures but an 0 to N (depth) in 2D arrays. If filtering is not NEAREST 3D will blend across layers, 2D array will not. Correct? 回答1: Incorrect. There's one