Real-Time Dual-GLB Combat Effects with CUDA and OpenGL on Jetson Orin Nano

Hello NVIDIA Developer Community,

I would like to share a real-time dual-GLB combat rendering experiment that I developed for the NVIDIA Jetson Orin Nano Super.

The project renders an animated character model and a separate magic-sword model while generating attack geometry, energy trails, hit reactions and state transitions in real time.

The main objective is to explore a CUDA–OpenGL architecture for interactive 3D effects while keeping most dynamic geometry generation on the GPU.

Video Demonstration

The following video shows the current implementation running with two GLB assets.

The demonstration includes:

  • A separate GLB character and magic-sword model
  • Repeated sword attack sequences
  • GPU-generated blue and purple energy effects
  • Dynamic sword movement and attack trajectories
  • Character hit highlighting
  • Knockback and displacement reactions
  • Return-to-idle transitions
  • Runtime status information
  • Repeated attack-state cycles

The video is intended as a rendering and architecture demonstration rather than a formal performance benchmark.

Rendering Pipeline

The current rendering pipeline is organized approximately as follows:

GLB Asset Loading
→ Character and Sword Transform Updates
→ CUDA Attack-Geometry Generation
→ OpenGL Buffer Update
→ Character and Weapon Rendering
→ Transparent Energy-Effect Rendering
→ Hit-Reaction and State Processing

The character and sword are treated as separate scene objects with independent transforms and effect states.

OpenGL performs the final model and effect rendering, while CUDA is used to calculate or update dynamic attack data.

Dual-GLB Scene Structure

The project loads two independent GLB assets:

  1. An animated humanoid character
  2. A magic-sword or weapon model

Each object has its own:

  • Model transformation
  • Position and orientation
  • Animation or idle state
  • Material configuration
  • Effect attachment points
  • Combat-state information

Keeping the weapon separate from the character makes it possible to move, rotate and animate the sword independently during attack sequences.

It also allows the same attack system to be reused with different weapon and character assets.

CUDA-Generated Attack Effects

CUDA is used to update dynamic effect information such as:

  • Attack-path positions
  • Sword-trail vertices
  • Energy-blade geometry
  • Particle positions
  • Fragment directions
  • Effect opacity
  • Emissive intensity
  • Impact orientation
  • Effect lifetime

The resulting data is consumed by OpenGL for final rasterization.

The CPU mainly controls the current attack state and timing. It does not need to calculate every trail vertex or effect particle individually.

Attack and Reaction State Machine

The combat sequence is controlled by a state-based system.

A simplified sequence is:

Idle
→ Attack Preparation
→ Sword Movement
→ Contact or Impact
→ Character Hit Reaction
→ Knockback
→ Recovery
→ Return to Idle

Each state controls different parameters, including:

  • Sword position
  • Sword rotation
  • Attack speed
  • Character displacement
  • Emissive intensity
  • Trail length
  • Effect visibility
  • Reaction duration

This makes it possible to create repeatable attack sequences while keeping the rendering system separate from the gameplay-state logic.

Hit-Reaction Rendering

When an attack reaches the target, several effects can be activated together:

  • Character emissive highlighting
  • Screen-facing impact geometry
  • Short-duration energy trails
  • Character displacement
  • Knockback direction
  • Temporary material-intensity changes

The reaction effects are synchronized with the attack timeline rather than being rendered continuously.

One area I am currently improving is the transition between the normal character material and the high-intensity hit effect, so that the model remains visible without becoming completely white.

CUDA–OpenGL Interoperability

Dynamic attack geometry is updated frequently, so CUDA–OpenGL synchronization is an important part of this project.

The current workflow conceptually includes:

  1. Registering an OpenGL buffer for CUDA access
  2. Mapping the resource
  3. Updating attack or effect geometry with CUDA
  4. Unmapping the resource
  5. Rendering the updated data with OpenGL

I am currently evaluating the overhead of mapping and unmapping resources during every effect frame.

Possible alternatives include:

  • Double-buffered effect VBOs
  • Persistent OpenGL buffer storage
  • Longer-lived mapped resources
  • Multiple CUDA streams
  • Explicit CUDA and OpenGL synchronization
  • Preallocated effect-memory pools

GLB Materials and Lighting

The video currently uses a high-contrast black background so that the energy effects remain clearly visible.

The character, sword and attack effects use separate material paths.

The rendering system can distinguish between:

  • Character base material
  • Weapon material
  • Emissive attack material
  • Transparent trail material
  • Hit-reaction material
  • Screen-facing impact geometry

The current visual style emphasizes blue, cyan and purple emissive effects.

Future improvements may include physically based materials, improved tone mapping and more controlled bloom.

Transparency and Overdraw

Several attack effects use transparent or additive rendering.

When large energy planes and multiple trails overlap, the fragment workload can increase significantly.

The main optimization areas include:

  • Reducing oversized transparent geometry
  • Limiting unnecessary screen coverage
  • Reducing inactive particles
  • Culling expired effect segments
  • Sorting transparent layers
  • Rendering selected effects at reduced resolution
  • Avoiding excessive additive blending
  • Adjusting effect quality dynamically

Current Development Focus

I am currently working on:

  • More stable CUDA–OpenGL synchronization
  • Lower dynamic-buffer update overhead
  • Improved GLB material rendering
  • Better separation between character and effect passes
  • More natural hit and knockback transitions
  • Reduced transparent overdraw
  • More accurate frame-time measurements
  • Long-duration runtime stability
  • Adaptive effect quality for Jetson

Questions for the Community

I would appreciate feedback on the following points:

  1. For attack geometry that changes every frame, is mapping and unmapping a CUDA–OpenGL VBO each frame an appropriate approach on Jetson Orin Nano?

  2. Would double-buffered or persistently allocated OpenGL buffers provide a meaningful improvement for this type of dynamic effect workload?

  3. What synchronization strategy is recommended when CUDA generates geometry immediately before OpenGL renders it?

  4. For large transparent sword trails, what is the most effective way to reduce overdraw on Jetson while preserving the visual shape?

  5. Is it preferable to generate all particle and trail vertices with CUDA, or would instanced OpenGL rendering be more efficient for repeated effect elements?

  6. Which Nsight Systems measurements are most useful for identifying stalls between CUDA geometry generation and OpenGL rendering?

Thank you for reading.

Any feedback regarding CUDA–OpenGL interoperability, GLB rendering, dynamic geometry generation or Jetson-specific optimization would be greatly appreciated.

Hi,
Please check the programming guide to get some information:
CUDA Runtime API :: CUDA Toolkit Documentation
4.19. CUDA Interoperability with APIs — CUDA Programming Guide

As suggested in
GPU-Generated Heart, Ribbon and Particle Effects for a GLB Character on Jetson Orin Nano - #3 by DaneLLL

You can do profiling through tegrastats or Nsight. If you don’t see GPU running at full loading, please share the simple test sample so that we can replicate it on developer kit and check if performance enhancement is possible.

Thank you for the guidance.

I will review the graphics samples under:

/usr/src/nvidia/graphics_demos/

and compare their EGL/OpenGL initialization, rendering loop, buffer management and resource cleanup with my current implementation.

I will also use tegrastats to collect GPU utilization, memory usage, temperature and power information during the GLB rendering and CUDA-generated effect sequences.

This should help me improve both the graphics architecture and the performance measurements of the project.

Thank you again for pointing me to the relevant Jetson resources.

Hi DaneLLL,

Thank you for the guidance and for sharing the relevant CUDA Runtime API and interoperability documentation.

I will profile the application with tegrastats and Nsight Systems, focusing on GPU utilization, CUDA kernel execution, CUDA–OpenGL resource mapping, synchronization stalls and rendering frame time.

If the GPU is not fully utilized, I will prepare a minimal reproducible sample containing:

  • A simplified GLB character
  • One CUDA-generated ribbon or particle effect
  • CUDA–OpenGL buffer interoperability
  • Build and run instructions
  • JetPack and CUDA version information
  • tegrastats and profiling results

I will remove unrelated assets and application features so that the performance issue can be reproduced easily on a Jetson developer kit.

Thank you very much for offering to check whether further performance enhancement is possible.