vertex-attributes

Why does OpenGL drawing fail when vertex attrib array zero is disabled?

痞子三分冷 提交于 2020-01-22 17:48:12
问题 I was having extreme trouble getting a vertex shader of mine to run under OpenGL 3.3 core on an ATI driver: #version 150 uniform mat4 graph_matrix, view_matrix, proj_matrix; uniform bool align_origin; attribute vec2 graph_position; attribute vec2 screen_position; attribute vec2 texcoord0; attribute vec4 color; varying vec2 texcoord0_px; varying vec4 color_px; void main() { // Pick the position or the annotation position vec2 pos = graph_position; // Transform the coordinates pos = vec2(graph

Why does OpenGL drawing fail when vertex attrib array zero is disabled?

给你一囗甜甜゛ 提交于 2020-01-22 17:48:08
问题 I was having extreme trouble getting a vertex shader of mine to run under OpenGL 3.3 core on an ATI driver: #version 150 uniform mat4 graph_matrix, view_matrix, proj_matrix; uniform bool align_origin; attribute vec2 graph_position; attribute vec2 screen_position; attribute vec2 texcoord0; attribute vec4 color; varying vec2 texcoord0_px; varying vec4 color_px; void main() { // Pick the position or the annotation position vec2 pos = graph_position; // Transform the coordinates pos = vec2(graph

Is this diagram for OpenGL data types correct?

柔情痞子 提交于 2020-01-11 06:45:07
问题 I'm trying to understand glVertexAttribPointer , and I noticed that it accepts many more types than those that have an equivalent in GLSL. So to write down everything I know so far, I made this diagram matching all the types (except for the packed ones, which don't matter, and GL_FIXED , which I don't understand. Blue nodes represent the type in GLSL, while yellow nodes represent the symbolic constants passed to glVertexAttribPointer . Red nodes represent some kind of conversion between types

GLSL: Data Distortion

雨燕双飞 提交于 2020-01-06 12:51:42
问题 I'm using OpenGL 3.3 GLSL 1.5 compatibility. I'm getting a strange problem with my vertex data. I'm trying to pass an index value to the fragment shader, but the value seems to change based on my camera position. This should be simple : I pass a GLfloat through the vertex shader to the fragment shader. I then convert this value to an unsigned integer. The value is correct the majority of the time, except for the edges of the fragment. No matter what I do the same distortion appears. Why is

What is the difference between glVertexAttribDivisor and glVertexBindingDivisor?

懵懂的女人 提交于 2019-12-23 10:58:09
问题 I was looking for ways to associate attributes with arbitrary groupings of verticies, at first instancing appeared to be the only way for me to accomplish this, but then I stumbled up this question and this answer states : However what is possible with newer versions of OpenGL is setting the rate at which a certain vertex attribute's buffer offset advances. Effectively this means that the data for a given vertex array gets duplicated to n vertices before the buffer offset for a attribute

WebGL - which API to use?

谁说胖子不能爱 提交于 2019-12-23 05:50:49
问题 I want to draw multiple polygon shapes (where each shape has it's own set of vertices). I want to be able to position these shapes independently of each other. Which API can i use to set the a_Position for the vertex shader? A) gl.vertexAttrib3f B) gl.vertexAttribPointer + gl.enableVertexAttribArray thanks. 回答1: Your question makes it sound like you're really new to WebGL? Maybe you should read some tutorials? But in answer to your question: gl.vertexAttrib3f only lets you supply a single

Using GL_INT_2_10_10_10_REV in glVertexAttribPointer()

妖精的绣舞 提交于 2019-12-21 23:21:10
问题 Can anybody tell me how exactly do we use GL_INT_2_10_10_10_REV as type parameter in glVertexAttribPointer() ? I am trying to pass color values using this type. Also what is the significance of "REV" suffix in this type ? Does it require any special treatment in the shaders ? My code is as follows : GLuint red=1023,green=1023,blue=1023,alpha=3; GLuint val = 0; val = val | (alpha << 30); val = val | (blue << 20); val = val | (green << 10); val = val | (red << 0); GLuint test_data[]={val,val

How does Blender calculate vertex normals?

我与影子孤独终老i 提交于 2019-12-12 19:58:09
问题 I'm attempting to calculate vertex normals for various game assets. The normals I calculate are used for "inflating" the model (to draw behind the real model producing a thick outline). I currently compute the normal for each face and average all of them (several other questions on Stack Overflow suggest this approach). However, this doesn't work for sharp corners like this one (adjacent faces' normals marked in orange, the normal I'm trying to calculate is outlined in green). The object

Are MTLVertexAttributeDescriptors necessary? Why are they needed?

岁酱吖の 提交于 2019-12-09 14:56:09
问题 I've been learning Metal for iOS / OSX, and I began by following a Ray Wenderlich tutorial. This tutorial works fine but it makes no mention of MTLVertexAttributeDescriptors . Now that I'm developing my own app, I'm getting weird glitches and I'm wondering if the fact that I don't use MTLVertexAttributeDescriptors may be related to the problem. What difference do they make? I've been able to make a variety of shaders with varying vertex structures and I never even knew about these things. I

Passing attributes to OpenGL vertex shader acts strangely

℡╲_俬逩灬. 提交于 2019-12-07 15:53:55
问题 The problem: Outcome 1: I pass a vertex attribute to the shader, the program runs for 5 seconds, then the graphics driver stops responding and recovers but the program doesn't. Outcome 2: I cap the framerate at 60 then do the same thing. The program runs fine, but when I try to pass different values for the vertex attribute in the same runtime it does not update the geometry (only the first vertex attribute passed works). I'm using OpenGL version 3.1 with GLSL 140. (The highest my graphics