Separate vertex and fragment shaders and templates

This commit is contained in:
Jozufozu 2022-01-10 14:38:27 -08:00
parent 9f64ae4e9a
commit 88d8d24663
10 changed files with 11 additions and 23 deletions

View file

@ -50,7 +50,7 @@ public class FlwContraptionManager extends ContraptionRenderingWorld<FlwContrapt
Textures.bindActiveTextures();
ContraptionProgram structureShader = CreateContexts.STRUCTURE.getProgram(ProgramContext.create(Materials.Names.PASSTHRU, Formats.BLOCK, event.getLayer()));
ContraptionProgram structureShader = CreateContexts.STRUCTURE.getProgram(ProgramContext.create(Materials.Names.PASSTHRU, Formats.BLOCK, RenderLayer.getLayer(type)));
structureShader.bind();
structureShader.uploadViewProjection(event.viewProjection);

View file

@ -25,8 +25,8 @@ public class CreateContexts {
GameStateRegistry.register(RainbowDebugStateProvider.INSTANCE);
FileResolution header = Resolver.INSTANCE.get(ResourceUtil.subPath(CONTRAPTION, ".glsl"));
CWORLD = Templates.INSTANCING.programCompiler(ContraptionProgram::new, header);
STRUCTURE = Templates.ONE_SHOT.programCompiler(ContraptionProgram::new, header);
CWORLD = ProgramCompiler.create(Templates.INSTANCING, ContraptionProgram::new, header);
STRUCTURE = ProgramCompiler.create(Templates.ONE_SHOT, ContraptionProgram::new, header);
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -15,9 +15,7 @@ struct Belt {
float scrollMult;
};
#use "flywheel:block.frag"
#if defined(VERTEX_SHADER)
void vertex(inout Vertex v, Belt instance) {
v.pos = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
@ -33,4 +31,3 @@ void vertex(inout Vertex v, Belt instance) {
v.color = instance.color;
#endif
}
#endif

View file

@ -13,9 +13,6 @@ struct Actor {
float speed;
};
#use "flywheel:block.frag"
#if defined(VERTEX_SHADER)
void vertex(inout Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
@ -27,4 +24,3 @@ void vertex(inout Vertex v, Actor instance) {
v.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
v.light = instance.light;
}
#endif

View file

@ -14,10 +14,6 @@ struct Flap {
float flapness;
};
#use "flywheel:block.frag"
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
@ -48,4 +44,3 @@ void vertex(inout Vertex v, Flap flap) {
v.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
v.light = flap.light;
}
#endif

View file

@ -11,8 +11,6 @@ struct Rotating {
vec3 axis;
};
#use "flywheel:block.frag"
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
@ -20,7 +18,6 @@ mat4 kineticRotation(float offset, float speed, vec3 axis) {
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
void vertex(inout Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
@ -34,4 +31,3 @@ void vertex(inout Vertex v, Rotating instance) {
v.color = instance.color;
#endif
}
#endif