Hot answers tagged

6

So my understanding of VBO they're essentially Buffer objects (bunch of bytes to be sent to the GPU) with the difference that VBO are specifically dedicated to Vertex Data. Is this correct? A "VBO" is not really a thing, and I really wish tutorials would stop pretending that they are. You are correct in that there exist buffer objects. These are ...


4

The standard solution is to reduce the amount of per-vertex data by only specifying the 4 indices that have the highest weights (and rescaling the weights to add up to 1.0). That way, you can pass 4 weights as a vec4 and 4 indices as a uvec4. Also, you should pass the weights as normalized shorts (or bytes if you can accept the quality loss) and indices as ...


4

In general, you should not see significant performance differences running identical compute shaders via one API vs. another; in the end they’re running the same instructions on the same hardware. It’s possible for vendor-provided toolkits like CUDA or MetalPerformanceShaders to have more efficient implementations of a given algorithm on that vendor’s ...


4

Games, Triple A games in particular, tend to push graphics cards to their limits, computation capabilities, bandwidth, and drivers all get stressed heavily. This tends to cause even the smallest bug, or inefficiency in the driver to become a glaring problem resulting in "glitches", slow frame rates, game crashes and rendering quality issues. These &...


4

I think you misunderstood the use of glBlitFrameBuffer. When using this to blit Color Buffers, according to the docs, One thing to keep in mind is this: when using GL_COLOR_BUFFER_BIT​, the only colors read will come from the read color buffer in the read FBO, specified by glReadBuffer. The colors written will only go to the draw color buffers in the write ...


4

I assume you're talking about triangles with two vertices equal, and a third vertex at a different point. They don't appear in filled polygon mode because such triangles have zero area and don't cover any pixel centers. It's not that there's a special rule "degenerate triangles are dropped", it's that they naturally don't generate any fragments ...


3

The GS is responsible for assigning a particular primitive to a particular layer. The GS is also responsible for writing values for gl_ClipDistance for a particular primitive. So the GS is perfectly capable of doing both of those things: assigning a primitive to a layer and doing the clip-plane computations for that layer. And if you need to "deactivate&...


3

GLSL has no mechanism to change the "size" of shared memory. Indeed, GLSL is structurally incapable of such a thing. You can't get a pointer to shared memory. Indeed, "shared memory" doesn't really exist in GLSL; there are only shared variables. And variables have a compile-time fixed size. So GLSL wouldn't even have a good way of ...


3

Does Vulkan have the equivalent of the OpenGL separable shader objects, or are there any plans for it? They seem just so much more flexible. It would be "so much more flexible". But Vulkan is a low-level rendering API. It's job is to give you access to the hardware as close to the metal as possible; user-convenience isn't even in the top-5 goals ...


3

On current GPU architectures, at the machine level, compilation of a shader program can depend on which other pipeline stages are active, what the inputs/outputs to those shaders are, as well as what the inputs and outputs of the overall pipeline are (vertex inputs and fragment outputs, for example). There's a lot of complicated architectural reasons why ...


3

A problem I see in your code is that you take the sizeof() an unsized array, which yields the size of the pointer to that array and not the size of array itself. void CglSolidModel::loadModels(glm::vec3 vertices[], unsigned int indices[]) { { ... glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); ... } Here is a small ...


3

If you're interested in vertex normals specifically, there's an easy answer even for non-planar polygons that avoids the question of defining what the exact surface is: for each vertex, calculate the normal of the plane formed by the two edges entering and leaving that vertex. More formally, given vertices $\mathbf{v}_1, \mathbf{v}_2, \ldots \mathbf{v}_n$ ...


3

A simple spherical light volume can be computed as a post processing effect by drawing a cube with the face winding direction reversed (left hand winding vs right hand winding). This displays the interior of the cube. This gives a nice "halo" effect to lights. Compute the intersection of a ray with a sphere that is fitted to the cube inside the ...


2

I copied my answer for the same OP at https://github.com/godotengine/godot/issues/19473. But this question differs slightly to the original issue report. In case you want to manually add support for VERTEX_ID, these are the changes I had to make in 3.2.3-stable for spatial shaders. I wanted to use the vertex ID for creating procedural animations. In drivers/...


2

Kinda late on reply, but I'm still gonna post it here for future searches. Since all (or many, I'm not sure) macs use Intel GPUs you can use Intel Analyzers. It isn't much, but still got frame capture, texture browser etc. and helps debug many errors.


2

I am suprised that it was only mentioned in comments but yes you can use variable length arrays through SSBO. Here is the excerpt from wiki: On the host side: int data[SOME_SIZE]; ... GLuint ssbo; glGenBuffers(1, &ssbo); glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo); glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(data), data​, GLenum usage); //sizeof(data) ...


2

You could add the variable as code when you upload the shader code. char header[64]; sprintf (header, "const int size = %u;\n", pointLights.size()); Then add the header (assuming your code is in char code[]): GLchar *source[2] = {(GLchar *)header, (GLchar *)code}; glShaderSource(shader, 2, (const GLchar **)source, NULL); .. That way you can ...


2

After trying everything possible I found my mistake: The shaders are fine, the only thing which is wrong is the frameBufferObject binding. To be honest, the texture to FBO binding. the only thing I replaced is this: glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, m_cubeMapTexture, 0); glFramebufferTexture2D(...


2

If you could use imageLoad/Store to do atomic operations, there would be no need for atomic operations as a distinct class of operations. So no, you can't. There is no correct set of barriers or other properties that will allow this to work generally the way atomic operations do.


2

How are you randomizing the samples you take? It looks to me like maybe the random values are the same across all pixels in the image, which would explain why you see 10 coherent bright spots when you have 10 samples. The samples should be re-randomized for each pixel. This should produce a noisy result, with a single blurred-out bright spot instead of 10 (...


2

Most 3D models are not just collections of points; they’re also the information about how those points are connected. Those are polygon meshes. What you’re describing sounds like a point cloud, which is what processes like 3D scanning often produce. That article has a “conversion to 3D surfaces” section; if you search for “point cloud meshing” elsewhere you ...


2

I think you may be focusing on the wrong thing here. Moving the data from an SSBO to a uniform buffer might give some speedup, sure, but that is a micro-optimization. I would search for algorithmic optimizations first. As noted in the comments, processing all 200 records for every vertex is both a lot of data to read, and a lot of computation to do if there'...


2

A VBO is a buffer of memory which the gpu can access. That's all it is. A VAO is an object that stores vertex bindings. This means that when you call glVertexAttribPointer and friends to describe your vertex format that format information gets stored into the currently bound VAO. And when you draw it will use the vertex bindings in the currently bound VAO. ...


2

Everything in this code functions as intended, until I try to translate the entire grid (grid lines) to the center of the screen by adding v_Resolution.x / 2 to uv.x. Not sure what your intention is here since the Shadertoy example you referenced generates an infinite grid. So maybe you can clarify that. However, I think I can help you with this problem: .....


2

Vulkan uses vertex attributes. Here is an example: const VkVertexInputAttributeDescription vertexAttributes[] = { // location, binding, format, offset { 0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0 }, // inPosition { 1, 0, VK_FORMAT_R32G32B32_SFLOAT, 12 }, // inNormal { 2, 0, VK_FORMAT_R32G32B32A32_SFLOAT, ...


2

You are setting g_color after the vertex have been emitted so it will have no effect. EmitVertex() will emit the poition and whatever values are current in the out attributes. Set the attribute before emitting the vertex. The gemometry shader can create geometry by emitting multiple vertices or destroy geometry by not emitting something. This is why the ...


2

GLSL allows a location to be assigned to each in/out variables then the names can be anything you want. Here is an example: Vertex shader: layout(location=0) out vec3 test; Geometery shader: // as long as the location numbers match, the names don't matter layout(location=0) in vec3 testIn; layout(location=0) out vec3 testOut; Fragment shader: // location ...


1

The volume inside of the frustum is defined by a set of inequalities, and since we are trying to find the boundaries of the frustum, we set the inequalities to equalities. That's really all it is. To take a 1D example, if we have a "frustum" defined by 0 < x < 5, then of course the bounding points of it are defined by x = 0 and x = 5. ...


1

Yes, With a certain OpenGL extension, that is possible (thanks to NicolBolas for pointing that out). It is pretty much the same as in C++. Let's assume you have a file util.glsl, vertex.glsl and fragment.glsl, all in the same folder. $^1$ //in util.glsl float add(float a, float b) { return a + b; } Then you can call that function, as if it were in your ...


1

No. When you use image load/store, you don't get to play "texture" games like playing with the border color, doing filtering on values, etc. You are fetching a texel from a particular location. If you want this, you will have to detect the out-of-bounds access and choose to substitute an alternate value. You can query the image's size, so it should ...


Only top voted, non community-wiki answers of a minimum length are eligible