glsl

PyOpenGL OpenGL Version on MacOs

假如想象 提交于 2020-07-19 04:41:30
问题 I've been told to switch legacy profile to core profile from other stackoverflow posts but I can't seem to find a way to do that. So I'm positing a more updated error post to help me figure out a way. CODE: import glfw, numpy from OpenGL.GL import * import OpenGL.GL.shaders def main(): if not glfw.init(): return window = glfw.create_window(800,600,"My OpenGL Window", None, None) if not window: glfw.terminate() return glfw.make_context_current(window) triangle = [-0.5, -0.5, 0.0, 0.5, -0.5, 0

OpenGL 4.2 LookAt matrix only works with -z value for eye position

妖精的绣舞 提交于 2020-07-13 15:41:12
问题 I am trying to understand and apply modern OpenGL matrix transformations. I already read a lot of different sources but I am not sure what I am actually doing wrong. The issue I have is also commented in the code: If I set the eye coordinates of the Matrix4.LookAt to a z value that is greater or equal 0 or lower -2 the triangle is not visible anymore. Can someone explain why? As far as I understood the method the triangle should just be visible just from the other side (explicitly disabling

OpenGL 4.2 LookAt matrix only works with -z value for eye position

痞子三分冷 提交于 2020-07-13 15:40:26
问题 I am trying to understand and apply modern OpenGL matrix transformations. I already read a lot of different sources but I am not sure what I am actually doing wrong. The issue I have is also commented in the code: If I set the eye coordinates of the Matrix4.LookAt to a z value that is greater or equal 0 or lower -2 the triangle is not visible anymore. Can someone explain why? As far as I understood the method the triangle should just be visible just from the other side (explicitly disabling

OpenGL directional light shader

北战南征 提交于 2020-07-08 13:33:11
问题 I want to add directional light to my scene using OpenGL and GLSL. The problem is that the theoretically correct way to do so has the wrong results. In the vertex shader I do the following: The direction of the light is given in world-coordinates and transformed using the viewMatrix to camera-coordinates. The normal of the vertex is transformed using the normal-matrix to camera-coordinates. void main () { vary_textureCoord = attribute_textureCoord; vary_normal = mat3(normalMatrix) * attribute

OpenGL directional light shader

坚强是说给别人听的谎言 提交于 2020-07-08 13:32:39
问题 I want to add directional light to my scene using OpenGL and GLSL. The problem is that the theoretically correct way to do so has the wrong results. In the vertex shader I do the following: The direction of the light is given in world-coordinates and transformed using the viewMatrix to camera-coordinates. The normal of the vertex is transformed using the normal-matrix to camera-coordinates. void main () { vary_textureCoord = attribute_textureCoord; vary_normal = mat3(normalMatrix) * attribute

OpenGL directional light shader

ぃ、小莉子 提交于 2020-07-08 13:32:35
问题 I want to add directional light to my scene using OpenGL and GLSL. The problem is that the theoretically correct way to do so has the wrong results. In the vertex shader I do the following: The direction of the light is given in world-coordinates and transformed using the viewMatrix to camera-coordinates. The normal of the vertex is transformed using the normal-matrix to camera-coordinates. void main () { vary_textureCoord = attribute_textureCoord; vary_normal = mat3(normalMatrix) * attribute

In WebGL - when instancing geometry, is it possible to pass per-vertex attribute information for each instance?

醉酒当歌 提交于 2020-07-07 11:32:06
问题 I am trying to recreate through raw WebGL the following three.js example with instanced geometry; though, after testing it looks like I may just have to draw multiple meshes like in the sample but I thought I would ask here first to double check. The question now is essentially - is it possible to pass per-vertex data for each instance of the geometry that gets rendered? Hopefully that makes sense but if it doesn't - The geometry I'm rendering has 4 vertices. For each instance of the geometry

How to use samplerCube as array

亡梦爱人 提交于 2020-06-29 04:45:23
问题 I am using samplerCube for a point light shadow map. For multiple lights, I implemented samplerCube as an array in the following. uniform samplerCube pointShadowMapTexture[MAX_LIGHT]; But somehow I can't index this samplerCube . Shader compiles and there is no problem. This is working for sampler2D arrays. I tried indexing it with [0], [1] .. in the shader but always the same image. I am sending different cube textures for each light but somehow shader doesn't index it or doesn't accept it. I

Why are glsl variables not working as expected?

好久不见. 提交于 2020-06-28 06:07:48
问题 I am working on a 3D renderer which was working as expected but now I am trying to batch every cube into a single draw call (my renderer can only draw cubes right now). Here I have my glsl program that runs for each batch #type vertex #version 330 core layout(location = 0) in vec3 a_Position; layout(location = 1) in vec4 a_Color; layout(location = 2) in vec3 a_TexCoord; layout(location = 3) in int a_TexIndex; uniform mat4 u_ProjectionView; out vec4 v_Color; out vec3 v_TexCoord; out flat int v

Why are glsl variables not working as expected?

纵然是瞬间 提交于 2020-06-28 06:07:05
问题 I am working on a 3D renderer which was working as expected but now I am trying to batch every cube into a single draw call (my renderer can only draw cubes right now). Here I have my glsl program that runs for each batch #type vertex #version 330 core layout(location = 0) in vec3 a_Position; layout(location = 1) in vec4 a_Color; layout(location = 2) in vec3 a_TexCoord; layout(location = 3) in int a_TexIndex; uniform mat4 u_ProjectionView; out vec4 v_Color; out vec3 v_TexCoord; out flat int v