Questions tagged [vertex-attributes]
62 questions
18
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…
![](../../users/profiles/605710.webp)
bsabiston
- 647
- 4
- 20
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…
![](../../users/profiles/1818856.webp)
fluggo
- 1,478
- 2
- 13
- 21
7
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 ==…
![](../../users/profiles/407757.webp)
James Bedford
- 27,356
- 8
- 51
- 62
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…
![](../../users/profiles/1258491.webp)
metaleap
- 2,054
- 2
- 17
- 37
5
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…
![](../../users/profiles/2036035.webp)
Krupip
- 3,570
- 1
- 27
- 40
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
{
…
![](../../users/profiles/4905333.webp)
bobby
- 115
- 6
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…
![](../../users/profiles/3902980.webp)
dabigjhall
- 53
- 1
- 3
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…
![](../../users/profiles/1691407.webp)
bofjas
- 1,146
- 7
- 19
3
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…
![](../../users/profiles/3494792.webp)
chainerlt
- 167
- 1
- 8
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…
![](../../users/profiles/605710.webp)
bsabiston
- 647
- 4
- 20
3
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…
![](../../users/profiles/4484072.webp)
Ashwin Gupta
- 2,100
- 7
- 23
- 54
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…
![](../../users/profiles/2940623.webp)
user2940623
- 339
- 1
- 13
2
votes
1 answer
Clarification on glVertexAttribPointer index paramter
I have a very simple program to display a 3D triangle in OpenGL. hat value I put in, it does not display correctly. I put in the following array into the vertex buffer
float triangle[] = {
// x y z r g b a
0.2f,…
![](../../users/profiles/10534921.webp)
LardPies
- 83
- 5
2
votes
1 answer
OpenGL vertex shader is fast on Linux, but extremely slow on Windows
To draw power spectral density of a signal (which is very similar to heatmap), I use this vertex shader program. It receives value of power at each vertex, takes logarithm to show result in dB, normalizes within the range of colormap array, and…
![](../../users/profiles/1994239.webp)
Ali Tavakol
- 417
- 3
- 11
2
votes
2 answers
InputLayout which binds vertex attributes to a constant value?
I'm trying to port some code from OpenGL to DirectX - in OpenGL it is possible to disable a certain vertex attribute and set it to a constant value.
const GLfloat data[] = { 1.0f, 0.0f, 0.0f, 1.0f };
GLuint location = glGetAttribLocation(program,…
![](../../users/profiles/531840.webp)
Constantin
- 7,926
- 12
- 71
- 112