Back to JetBrains

Live-Building AI-Driven PCG with Godot, C#, and Gemini | Sharmishtha Sen | GameDev Day 2026

JetBrainsOctober 19, 202635m
In a Nutshell

Sharmistha Sen demonstrates an AI-assisted workflow that connects Gemini and local Ollama models through a Godot MCP bridge to generate and debug C# procedural generation code in real time inside JetBrains Rider. The system uses rule-based anchors, MultiMeshInstance3D batching, and background threading to create large-scale terrain with 30,000+ foliage instances at 60+ FPS on consumer hardware without subscriptions. All AI generation happens at editor time, so the final exported game runs as pure multi-threaded C# with zero runtime dependencies.

AI-Generated Notes

These notes were generated by AI and may contain inaccuracies.

Sharmishta Sen, known as Sammy in the community, presents on connecting open-source tooling, modern IDE workflows, and local agents with cloud language models directly into Godot to create an AI general editor-time code builder. The talk addresses the reality of building games in small teams or solo development.

Four major challenges face indie developers building expansive 3D worlds:

  • Handcraft burnout: Manually placing assets into 3D worlds one by one drains creative bandwidth away from mechanics, systems, and gameplay loops
  • SaaS and budget barriers: Modern generative tools require expensive enterprise subscriptions or heavy server clusters, while indies need pipelines that run on consumer-grade mid-tier hardware with zero subscription fees
  • Soldier's void: Traditional procedural generation using simplex or Perlin noise creates repetitive worlds with chaotic, unplayable blobs lacking landmarks, natural choke points, or paced gameplay
  • Environmental QA bottleneck: Generated random terrains require days of manual inspection to find floating trees, broken collision, or impossible geometry

Godot 4's dynamic scripting struggles when iterating through hundreds or thousands of vertices coordinates in real time, which is why PCG code is built entirely on C# using .NET framework for faster real-time performance compared to GDScript.

High Performance Geometry Threading

Terrain meshes are generated using Godot's low-level ArrayMesh and FastNoiseLite. Heavy noise sampling, analytical normal evaluation, and vertex coordinate mapping are offloaded to asynchronous background tasks while the main thread remains completely responsive.

GPU Accelerated Batch Scattering

Instead of instantiating individual Node3D scenes for every tree, rock, or bush, the C# script calculates candidate positions, checks slope limits, and serializes transform matrices directly into a PackedFloat32Array buffer. This buffer feeds into a MultiMeshInstance3D, batching over 30,000 environmental instances in a single GPU draw call.

Managed Proceduralism via Authored Anchors

To avoid soulless voids, authored Marker3D nodes are defined in scenes. C# math calculates distance from each vertex to these anchors and uses linear interpolation to flatten dynamic noise into smooth foundations for tutorial hubs, roads, and dungeons while automatically carving out vegetation and clear zones.

Web-based LLM models like ChatGPT, Claude, or Gemini lack access to active scene tree node hierarchy or script dependencies, leading to null reference exceptions. General models trained on older Godot versions provide GDScript 3 syntax and old connect signal code signatures that fail in Godot 4 C#.

Silent Runtime Failures

Web chatbots cannot read engine console or runtime debugger output, creating mismatches between AI-generated code and live editor conditions.

Engine and IDE Setup

Direct AI implementation into IDE setup using JetBrains Rider with dedicated editor bindings bidirectionally using C# syncing.

Local and Cloud AI Dual Brain Setup

  • Local AI: Ollama instance on localhost:11434
  • Cloud AI: Gemini 1.5 Pro connected via Continue plugin

Engine Context Bridge

Godot MCP Pro plugin running on local WebSocket server port 6505 exposes scene hierarchies to both AI models.

Custom C# PCG Core

Procedural generator handles ArrayMesh construction, vector math, and Marker3D height blending.

GPU Scattering and Shaders

MultiMeshInstance3D pipeline batches foliage combined with custom Godot shader code for procedural height and texture blending.

Rider provides high-performance IDE capabilities essential for heavy procedural generation loops. The Continue plugin enables instant error checking and solutions without constant reload cycles. Advanced profiling includes performance profiler and memory allocation trackers for handling 30,000-50,000 element scattering.

Cloud APIs have limited tokens, and PCG logic requires hundreds or thousands of iterations. The dual agent architecture uses:

  • Cloud AI (Gemini 1.5 Pro): Refactoring, writing special shaders, algorithms, optimizing C# math, providing maximum reasoning power and deep context
  • Local AI (Ollama with KMA 3 or Qwen 2.5 Coder): Inline copilot for autocompletion, helping functions, tweaking PCG parameters, running 100% offline with complete privacy at zero cost

Both models access the shared Godot MCP server on WebSocket port 6505, ensuring scene hierarchy visibility regardless of which model handles complex tasks.

Pipeline runs on Nvidia 1060 6GB GPU and Intel Core i7 CPU. Local LLM models require only 4-8GB VRAM via Ollama and work on standardized gaming laptops, eliminating need for high-end hardware.

Prompt to Continue plugin: "Update the min and max scale properties to use an export property hint range from 0.1 to 5.0 with 0.5 step increments and keep the defaults at 0.2 and 0.5 and do not touch any other properties." Agent generates precise Godot 4 C# attribute syntax without rewriting entire files or introducing deprecated Godot syntax.

MCP server installed via npx pointing to Godot executable, establishing bidirectional communication bridge. No major installation hassle required.

Scene Awareness

AI queries MCP server to inspect active scene tree node hierarchies, knowing exact static content parent locations and mesh generator positions. Uses verified node paths for automated debugging.

Runtime Debugging

MCP server allows AI to launch Godot editor, run projects in debug mode, capture live console output, runtime stack traces, and self-correct C# code when engine exceptions occur.

Foliage clumping too closely together prompted: "Update the spawn foliage layer method to prevent clumping and maintain a list of spawn positions before adding a new Transform3D and check if the distance between the current vertex and all previously spawned positions is greater than the minimum radius and only spawn if far enough away."

AI response used distance squared formula instead of Vector3.Distance, eliminating expensive square root calculations in loops running tens of thousands of times.

To prevent carbon data and CPU overload:

  1. Rule-based engine access: Explicit Continue rules instruct AI to query Godot MCP on port 6505 before generating code
  2. Context-aware fetching: Agent inspects scene tree and project dependencies before script modifications
  3. Zero hallucination execution: Strict system prompts with verified MCP data eliminate version confusion
  4. Closed-loop verification: MCP bridge feeds console logs back into AI context for immediate self-correction

Inspector Parameters Export

  • Noise frequencies: 0.015f
  • Maximum terrain height: 8.0f
  • Random seeds and Marker3D blend values

Engine Scene Tree and Node Paths

  • Live verified string paths: static content parent, marker tutorial

Procedural Geometry Buffer

  • ArrayMesh vertex coordinates, counterclockwise quad indexed arrays, analytical normal vectors

GPU Foliage Logic

  • PackedFloat32Array containing 3D transformation matrices: position, rotation, base, scale fed directly into MultiMeshInstance3D

Rules enforce:

  • Only use C# code
  • Only use Godot 4 syntax
  • Node3D, CharacterBody3D, exposed via [Export]
  • Construct meshes using CCW winding
  • Verify scene paths via MCP before generating references

Dedicated Continue workspace rule "Godot 4 C# world generation" automatically inherits constants for every prompt, ensuring consistent clean code generation.

Dynamic Chunk Loading

World divided into infinite grid of chunks. Chunk manager monitors player coordinates, dynamically instantiates chunks within target area, culls and frees out-of-bounds chunks while maintaining 60+ FPS.

Off-Thread Mesh Generation

FastNoiseLite calculations run on background threads using Task.Run. CallDeferred passes completed buffers back to main thread safely.

Managed Procedural Blending

Dynamic height maps continuously interpolated around Marker3D anchors, ensuring critical gameplay foundations remain stable regardless of procedural seed changes.

Dual Vector Math

Geometric cross product calculates uniform normals for each triangle, creating clean low-poly aesthetics. For sandy or dirt terrain, cross product edge generation resolves chunk border lighting issues.

Slope Awareness GPU Foliage

Foliage manager samples Y component of surface normal. Checking if normal dot Y is less than max slope prevents trees and rocks from spawning on vertical surfaces.

Realtime Physics

Collision shape extracted from generated ArrayMesh creates shape attached to CollisionShape3D with concave backface collision set to true, ensuring player characters never clip or fall through procedural terrain.

The foliage distributes cleanly across the landscape with tree clusters naturally positioned in valleys and flat cleared areas. As terrain rises into steeper ridges, the system automatically keeps slopes clear. Lighting remains consistent across the entire chunk, running at a locked frame rate of 60 plus FPS.

Complex manual wrapping is not required for the procedural world. A custom shader can be used, and instead of hot reloading, developers can directly edit the Godot code in Rider. Pressing Control+S instantly reloads the shader material inside the PCG cart. When generating procedural meshes, a common visual bug involves invisible or cull triangles. If an array is indexed clockwise instead of counterclockwise, Godot renders it incorrectly and the issue becomes invisible. Adding render color mode disabled guarantees both sides are drawn, eliminating transparent holes in terrain or glare when sunlight hits the surface.

The AI was prompted to structure shader parameters using a group uniform and hint range, automatically building clean sliders in Godot. The inspector allows visual adjustment of sand, grass, building noise, patch scales, and roughness without touching code. The shader implementation provides Gemini with logic to generate organic orange dirt patches, keep render mode color disabled, add uniform vector 4 for sand, grass, and patched albedo, and use a 3D value noise function based on world position to mask patches primarily over grass.

The system maintains locked 60+ FPS performance through several architectural decisions:

  • Zero runtime overhead: All AI generation occurs strictly at editor time inside JetBrains Rider. When exporting the final game executable, no language models run on cloud API calls, allowing compilation to pure multi-threaded C#
  • Asynchronous threading: All noise calculations and vertex array generation run off-thread, with tasks safely transferred to the main thread via call deferred
  • GPU draw call batching: Through multi-mesh instances, 20,000 to 30,000 trees, rocks, and grass render in a single draw call by serializing transform matrices into a flat memory buffer without allocating individual tree nodes
  • Dynamic chunk culling: Chunks stream based on player proximity, immediately freeing out-of-bounds meshes to prevent RAM bloating and memory leaks

The integrated procedures produce smooth terrain with custom spatial shaders running from warm sand to organic dirt patches. Thousands of stylized bridge trees and boulders populate the landscape. The entire world generates and textures populate using editor-time AI co-builder inside Rider and Godot, building on open-source tools running locally with zero manual asset placement.

  1. Editor-time code builder: Stop treating AI as a runtime player gimmick and use an MCP bridge to connect your IDE with Godot using IMCP
  2. Manage proceduralism and performance: Don't let AI go wild - use rules, marker 2D, and math logic
  3. Future development: More foliage buffers that handle data more efficiently, loops, and runtime debuggers
  4. This is currently a prototype with planned expansions

The session emphasizes building the future of game development together through open-source tools and AI-assisted workflows that combine procedural generation scalability with deliberate handcrafted level design structure.

Keep JetBrains in your library

Save the videos and channels worth coming back to, and find them again in one place.