CHAPTER 62: The Engine That Breathes (Patreon)
Content
CHAPTER 62: The Engine That Breathes
George opened the source code of the Castlevania engine the second week of January and looked at it the way an architect looks at the blueprints of a house he is going to renovate. The walls were fine. The foundations were solid. But the house needed new windows, a different electrical system, and a way of breathing that the original version didn't have.
The Castlevania engine was three years old. George had written it in 1998 in a Fulton Street apartment with a Pentium II and a dream, and he had improved it gradually over Isaac and the console ports. It was a 2D tile engine with parallax, gravity physics, AABB collisions, and a sprite renderer that could move hundreds of entities on screen at 30 fps on any platform where NGS published. It was robust, battle-tested, and completely inadequate for Hollow Knight.
It worked like a Castlevania engine. And Hollow Knight was something else.
The Castlevania engine was designed for a game where each room was uniformly lit, where the camera followed the character with a fixed offset, where particles were a decorative luxury that didn't affect gameplay, and where the world was visible in its entirety from the moment the player entered a zone. Hollow Knight needed an engine where darkness was the natural state, where the camera was a narrator that guided the player's gaze, where particles were part of the identity of each zone, and where the world revealed itself gradually like a secret discovered step by step.
George needed three fundamental improvements. All three were going to take months. All three were going to transform the engine from a rendering tool into something that felt alive.
*
The first improvement was lighting.
In Castlevania, the lighting was fake. Each tile had a fixed brightness that Marcus chose when he painted the sprites. The dark zones were dark because the tiles were dark. The light zones were light because the tiles were light. There was no light system: there were tiles with colors that suggested light. It was an artist's trick, not an engine system.
In Isaac, George had implemented a rudimentary system for Depths: a brightness multiplier that darkened the tiles according to their distance from the player. It worked but it was crude. The edges between light and darkness were abrupt. The darkness was uniform instead of gradual. And the effect was generic darkness, not the specific darkness of a subterranean world where the only light source is the creature that walks through it.
For Hollow Knight, George wanted something different. He wanted the Knight to carry the light with him. Like a firefly that radiated in all directions instead of a flashlight that pointed to one side: a circular halo of soft light that lit the nearby tiles and faded gradually toward total darkness at the edges of the screen.
George implemented the system in two weeks.
The base was a light map: an invisible texture the size of the screen where each pixel had a brightness value between 0 (total darkness) and 255 (full light). The light map was generated every frame: the system calculated the distance of each pixel of the screen to the Knight, applied a radial falloff function that converted distance into brightness, and then multiplied the color of each visible tile by its corresponding brightness value. The tiles near the Knight showed with their original colors. The tiles far from the Knight darkened to black.
The falloff function was the detail that mattered. A linear falloff produced a flashlight effect: light within a fixed radius, darkness outside it. Ugly, artificial, like a spotlight pointed at the floor. George tried it and discarded it in ten minutes. A quadratic falloff was better: the light concentrated near the Knight and faded softly, like the light of a candle. But it was too concentrated: the player only saw a meter around him and the rest was black.
The function that worked was a combination: quadratic falloff in the center (intense light near the Knight), transition to linear falloff in the middle zone (gradual fading), and a minimum brightness value at the edges of 5% that let the silhouettes of the farthest tiles show without revealing their details. The player could see that there was something at the edge of the screen but not what it was. He knew a corridor existed to the left but not what inhabited it. The partial information was more effective than total darkness because it activated the imagination: the player's brain filled the darkness with possibilities that were more terrifying than any enemy George could design.
Daniel watched the lighting system running for the first time and said:
"The game breathes."
George looked at him.
"In Castlevania, the screen is static. You enter a room and you see everything. Here, the light moves with the character. The screen changes with every step. It's as if the game breathes to the player's rhythm."
It was the perfect description. And George adopted it as the internal name of the improved engine: the engine that breathes.
*
The Knight's halo wasn't the only light source.
George designed a system where any entity in the game could emit its own light. The lanterns of Dirtmouth had warm halos of fixed radius. The fireflies of Greenpath emitted pulses of green light that turned on and off in two-second cycles. The crystals of Crystal Peak radiated a cold white light that was more intense than the Knight's and that created zones of expanded visibility. The spores of Fungal Wastes glowed a faint purple that didn't light much but gave the zone an atmosphere of bioluminescence.
Each light source added to the light map. If the Knight was near a lantern, his personal halo blended with the lantern's halo, creating a wider and brighter zone of light. If he was far from any additional source, his halo was the only light on the screen and the darkness closed around him like a fist.
The computational cost was significant. Each frame, the system went through the list of active light sources, calculated their contribution to the light map, and summed the values. With twenty light sources on screen, the calculation took 15% of the available frame time. George optimized it with a precalculated table of radial falloff: instead of calculating the falloff function for each pixel every frame, he precalculated the values for every possible distance and stored them in an array that the system consulted by index. The optimization reduced the cost to 4%.
Marcus saw the lighting system running over his Greenpath tiles and stayed silent for a while. Then he said:
"My tiles look different."
"Better or worse?"
"Better. Much better. But different. When I painted them, I painted them thinking of uniform lighting. Each tile had its own light built into the colors. Now the light comes from the engine. My colors look more saturated where the light is strong and more muted where it's weak. It's as if the tiles had depth."
"Do you need to repaint anything?"
Marcus thought about it.
"Not repaint. Adjust. I need to reduce the light built into my tiles because the engine is adding it. If I leave my tiles with their original brightness and the engine adds more, the lit zones are going to look washed out. I need darker base tiles so the engine's light reveals them."
It was a change of philosophy. In Castlevania, the artist controlled the light. In Hollow Knight, the engine controlled the light and the artist painted for the darkness. Marcus had to unlearn three years of instinct and paint tiles that looked muted and ugly in Graphics Gale but that came to life when the engine added light to them.
"Painting for the darkness," Marcus said, repeating the phrase as if savoring it. "I like it. It's like painting a watercolor in a dark room knowing that someone is going to light a candle to see it."
*
The second improvement was the particle system.
The Castlevania system handled particles as decoration: dust motes that floated in the Catacombs, sparks that jumped from the candelabras, flashes of light at the save points. They were small sprites with predefined movement that didn't interact with the world. Pretty but inert.
The Hollow Knight system needed particles that lived. George wanted rain that fell with acceleration, bounced when it touched the ground, and formed visible puddles. He wanted spores that floated on simulated air currents, rising when the Knight ran beneath them and descending when the air calmed. He wanted dust that rose when the Knight landed from a jump and that settled slowly onto the floor tiles. He wanted petals in Greenpath that fell from the leaves and settled on the ground and that the Knight scattered as he walked past.
Each behavior required physics. Enough physics for the particles to feel real, without reaching the complexity of a simulator: gravity that pulled them down, horizontal velocity that moved them with the wind, collision with the ground that stopped them or made them bounce, and a lifetime that destroyed them after a number of frames so they wouldn't accumulate infinitely.
George rewrote the particle system from scratch. The new system treated each particle as an entity with position, velocity, acceleration, lifetime, and a set of flags that determined its behavior: does it bounce when it touches the ground? Does it get destroyed when it touches the ground? Does it collide with the tiles or pass through them? Is it affected by the wind? Does it emit its own light?
The system supported up to five hundred simultaneous particles. Not because George needed five hundred but because City of Tears was going to need them: the eternal rain of that zone required hundreds of drops falling across the screen every frame, each with its own velocity, its own impact position, and its own splash when it touched the ground.
George implemented the rain as a test of the system. Five hundred drops per frame. Each drop is born at a random position on the top edge of the screen with a vertical velocity of 8 pixels per frame and a random horizontal velocity of between -1 and +1 pixels per frame that simulated the wind. When a drop touched the ground, it spawned three splash particles that scattered laterally and disappeared in 4 frames. Each drop had a sprite of 1 by 4 pixels: a vertical line of light blue that, multiplied by five hundred, created the illusion of a dense rain.
The first time George ran the rain over the City of Tears tiles that Marcus was beginning to design, Daniel stopped what he was doing and came over to look.
"How many particles?"
"Five hundred. With splash on impact."
"Framerate?"
"Twenty-eight fps on PC. I need to optimize to reach a stable thirty."
"On PS2?"
"I haven't tested it yet. Probably twenty."
Daniel nodded. Twenty fps on PS2 meant the rain was going to need the texture-strip trick he was already planning. But that was a port problem, not a base engine problem. On PC, the rain worked. And it looked like rain: real rain falling inside a cave, bouncing on the stone floor, forming puddles that shone with the Knight's light.
Priya came up behind Daniel. She looked at the screen for five seconds. Then she said:
"I can hear the rain."
"There's no audio implemented yet," George said.
"I know. But I can hear it."
It was the highest compliment a visual system could receive: it was so convincing that the brain added the sound that was missing.
*
The third improvement was the camera. And it was the one that changed the most how it felt to play.
In Castlevania, the camera was simple: it followed Alucard with a fixed offset. If Alucard was in the center of the room, the camera showed the room centered on him. If he walked right, the camera shifted right at the same speed. It was functional, predictable, and completely invisible: the player never thought about the camera because the camera never did anything unexpected.
George wanted a camera that did something the player wouldn't consciously notice but would feel subconsciously: anticipate. Show the player what was coming before it arrived, without the player knowing that someone was guiding him.
The look-ahead was the central concept. When the Knight moved right, the camera moved ahead in that direction: instead of keeping the Knight in the center, it shifted him slightly to the left of the screen, showing more space to the right. When the Knight moved left, the camera did the opposite. The effect was subtle: the player saw more terrain in the direction of his movement, which gave him an extra fraction of a second to react to enemies, platforms, and chasms that appeared in front of him.
George implemented the look-ahead with a target point that moved ahead of the Knight. The camera didn't follow the Knight directly but the target point, which was offset 40 pixels in the direction of movement. The offset wasn't instantaneous: the target point accelerated smoothly toward its objective position and decelerated on arrival, creating a fluid camera movement that produced no dizziness or disorientation.
The vertical compensation was the second layer. When the Knight fell, the camera looked downward: the target point shifted 60 pixels below the Knight, showing more of the lower space. When he jumped, the camera stayed where it was and let the Knight rise on the screen, so the player could see where he was going to land. They were decisions that gave the player the information he needed at the moment he needed it without his asking for it.
And the third layer was what George internally called the "breath." When the Knight stopped, the camera didn't stop instantly: it kept moving a couple of pixels in the direction of the last movement, as if the camera had its own inertia, and then slowly returned to the center. The effect was that the world felt alive: when the player stopped, the camera exhaled, as if the world around the Knight kept moving an instant longer before stopping with him.
Tomás tested it for a week. His report was revealing:
"I didn't notice anything. I played two hours and didn't notice that the camera did anything different from Castlevania's. And then I went back to Castlevania to compare and Castlevania's camera felt rigid. Dead. Like a photo glued to the character. Hollow Knight's camera feels like... someone following you with their eyes."
"Did you notice it or not?" George asked.
"I didn't notice it while playing HK. I noticed it when I stopped playing HK. It's the kind of thing you don't see until it's gone."
George smiled. Invisible design. The specialty of the house.
*
By the end of February, George had the three improvements working: dynamic lighting, particles with physics, and a smart camera. He combined them in a test world he put together in an afternoon: a map of ten connected rooms with Greenpath placeholder tiles that Marcus had started, static enemies that didn't move, and a Knight that could walk, jump, and fall but couldn't attack because the combat system wasn't implemented yet.
Ten rooms. No final art. No music. No functional enemies. Just the Knight moving through a space that had dynamic light, dust particles that rose with every landing, leaves that fell from the upper tiles, and a camera that anticipated every movement with the subtlety of a good cameraman.
George played it at eight at night. Alone in the office.
He walked right. The camera moved ahead, revealing the corridor that was coming. Dust floated in the air, lit by the Knight's halo, tiny motes that sparkled like miniature stars. The placeholder tile walls were gray and without detail, but the light gave them depth: the edges of the tiles caught the halo and produced a gradient of brightness that suggested texture where there was none.
He jumped. The camera stayed low, showing the platform where he was going to land. In the air, the Knight crossed a zone with no upper tiles and for a second the screen showed a black void above him that was immense and that communicated height without needing a number or an indicator.
He landed. The dust particles rose from the ground in a semicircular fan that dissipated in eight frames. The camera exhaled: it moved two pixels to the right by inertia and returned to the center. The world breathed with George.
Ten rooms. No art. No sound. No combat. And it already felt like a place. A place that existed and that George was visiting. The light moved with him. The particles responded to his steps. The camera followed him with the attention of someone who knows where he is going.
George walked through the ten rooms three times. Then he sat down and looked at the screen where the Knight waited in his two-frame idle, breathing in the darkness of a world that was barely starting to exist.
The Castlevania engine rendered images. The Hollow Knight engine created spaces. The difference was in what the code produced: the sense of being somewhere, of occupying a volume of darkness that lit up with your presence and that darkened when you left.
Three technical improvements. Months of work. And the result was something that couldn't be measured in frames per second or in lines of code: the ability of a 2D game engine to make a player feel small in a big world, alone in a vast space, and curious to know what lay beyond the edge of the light.
The engine that breathed was ready. Now it had to be given a body.
End of Chapter 62