Questions tagged [vertex-attributes]

73 questions
19
votes
1 answer

Are MTLVertexAttributeDescriptors necessary? Why are they needed?

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…
bsabiston
  • 721
  • 6
  • 22
11
votes
1 answer

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

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…
mrdecemberist
  • 2,631
  • 2
  • 20
  • 23
8
votes
2 answers

Can you tell if a vertex attribute is enabled from within a vertex shader?

I was wondering if there was a way to tell if a vertex attribute is enabled from within a vertex shader? I know that if the vertex attribute is disabled all the values will be treated as 0.0, so I could do a test like the following: if (attribute ==…
James Bedford
  • 28,702
  • 8
  • 57
  • 64
8
votes
2 answers

What is the difference between glVertexAttribDivisor and glVertexBindingDivisor?

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…
Krupip
  • 4,404
  • 2
  • 32
  • 54
7
votes
1 answer

How do I make this simple OpenGL code (works in a "lenient" 3.3 and 4.2 profile) work in a strict 3.2 and 4.2 core profile?

I had some 3D code that I noticed wouldn't render in a strict core profile but fine in a "normal" (not explicitly requested-as-core-only) profile context. To isolate the issue, I have written the smallest simplest possible OpenGL program drawing…
metaleap
  • 2,132
  • 2
  • 22
  • 40
6
votes
0 answers

Interleaved vs non-interleaved vertex buffers

This seems like a question which has been answered throughout time for one IHV or another but recently I have have been trying to come to a consensus about vertex layouts and the best practices for a modern renderer across all IHVs and…
6
votes
2 answers

OpenGL GLSL Send color as integer to shader to be decomposed as vec4 RGBA

I can send color to shader as 4 floats - no problem. However I want to send it as integer (or unsigned integer, doesn't really matter, what matters is 32 bits) and be decomposed in vec4 on shader. I'm using OpenTK as C# wrapper for OpenGL (although…
chainerlt
  • 215
  • 3
  • 8
5
votes
1 answer

Opengl - rendering different vertex formats

I am looking for a nice way to render mesh objects with different vertex layouts wihtout large effort (e.g. defining a renderer class for each vertex layout). You can see some examples of different vertex formats below. enum EVertexFormat { …
bobby
  • 115
  • 8
5
votes
1 answer

How does Blender calculate vertex normals?

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…
dabigjhall
  • 53
  • 1
  • 3
4
votes
1 answer

Can I have multiple GL_ARRAY_BUFFER buffers?

So I was looking at another SO question regarding the command glVertexAttribPointer and I ran into a slight confusion. The accepted answer to this question explains, But there's an additional implied piece of state that is also stored away for…
4
votes
1 answer

OpenGL buffers - Stride vs Tightly packed

What are the pros and cons for using strided vertex buffers vs tighly packed buffers for each attribute? What I mean is for instance: Stride: xyzrgb xyzrgb xyzrgb Tight: xyzxyzxyz rgbrgbrgb At first glance it might look like you easily can change…
bofjas
  • 1,186
  • 7
  • 19
3
votes
1 answer

how to describe packed_float3 in Metal vertex shader MTLVertexAttributeDescriptor?

I am passing an array of structs to my Metal shader vertex function. The struct looks like this: struct Vertex { var x,y,z: Float // position data var r,g,b,a: Float // color data var s,t: Float // texture coordinates var…
bsabiston
  • 721
  • 6
  • 22
3
votes
1 answer

Passing attributes to OpenGL vertex shader acts strangely

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…
user2940623
  • 369
  • 3
  • 14
2
votes
1 answer

how to split values from coordinates in OpenGL vertex buffer objects

For drawing a heatmap in OpenGL we want to give each point x,y, and value. We could just store a vbo with these values and split it into two vertexattrib pointers: glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 3*sizeof(float),…
Dov
  • 8,000
  • 8
  • 46
  • 75
2
votes
1 answer

OpenGL - Can I draw non-indexed when index-buffer is set for VAO?

I set up a VAO, binding vertex-buffers to it for vertex attributes, but also set index-buffer (With glVertexArrayElementBuffer). Does that restrict it so it only works with glDrawElements type of commands, or will it work with glDrawArrays…
Newline
  • 769
  • 3
  • 12
1
2 3 4 5