A heck of a lot

- Reorganize everything
 - Isolate SourceFile related things
 - Should consider decoupling ShaderLoader from resource loading
 - Document a lot of newer things
 - Index functions
 - Awkward WorldContext builder
 - Template responsible for providing shader inputs
 - Template is now an abstract class
 - Template provides GLSL version
 - ProgramSpecs now only accept one file
This commit is contained in:
Jozufozu 2021-08-10 02:06:23 -07:00
parent cb47ca8452
commit 208c6eff89
6 changed files with 15 additions and 25 deletions

View file

@ -2,14 +2,11 @@ package com.simibubi.create.foundation.render;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.lwjgl.opengl.GL46;
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.FileResolution; import com.jozufozu.flywheel.backend.source.FileResolution;
import com.jozufozu.flywheel.backend.ResourceUtil; import com.jozufozu.flywheel.backend.ResourceUtil;
import com.jozufozu.flywheel.backend.SpecMetaRegistry; import com.jozufozu.flywheel.backend.SpecMetaRegistry;
import com.jozufozu.flywheel.backend.pipeline.IShaderPipeline; import com.jozufozu.flywheel.backend.pipeline.IShaderPipeline;
import com.jozufozu.flywheel.backend.pipeline.ITemplate;
import com.jozufozu.flywheel.backend.pipeline.InstancingTemplate; import com.jozufozu.flywheel.backend.pipeline.InstancingTemplate;
import com.jozufozu.flywheel.backend.pipeline.OneShotTemplate; import com.jozufozu.flywheel.backend.pipeline.OneShotTemplate;
import com.jozufozu.flywheel.backend.pipeline.WorldShaderPipeline; import com.jozufozu.flywheel.backend.pipeline.WorldShaderPipeline;
@ -32,19 +29,17 @@ public class CreateContexts {
Backend backend = event.getBackend(); Backend backend = event.getBackend();
SpecMetaRegistry.register(RainbowDebugStateProvider.INSTANCE); SpecMetaRegistry.register(RainbowDebugStateProvider.INSTANCE);
CWORLD = backend.register(contraptionContext(backend, InstancingTemplate.INSTANCE));
STRUCTURE = backend.register(contraptionContext(backend, OneShotTemplate.INSTANCE)
.withSpecStream(() -> Stream.of(AllProgramSpecs.STRUCTURE)));
}
private static WorldContext<ContraptionProgram> contraptionContext(Backend backend, ITemplate template) {
FileResolution header = backend.sources.resolveFile(ResourceUtil.subPath(CONTRAPTION, ".glsl")); FileResolution header = backend.sources.resolveFile(ResourceUtil.subPath(CONTRAPTION, ".glsl"));
IShaderPipeline<ContraptionProgram> worldPipeline = new WorldShaderPipeline<>(backend.sources, ContraptionProgram::new, template, header); IShaderPipeline<ContraptionProgram> instancing = new WorldShaderPipeline<>(backend.sources, ContraptionProgram::new, InstancingTemplate.INSTANCE, header);
IShaderPipeline<ContraptionProgram> structure = new WorldShaderPipeline<>(backend.sources, ContraptionProgram::new, OneShotTemplate.INSTANCE, header);
return new WorldContext<>(backend, worldPipeline) CWORLD = backend.register(WorldContext.builder(backend, CONTRAPTION)
.withName(CONTRAPTION); .build(instancing));
STRUCTURE = backend.register(WorldContext.builder(backend, CONTRAPTION)
.setSpecStream(() -> Stream.of(AllProgramSpecs.STRUCTURE))
.build(structure));
} }
} }

View file

@ -1,6 +1,5 @@
{ {
"vert": "create:belt.vert", "source": "create:belt.vert",
"frag": "flywheel:block.frag",
"states": [ "states": [
{ {
"when": "create:rainbow_debug", "when": "create:rainbow_debug",

View file

@ -1,6 +1,5 @@
{ {
"vert": "create:contraption_actor.vert", "source": "create:contraption_actor.vert",
"frag": "flywheel:block.frag",
"states": [ "states": [
{ {
"when": { "when": {

View file

@ -1,6 +1,5 @@
{ {
"vert": "create:contraption_structure.vert", "source": "create:contraption_structure.vert",
"frag": "flywheel:block.frag",
"states": [ "states": [
{ {
"when": { "when": {

View file

@ -1,6 +1,5 @@
{ {
"vert": "create:flap.vert", "source": "create:flap.vert",
"frag": "flywheel:block.frag",
"states": [ "states": [
{ {
"when": { "when": {

View file

@ -1,6 +1,5 @@
{ {
"vert": "create:rotating.vert", "source": "create:rotating.vert",
"frag": "flywheel:block.frag",
"states": [ "states": [
{ {
"when": "create:rainbow_debug", "when": "create:rainbow_debug",