glsl

glsl pyOpenGL array passing

こ雲淡風輕ζ 提交于 2020-05-15 07:13:11
问题 I'm currently playing around with glsl. For that purpose i need to pass an array from the opengl code to the gsls, which then in return calculates a new color out of the array. But somehow this doesn't work for me. Instead of getting the whole array I'm always stuck with only the first entry. Could you help me by saying what I'm doing wrong? import numpy as np \\... array = np.array([1.2,2.5,3.8,4.3,5.6, #....]) location = glGetUniformLocation(program,"arrayInShader") glUniform1fv(location,1

glsl pyOpenGL array passing

不想你离开。 提交于 2020-05-15 07:12:40
问题 I'm currently playing around with glsl. For that purpose i need to pass an array from the opengl code to the gsls, which then in return calculates a new color out of the array. But somehow this doesn't work for me. Instead of getting the whole array I'm always stuck with only the first entry. Could you help me by saying what I'm doing wrong? import numpy as np \\... array = np.array([1.2,2.5,3.8,4.3,5.6, #....]) location = glGetUniformLocation(program,"arrayInShader") glUniform1fv(location,1

glsl pyOpenGL array passing

China☆狼群 提交于 2020-05-15 07:11:21
问题 I'm currently playing around with glsl. For that purpose i need to pass an array from the opengl code to the gsls, which then in return calculates a new color out of the array. But somehow this doesn't work for me. Instead of getting the whole array I'm always stuck with only the first entry. Could you help me by saying what I'm doing wrong? import numpy as np \\... array = np.array([1.2,2.5,3.8,4.3,5.6, #....]) location = glGetUniformLocation(program,"arrayInShader") glUniform1fv(location,1

Traversal of Bounding Volume Hierachy in Shaders

ぐ巨炮叔叔 提交于 2020-05-13 05:30:05
问题 I am working on a path tracer using vulkan compute shaders. I implemented a tree representing a bounding volume hierachy. The idea of the BVH is to minimize the amount of objects a ray intersection test needs to be performed on. #1 Naive Implementation My first implementation is very fast, it traverses the tree down to a single leaf of the BVH tree. However, the ray might intersect multiple leaves. This code then leads to some triangles not being rendered (although they should). int box_index

How to properly blend colors across two triangles and remove diagonal smear

纵饮孤独 提交于 2020-05-09 06:25:08
问题 I am learning WebGL and I've drawn a full screen quad with colors for each vertex. No lighting or normals or perspective matrix or depth buffer; I'm just drawing a gradient background. This is what I get: It looks good but I cannot help noticing the diagonal smear from the bottom right to the top left. I feel this is an artifact of linear interpolating the far opposite vertices. I'm drawing two triangles: the bottom left, and the top right. I think I would get similar results using OpenGL

What does it mean to normalize a value?

北战南征 提交于 2020-04-29 07:12:11
问题 I'm currently studying lighting in OpenGL, which utilizes a function in GLSL called normalize. According to OpenGL docs, it says that it "calculates the normalized product of two vectors". However, it still doesn't explain what "normalized" mean. I have tried look for what a normalized product is on Google, however I can't seem to find anything about it. Can anyone explain what normalizing means and provide a few example of a normalized value? 回答1: It's a mathematical term and this link

Can OpenGL shader compilers optimize expressions on uniforms?

可紊 提交于 2020-04-18 12:34:37
问题 I've got an OpenGL ES shader with some uniforms in it. I do some math on the uniforms in my fragment shader. Will the shader compiler generally optimize those expressions on the uniforms so they happen once instead of on every pixel? Or should I do the computations outside the shader and pass the results in? Specifically, I've got three uniform coordinates I'm passing into the shader: uniform vec2 u_a; uniform vec2 u_b; uniform vec2 u_c; And then I compute some vectors among those points:

How do I implement two translations and a scale operation in GLSL?

人盡茶涼 提交于 2020-04-17 22:41:06
问题 I am trying to implement the following transformation. My original world-space coordinates are (2D) x=1586266800 and y=11812 I want: the bottom left corner of the OpenGL image to represent coordinates (1586266800, 11800) the top right corner of the OpenGL image to represent coordinates (1586267400, 11900) In order to do that I plan to join three transformation matrices: Translate to the origin of coordinates x=1586266800 and y=11800 Scale to have a width of 600 and a height of 100 Translate

How do I implement two translations and a scale operation in GLSL?

…衆ロ難τιáo~ 提交于 2020-04-17 22:39:30
问题 I am trying to implement the following transformation. My original world-space coordinates are (2D) x=1586266800 and y=11812 I want: the bottom left corner of the OpenGL image to represent coordinates (1586266800, 11800) the top right corner of the OpenGL image to represent coordinates (1586267400, 11900) In order to do that I plan to join three transformation matrices: Translate to the origin of coordinates x=1586266800 and y=11800 Scale to have a width of 600 and a height of 100 Translate

Bind multiple Uniform Buffer Objects

百般思念 提交于 2020-04-16 03:33:09
问题 With WebGL 2 we now can play with Uniform Buffer Objects. They look like a great idea, not having to attach common uniforms to every single program (like projection and view matrices that are common to every object being rendered). I created an helper class which I call every time I want to bind a uniform buffer object. class UniformBuffer { constructor(gl, data, boundLocation = 0) { this.boundLocation = boundLocation; this.data = new Float32Array(data); this.buffer = gl.createBuffer(); gl