A Modular Render System for Cleanroom #405
tttsaurus
announced in
Work in Progress
Replies: 3 comments 1 reply
-
Conceptual API DesignECS-based Rendering FrameworkCleanWorld world = new CleanWorld();
RenderSystem renderSystem = new RenderSystem(world);
// systems can be generic but RenderSystem must be a special one
// and systems need an order of execution
world.registerSystem(new AnimationSystem());
world.registerSystem(new AISystem());
// we register com types ahead-of-time
// so it'll be easier to alloc offheap mem and manage
world.registerComponent(MeshComponent.class);
world.registerComponent(MaterialComponent.class);
world.registerComponent(TransformComponent.class);
// render passes should be generic
renderSystem.registerPass(new OpaquePass());
renderSystem.registerPass(new TransparentPass());
renderSystem.registerPass(new PostProcessPass());
void gameTick(float deltaTime)
{
world.tickSystems(deltaTime);
renderSystem.generateRenderCommands();
renderSystem.executeRenderPasses();
}// this is not a Minecraft entity & world!
CleanEntity entity = cleanWorld.createEntity();
// addComponent is giving a composition feeling
// but com data should be flattened and continuous in mem
// we can do hybrid tho, like offheap + traditional oop
entity.addComponent(new TransformComponent(data));
entity.addComponent(new MeshComponent(meshData));
entity.addComponent(new MaterialComponent(materialData));class RenderCommand
{
int meshID, ... ? // currently no idea how we design RenderCommand
// maybe we should record the owner of commands for the decoration purpose
}Minecraft-bridge and Mod Dev Partpublic class MyModTileEntityRenderer implements ITileEntityRenderer
{
@Override
public List<RenderCommand> createRenderCommands(TileEntity tileEntity, RenderContext ctx)
{
// maybe we don't use ID. not certain
int meshID = ctx.meshFactory.cube();
int matID = ctx.materialFactory.mat("my_mod:block/custom_texture");
return Collections.singletonList(new RenderCommand(...));
}
}// this should be a powerful thing
// like it'll be totally possible to add a bloom layer or something
public class ChestRenderingDecorator implements IRenderPassDecorator
{
@Override
public void decorate(Decorator deco)
{
deco.match(Chest).insert((tileEntity, ctx) ->
{
return Collections.singletonList(...);
});
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Progress on ECSPositionComponent positionComponent = new PositionComponent();
positionComponent.xyz = new Vector3f(1, 2, 3);
// components will be flattened and stored in archetype data pools
// and entities are represented as data rather than objects
// -> reduce per entity object allocations and gc pressure
ECS_RUNTIME.entityManager.createEntity(positionComponent);
ECS_RUNTIME.entityManager.createEntity(positionComponent);
ECS_RUNTIME.entityManager.createEntity(positionComponent);
// the side effects are deferred. guarantees thread safety
ECS_RUNTIME.entityManager.flush();
// the query is archetype oriented not entity oriented. faster query
List<ArchetypeDataPool> archetypes = ECS_RUNTIME.entityManager.startQuery(ECS_RUNTIME.entityManager.newQuery().with(PositionComponent.class));
LOGGER.info("archetype num: " + archetypes.size()); // assert: 1
// the array is fetched from archetype data pools directly. zero copy
// providing a friendly structure to parallel jobs
INativeArray<?> array = archetypes.get(0).getArray(PositionComponent.class, "xyz", "z");
ArrayRange range = archetypes.get(0).getArrayRange();
for (int i = range.start; i < range.end; i++) {
// skip deleted entities
if (range.deprecatedIndexes.contains(i)) {
continue;
}
LOGGER.info("debug: " + array.get(i));
} // assert: 3.0 3.0 3.0 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
One of the goals of Kirino should be to slowly deprecate and remove the way to access raw GL calls provided from LWJGL. Few things to consider:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
To provide a clean way to do rendering and prevent modders from leaking OpenGL.
Goals
Non Goals
Motivation
Description
Overview
Here's an overview of what we need to work on:
Low-level GL Abstraction
I'm just listing them based on my experience. We may need more or less while designing the system.
High-level GL Abstraction
Similar to Low-level GL Abstraction, we may need more or less of them.
ECS
Key clarifications:
When designing this library, we can discuss and possibly implement an ECS variant to accommodate Minecraft.
Render Commands
Using ECS, we implement a Render System that processes entities and generate render commands. This approach allows us to:
Overall Pipeline
Summary
This is my first time designing and outlining a system like this, so some technical details may be incomplete, and I'm not yet certain about the challenges before implementing it. However, the main idea is still clear and simple 1. use ECS for logic & data; 2. build a structured pipeline.
Dependencies
References
No response
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions