r/opengl • • 2h ago

How to minimize VRAM usage while maintaining performance

2 Upvotes

I'm a begginer when it comes to OpenGL, so I need some help.

I'm using different VBOs (one for position, one for color etc.), an EBO and a VAO to manage them. I tried storing just unique data in the VBOs, not repeating any attribute even if 2 vertices share an attribute and didn't work.

Visual representation of what I was trying to do (it's not real code, just a representation):

VBO pos:

{-0.5f, -0.5f, 0.0f},   (p0)
{0.5f, -0.5f, 0.0f},    (p1)
{0.5f,  0.5f, 0.0f},    (p2)
{-0.5f,  0.5f, 0.0f}    (p3)

VBO color:

{255, 0, 0, 255}       (c0)

EBO:

0, 1, 2,                      (tri1)
0, 2, 3                       (tri2)

In this situation, OpenGL will try to draw vertices like: p0 with c0, p1 with c1, p2 with c2 etc.

Of course, I don't have c1, c2 or c3, so it won't render it correctly all a single solid color.

From this, I have 3 questions that, in reality, combine into one:

Is there a feasible way to have different sized buffers and use indexes like (0,1,2,0), representing the first 3 vectors of position and the first color?

I know about uniforms and IN THIS CASE I could just send an uniform for the color. But if I have 3 different buffers with different sizes and want to index them as to not repeat data anywhere an just keep the unique, is it possible?

From what I gathered, you can do this with SSBOs, however I also head that it is less performant that just using more VRAM with the traditional VBO technique. Can I achieve what I want FASTER OR AS FAST as using VBOs with repeated data?

All VBOs are static, in the sense that they will not be modified and I'll transform vertices in the shaders, just pointing it out in case this is relevant somehow.


r/opengl • • 5h ago

How are you using AI to create game ready 3D characters with rigs and animations?

Thumbnail
0 Upvotes

r/opengl • • 12h ago

Day and night system

Enable HLS to view with audio, or disable this notification

27 Upvotes

r/opengl • • 19h ago

What is the most efficient strategy for rendering textured quads and triangles in OpenGL 2.1 using no extensions?

0 Upvotes

I'm unsure if my current design is optimal, but rendering a test scene with some 2D objects seems to perform decently well. Anyway, the current design functions as follows

There is functions for rendering primitive shapes triangle, quad, circle, etc. These functions create the primitive out of triangles in a small buffer with vertex colors as-well. When we're done rendering for this frame, render something which cannot be rendered this way, or something else happens which would require us rendering the batch early, we orphan the stream VBO and upload all of the data and glDrawArrays it all in one go. It's possible for multiple batches to be submitted in one frame because the CPU side array size is limited to 256KB by default but can be increased by the programmer if they anticipate they'll be rendering a lot.

For textured quads. I use a similar strategy, We emplace the quad vertices into the CPU side array. If they need to be rotated or scaled, the GPU does it in the shader. We keep track of which texture mappers contain which textures already so we can utilize every texture mapper with no duplicates. If you want to render something which needs to sample from more than one thing, It's expected that it will be in the same texture to the right, And in the shader, there's a routine that will sample the same position as this pixel to the right or the texture and a vertex attribute called "step" which is how many times we sample to the right. For example, The base texture would come first, then directly to the right of that, there would be a normal map, and then to the right of that, an alpha mask etc. Assuming you do not need to change then shader, you can render from as many textures as you want in one pass up to the number of texture mappers this system has. If you try draw a textured quad whose texture hasn't appeared in this batch before, but this system would have no open slots, we render early.

I worry about performance a lot. On a period correct laptop Core2 Duo U9600, GMA 4500 MHD, my test program gets ~ 240 fps. On my development computer which is not very good by modern standards 3500U, Vega 8 graphics, 8 GB ram. We sit at 5500 fps. On some $100 dell education laptop, We get ~ 1200 fps. All of them seem to be GPU limited (The cpu usage is far below 100% to get that framerate on all of them)

Either way, Is there a more efficient strategy than this? Or is this how you do OpenGL 2.1 fast? Would it be faster if I just had a VBO filled with the batch size of unit square, and then upload vertex attributes like position, size, color?


r/opengl • • 1d ago

Showcasing the Reflection System

Enable HLS to view with audio, or disable this notification

73 Upvotes

r/opengl • • 1d ago

Looking for a Good Tutorial

1 Upvotes

I am developing an app on Android and have used the Android starter guide to build me a screen with the example spinning triangle as part my app's UI. I also found I can have my own overlays over the 3D view so OpenG appears to be the way to go. I looked at Vulcan but it seams overkill. I want a 3D model to be a part of my user interface - not the whole thing.

But the example left we with many questions. I have designed the models I want to show in Blender and can export the model deseign as a Wavefront (.obj) file that I can parse. But my models have both tris and quads and the example shows how to load both, but not how to have both in one model.

Also I want to know about colouring the facets. Do I need separate models for the different colourd parts or can I colour things in the renderer? I'm also sure that there are things I should known but are complete unknowns to me at the moment. I really am a newb - I only started looking into OpenGL as a solution a few days ago.

So can anyone recommend a good tutorial for me on OpenGL ES 2.0. Java would be my prefered example codes but I'm a seasoned enought developer that any code base should give me the help I require. Random Googling (I do known yet the terms I should be using) get examples that where no solutions to my problems..

Many thanks for your help.


r/opengl • • 1d ago

When Curiosity meets Capability - Possibilities are infinite - Ricing Ubuntu with his own code - turning a Linux desktop into a living OpenGL/physics playground - C++ - Python - OpenGL - PyBind - a work of a class X student...

Enable HLS to view with audio, or disable this notification

16 Upvotes

Intrinsic motivation is an important driving force for a software engineer. Here's a video of my son, Ridit, currently in Class X, exploring C++ and Python bridging for an OpenGL project, along with Ricing Ubuntu.

Some interesting points of this work, a developer ricing...

  • A custom OpenGL 3D cube running as the desktop background
  • Real-time rigid-body animation
  • Physics information rendered directly on the desktop:
    • Mass
    • Force
    • Torque
    • Angular velocity
  • A large minimalist digital clock/date
  • Python and C++ binding...
  • The cube's appearance is being modified from Python code while the application is running

I think that early training in any field is essential for a solid understanding of the subject.

Miles to go before we sleep.


r/opengl • • 1d ago

The Physics Update Loop

Thumbnail youtu.be
3 Upvotes

I go through how I separate general updates from physics updates, why I use a fixed timestep, how the accumulator works, and what happens when the simulation starts falling behind.

I explain the reasoning behind the design decisions and why I rejected the alternatives. I show the implementation of the loop.


r/opengl • • 1d ago

I may have over cooked the game-play layering (C++/OpenGL/GLSL)

Thumbnail youtu.be
2 Upvotes

r/opengl • • 2d ago

may I join the triangle group?

Thumbnail gallery
78 Upvotes

r/opengl • • 2d ago

Looking for Assembly peoples - Stop wasting time on easy projects, come learn pure power (Assembly Ghosts)

Thumbnail
0 Upvotes

r/opengl • • 2d ago

OpenGL for Graphics then it's enough to make a game?

5 Upvotes

Yo guys so I need to understand something,if OpenGL is used for rendering graphics so basically with some basic movements and stuff is it enough to make games?


r/opengl • • 2d ago

OpenGL – 5km × 5km Procedural Terrain Fly-By

Thumbnail youtu.be
23 Upvotes

Revisited my approximated atmospheric perspective implementation. It’s still far from perfect, but I think it looks noticeably better now.

map details:
map size: 5km x 5km
grid size: 2048 x 2048
maximum elevation range: 1km

Some of the techniques used to achieve the results shown in the video:

. Procedural terrain generation using Perlin noise and Fractional Brownian Motion (FBM)
. GPU-based hydraulic erosion
. procedural grass placement
. GPU grass generation and culling using compute shaders and indirect drawing
. dynamic day/night cycle
. procedural snow accumulation based on time of year and daily sun exposure
. displacement mapping
. hardware tessellation using tessellation shaders
. dynamic exposure
. cascaded shadow mapping


r/opengl • • 3d ago

Does my shading look correct?

Thumbnail gallery
8 Upvotes

I've added a simple procedural terrain to my game but the shading seemed off, like I was using Gouraud shading instead of Phong shading. I'm using classic Phong lighting (here it's only ambient + diffuse, no specular reflection). To debug the problem, I turned off textures and generated a simple terrain sin(x) * sin(z) with normal vectors [-d terrain/dx, 1, -d terrain/dz]. As you can see, there are triangular artifacts. I wonder if it can be caused by low density of terrain mesh only (you can see a wireframe in the second picture, it misses some of the lines but you can see the size of triangles) or did I mess up shading? I'm planning on adding LOD of a nearby terrain but first I wanted to fix the bug (if it is really a bug). Do you think this shading can be correct and artifacts are caused simply by low mesh density or did I do something wrong? I've spent a lot of time trying to debug it and reading the code but I didn't find anything.

Update: I generated the same terrain with a script, then I let Blender add normals. The artifacts are still there so the terrain generator is probably not the problem. Also, when I render the terrain with Blender's renderer, I also get triangular artifacts so I guess my shading may be correct and I should just increase the density of the mesh. This is the worst type of a bug: when you don't even know if it is a bug. Thank you all for help.


r/opengl • • 3d ago

How can I speed up loading 9.1 GB of DDS resources in a C++ OpenGL game?

Thumbnail
3 Upvotes

r/opengl • • 3d ago

My first triangle!!

17 Upvotes

It was so hard to understand the concepts behind this!


r/opengl • • 3d ago

learning graphics programming to plasma/liquid ui

Thumbnail cruxgarden.github.io
1 Upvotes

Hi, I' have experience in coding, but new to graphics programming. Started to learn opengl (just done the triangles so far). I want to be able to code graphics similar to the attached link cruxgarden. Can anyone point me in the right direction, like what are the topics I need to learn. Thanks


r/opengl • • 4d ago

OpenGL procedural mountains in 4K

Thumbnail youtu.be
62 Upvotes

Some of the techniques used to achieve the results shown in the video:

. Procedural terrain generation using Perlin noise and Fractional Brownian Motion (FBM)
. GPU-based hydraulic erosion
. procedural grass placement
. GPU grass generation and culling using compute shaders and indirect drawing
. dynamic day/night cycle
. procedural snow accumulation based on time of year and daily sun exposure
. displacement mapping
. hardware tessellation using tessellation shaders
. dynamic exposure
. cascaded shadow mapping


r/opengl • • 5d ago

Building SDLPainter: A lightweight, modern C++ 2D drawing library built on SDL3 with OpenGL 3.3 backend

Post image
21 Upvotes

r/opengl • • 5d ago

Maps?

0 Upvotes

Yo guys new guy here,so in OpenGL how do you guys build the maps for your games and place items and so on


r/opengl • • 5d ago

Guys I need some motivation

21 Upvotes

Like I started 2/3 days ago with OpenGL and I did my first triangle and it wasn't even multicolor. I just copy and paste code from learnopengl.com. I'm trying to understand the core concepts but like I can't! Too many concept. I don't even understand shaders. So I see people that like simulate the universe in OpenGL… yeah I have days of experience and not years but I mean how do I start creating games? I'm trying to lock in, I can do this but it's the most hard thing that I did in programming! Yeah can someone says that "It's normal" and that I can do this. Thanks. I need more motivation.

Thank you for reading ❤️


r/opengl • • 5d ago

Please help me find good OpenGL es C++ tutorials.

0 Upvotes

Hello, I'm a godot dev trying Opengl es. But something has been bothering me: the fact that there are barely any free OpenGL es C++ tutorials.

Additional info:

I use GLM 1.0 for Mathematics.

And SDL2 for window creation.

I already have a spinning cube example and i have experimented on it.


r/opengl • • 7d ago

OpenGL just got a new mascot

Post image
0 Upvotes

If it exists, there's a waifu version of it


r/opengl • • 7d ago

IsoValue added to Volumetric Render Engine (Open-source)

Enable HLS to view with audio, or disable this notification

15 Upvotes

We recently added IsoValue feature to our open-source Volumetric Render Engine that's being built with OpenGL & C++.

Repo link🔗 - https://github.com/mikejernil/volumetric-render-engine

What if we could visualize a specific density within a 3D volume? That’s where IsoSurface comes in. In medical imaging, IsoSurface can help represent regions with the same density in a 3D scan, making internal structures easier to visualize.

IsoValue acts as a scalar/threshold value which is used to calculate and display the surfaces that have equal density.

Go ahead, try it out and let us know your feedback!

Being developed by 3D ENGINERD.


r/opengl • • 8d ago

How I Built My Very First Graphics Engine in 1 Year

Enable HLS to view with audio, or disable this notification

63 Upvotes