Skip to content

VERTEX_ID and mesh-less rendering #19473

Closed
@Zylann

Description

A friend of mine explained me an interesting rendering technique recently:
In some cases, you can render particles, grass, water or terrain chunks without using any mesh, and generating the geometry procedurally in the vertex shader, without geometry shader.

For example:

position = vec2(gl_VertexId & 1 ? -1.0f : 1.0f, gl_VertexId & 2 ? -1.0f : 1.0f);

The idea is to expose the VERTEX_ID builtin from GLSL in the shading language, and add the ability to draw something without specifying a vertex array. Instead, just specifying how many vertices there are, but without data (oh my god! No vertices? Mind = blown).
I think it should work in the version of OpenGL Godot uses.

The advantages are:

  • No need to setup a mesh
  • Reduces memory usage
  • Removes cost of vertex memory access
  • More dynamic shape variety using procedural techniques

Now, I'm aware that probably nobody in Godot thinks about it, since it's a kind of optimization you can do in an advanced stage of a game's development, but it's an interesting technique to consider.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions