mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Separate vertex and fragment shaders and templates
This commit is contained in:
parent
9f64ae4e9a
commit
88d8d24663
10 changed files with 11 additions and 23 deletions
|
@ -50,7 +50,7 @@ public class FlwContraptionManager extends ContraptionRenderingWorld<FlwContrapt
|
||||||
|
|
||||||
Textures.bindActiveTextures();
|
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.bind();
|
||||||
structureShader.uploadViewProjection(event.viewProjection);
|
structureShader.uploadViewProjection(event.viewProjection);
|
||||||
|
|
|
@ -25,8 +25,8 @@ public class CreateContexts {
|
||||||
GameStateRegistry.register(RainbowDebugStateProvider.INSTANCE);
|
GameStateRegistry.register(RainbowDebugStateProvider.INSTANCE);
|
||||||
FileResolution header = Resolver.INSTANCE.get(ResourceUtil.subPath(CONTRAPTION, ".glsl"));
|
FileResolution header = Resolver.INSTANCE.get(ResourceUtil.subPath(CONTRAPTION, ".glsl"));
|
||||||
|
|
||||||
CWORLD = Templates.INSTANCING.programCompiler(ContraptionProgram::new, header);
|
CWORLD = ProgramCompiler.create(Templates.INSTANCING, ContraptionProgram::new, header);
|
||||||
STRUCTURE = Templates.ONE_SHOT.programCompiler(ContraptionProgram::new, header);
|
STRUCTURE = ProgramCompiler.create(Templates.ONE_SHOT, ContraptionProgram::new, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"source": "create:belt.vert",
|
"vertex": "create:belt.vert",
|
||||||
|
"fragment": "flywheel:block.frag",
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"when": "create:rainbow_debug",
|
"when": "create:rainbow_debug",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"source": "create:contraption_actor.vert",
|
"vertex": "create:contraption_actor.vert",
|
||||||
|
"fragment": "flywheel:block.frag",
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"when": "flywheel:normal_debug",
|
"when": "flywheel:normal_debug",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"source": "create:flap.vert",
|
"vertex": "create:flap.vert",
|
||||||
|
"fragment": "flywheel:block.frag",
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"when": "flywheel:normal_debug",
|
"when": "flywheel:normal_debug",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"source": "create:rotating.vert",
|
"vertex": "create:rotating.vert",
|
||||||
|
"fragment": "flywheel:block.frag",
|
||||||
"states": [
|
"states": [
|
||||||
{
|
{
|
||||||
"when": "create:rainbow_debug",
|
"when": "create:rainbow_debug",
|
||||||
|
|
|
@ -15,9 +15,7 @@ struct Belt {
|
||||||
float scrollMult;
|
float scrollMult;
|
||||||
};
|
};
|
||||||
|
|
||||||
#use "flywheel:block.frag"
|
|
||||||
|
|
||||||
#if defined(VERTEX_SHADER)
|
|
||||||
void vertex(inout Vertex v, Belt instance) {
|
void vertex(inout Vertex v, Belt instance) {
|
||||||
v.pos = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
|
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;
|
v.color = instance.color;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -13,9 +13,6 @@ struct Actor {
|
||||||
float speed;
|
float speed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#use "flywheel:block.frag"
|
|
||||||
|
|
||||||
#if defined(VERTEX_SHADER)
|
|
||||||
void vertex(inout Vertex v, Actor instance) {
|
void vertex(inout Vertex v, Actor instance) {
|
||||||
float degrees = instance.offset + uTime * instance.speed / 20.;
|
float degrees = instance.offset + uTime * instance.speed / 20.;
|
||||||
//float angle = fract(degrees / 360.) * PI * 2.;
|
//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.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
|
||||||
v.light = instance.light;
|
v.light = instance.light;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -14,10 +14,6 @@ struct Flap {
|
||||||
float flapness;
|
float flapness;
|
||||||
};
|
};
|
||||||
|
|
||||||
#use "flywheel:block.frag"
|
|
||||||
|
|
||||||
#if defined(VERTEX_SHADER)
|
|
||||||
|
|
||||||
float toRad(float degrees) {
|
float toRad(float degrees) {
|
||||||
return fract(degrees / 360.) * PI * 2.;
|
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.normal = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
|
||||||
v.light = flap.light;
|
v.light = flap.light;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -11,8 +11,6 @@ struct Rotating {
|
||||||
vec3 axis;
|
vec3 axis;
|
||||||
};
|
};
|
||||||
|
|
||||||
#use "flywheel:block.frag"
|
|
||||||
|
|
||||||
mat4 kineticRotation(float offset, float speed, vec3 axis) {
|
mat4 kineticRotation(float offset, float speed, vec3 axis) {
|
||||||
float degrees = offset + uTime * speed * 3./10.;
|
float degrees = offset + uTime * speed * 3./10.;
|
||||||
float angle = fract(degrees / 360.) * PI * 2.;
|
float angle = fract(degrees / 360.) * PI * 2.;
|
||||||
|
@ -20,7 +18,6 @@ mat4 kineticRotation(float offset, float speed, vec3 axis) {
|
||||||
return rotate(axis, angle);
|
return rotate(axis, angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VERTEX_SHADER)
|
|
||||||
void vertex(inout Vertex v, Rotating instance) {
|
void vertex(inout Vertex v, Rotating instance) {
|
||||||
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
|
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
|
||||||
|
|
||||||
|
@ -34,4 +31,3 @@ void vertex(inout Vertex v, Rotating instance) {
|
||||||
v.color = instance.color;
|
v.color = instance.color;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in a new issue