fast actor rendering but it's not correct yet

This commit is contained in:
JozsefA 2021-01-22 18:00:14 -08:00
parent f6518d5c5d
commit cfd60fbc8d
13 changed files with 115 additions and 37 deletions

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -31,12 +32,12 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
@OnlyIn(value = Dist.CLIENT) @OnlyIn(value = Dist.CLIENT)
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) { IRenderTypeBuffer buffer) {
DrillRenderer.renderInContraption(context, ms, msLocal, buffer); //DrillRenderer.renderInContraption(context, ms, msLocal, buffer);
} }
@Override @Override
public void addInstance(MovementContext context) { public void addInstance(RenderedContraption contraption, MovementContext context) {
super.addInstance(context); DrillRenderer.addInstanceForContraption(contraption, context);
} }
@Override @Override

View file

@ -7,6 +7,9 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import com.simibubi.create.foundation.render.instancing.RenderMaterial;
import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingActorData;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.MatrixStacker;
@ -19,6 +22,7 @@ import com.simibubi.create.foundation.render.instancing.RotatingData;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -37,8 +41,20 @@ public class DrillRenderer extends KineticTileEntityRenderer {
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(state); return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(state);
} }
public static void addInstanceForContraption(MovementContext context) { public static void addInstanceForContraption(RenderedContraption contraption, MovementContext context) {
//AllBlockPartials.DRILL_HEAD. RenderMaterial<InstanceBuffer<StaticRotatingActorData>> renderMaterial = contraption.getActorMaterial();
BlockState state = context.state;
InstanceBuffer<StaticRotatingActorData> model = renderMaterial.getModel(AllBlockPartials.DRILL_HEAD, state);
model.setupInstance(data -> {
Direction facing = state.get(DrillBlock.FACING);
Vector3f orientation = facing.getOpposite().getUnitVector();
data.setPosition(context.localPos)
.setRotationOffset(0)
.setRotationAxis(orientation)
.setLocalRotation(AngleHelper.verticalAngle(facing), facing.getHorizontalAngle(), 0);
});
} }
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.block.HorizontalBlock.HORIZONTAL_FACING; import static net.minecraft.block.HorizontalBlock.HORIZONTAL_FACING;
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableBoolean;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
@ -35,10 +36,15 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
.getOpposite()); .getOpposite());
} }
@Override
public void addInstance(RenderedContraption contraption, MovementContext context) {
HarvesterRenderer.addInstanceForContraption(contraption, context);
}
@Override @Override
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffers) { IRenderTypeBuffer buffers) {
HarvesterRenderer.renderInContraption(context, ms, msLocal, buffers); //HarvesterRenderer.renderInContraption(context, ms, msLocal, buffers);
} }
@Override @Override

View file

@ -5,6 +5,10 @@ import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FAC
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import com.simibubi.create.foundation.render.instancing.InstanceBuffer;
import com.simibubi.create.foundation.render.instancing.RenderMaterial;
import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingActorData;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -14,6 +18,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -34,6 +39,25 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
} }
public static void addInstanceForContraption(RenderedContraption contraption, MovementContext context) {
RenderMaterial<InstanceBuffer<StaticRotatingActorData>> renderMaterial = contraption.getActorMaterial();
BlockState state = context.state;
InstanceBuffer<StaticRotatingActorData> model = renderMaterial.getModel(AllBlockPartials.HARVESTER_BLADE, state);
model.setupInstance(data -> {
Direction facing = state.get(HORIZONTAL_FACING);
Direction rotationAxis = facing.rotateY();
float originOffset = 1 / 16f;
Vector3f rotOffset = new Vector3f(0.5f, -2 * originOffset + 0.5f, originOffset + 0.5f);
data.setPosition(context.localPos)
.setRotationOffset(0)
.setRotationCenter(rotOffset)
.setRotationAxis(rotationAxis.getUnitVector())
.setLocalRotation(0, facing.getHorizontalAngle(), 0);
});
}
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffers) { IRenderTypeBuffer buffers) {
BlockState blockState = context.state; BlockState blockState = context.state;

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -56,7 +57,7 @@ public abstract class MovementBehaviour {
IRenderTypeBuffer buffer) {} IRenderTypeBuffer buffer) {}
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void addInstance(MovementContext context) {} public void addInstance(RenderedContraption contraption, MovementContext context) {}
public void onSpeedChanged(MovementContext context, Vec3d oldMotion, Vec3d motion) { public void onSpeedChanged(MovementContext context, Vec3d oldMotion, Vec3d motion) {

View file

@ -73,7 +73,7 @@ public class FastKineticRenderer {
public void invalidate() { public void invalidate() {
for (RenderMaterial<?> material : materials.values()) { for (RenderMaterial<?> material : materials.values()) {
material.runOnAll(InstanceBuffer::delete); material.delete();
} }
dirty = true; dirty = true;
} }

View file

@ -5,12 +5,8 @@ import com.simibubi.create.foundation.render.instancing.BeltBuffer;
import com.simibubi.create.foundation.render.instancing.KineticRenderMaterials; import com.simibubi.create.foundation.render.instancing.KineticRenderMaterials;
import com.simibubi.create.foundation.render.instancing.RenderMaterial; import com.simibubi.create.foundation.render.instancing.RenderMaterial;
import com.simibubi.create.foundation.render.instancing.RotatingBuffer; import com.simibubi.create.foundation.render.instancing.RotatingBuffer;
import com.simibubi.create.foundation.render.instancing.actors.RotatingActorBuffer;
import com.simibubi.create.foundation.render.shader.Shader; import com.simibubi.create.foundation.render.shader.Shader;
import com.simibubi.create.foundation.render.shader.ShaderCallback;
import com.simibubi.create.foundation.render.shader.ShaderHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.RenderType;
public class ContraptionKineticRenderer extends FastKineticRenderer { public class ContraptionKineticRenderer extends FastKineticRenderer {
@ -18,6 +14,7 @@ public class ContraptionKineticRenderer extends FastKineticRenderer {
public void registerMaterials() { public void registerMaterials() {
materials.put(KineticRenderMaterials.BELTS, new RenderMaterial<>(Shader.CONTRAPTION_BELT, BeltBuffer::new)); materials.put(KineticRenderMaterials.BELTS, new RenderMaterial<>(Shader.CONTRAPTION_BELT, BeltBuffer::new));
materials.put(KineticRenderMaterials.ROTATING, new RenderMaterial<>(Shader.CONTRAPTION_ROTATING, RotatingBuffer::new)); materials.put(KineticRenderMaterials.ROTATING, new RenderMaterial<>(Shader.CONTRAPTION_ROTATING, RotatingBuffer::new));
materials.put(KineticRenderMaterials.ACTORS, new RenderMaterial<>(Shader.CONTRAPTION_ACTOR, RotatingActorBuffer::new));
} }
@Override @Override

View file

@ -7,8 +7,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.FastKineticRenderer; import com.simibubi.create.foundation.render.FastKineticRenderer;
import com.simibubi.create.foundation.render.instancing.IInstanceRendered; import com.simibubi.create.foundation.render.instancing.*;
import com.simibubi.create.foundation.render.instancing.IInstancedTileEntityRenderer; import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingActorData;
import com.simibubi.create.foundation.render.light.ContraptionLighter; import com.simibubi.create.foundation.render.light.ContraptionLighter;
import com.simibubi.create.foundation.render.shader.ShaderHelper; import com.simibubi.create.foundation.render.shader.ShaderHelper;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
@ -43,6 +43,8 @@ public class RenderedContraption {
buildLayers(contraption); buildLayers(contraption);
buildInstancedTiles(contraption); buildInstancedTiles(contraption);
buildActors(contraption);
kinetics.markAllDirty();
} }
public int getEntityId() { public int getEntityId() {
@ -57,6 +59,10 @@ public class RenderedContraption {
return lighter; return lighter;
} }
public RenderMaterial<InstanceBuffer<StaticRotatingActorData>> getActorMaterial() {
return kinetics.get(KineticRenderMaterials.ACTORS);
}
public void doRenderLayer(RenderType layer, int shader) { public void doRenderLayer(RenderType layer, int shader) {
ContraptionBuffer buffer = renderLayers.get(layer); ContraptionBuffer buffer = renderLayers.get(layer);
if (buffer != null) { if (buffer != null) {
@ -93,8 +99,6 @@ public class RenderedContraption {
} }
} }
} }
kinetics.markAllDirty();
} }
private void buildActors(Contraption c) { private void buildActors(Contraption c) {
@ -107,7 +111,7 @@ public class RenderedContraption {
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state); MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
if (movementBehaviour != null) { if (movementBehaviour != null) {
movementBehaviour.addInstance(context); movementBehaviour.addInstance(this, context);
} }
} }
} }

View file

@ -99,7 +99,7 @@ public abstract class InstanceBuffer<D extends InstanceData> extends GPUBuffer {
} }
protected int getTotalShaderAttributeCount() { protected int getTotalShaderAttributeCount() {
return getInstanceFormat().getShaderAttributeCount() + FORMAT.getShaderAttributeCount(); return getInstanceFormat().getShaderAttributeCount() + super.getTotalShaderAttributeCount();
} }
@Override @Override
@ -130,7 +130,7 @@ public abstract class InstanceBuffer<D extends InstanceData> extends GPUBuffer {
buffer.rewind(); buffer.rewind();
GL15.glUnmapBuffer(GL15.GL_ARRAY_BUFFER); GL15.glUnmapBuffer(GL15.GL_ARRAY_BUFFER);
int staticAttributes = FORMAT.getShaderAttributeCount(); int staticAttributes = getModelFormat().getShaderAttributeCount();
instanceFormat.informAttributes(staticAttributes); instanceFormat.informAttributes(staticAttributes);
for (int i = 0; i < instanceFormat.getShaderAttributeCount(); i++) { for (int i = 0; i < instanceFormat.getShaderAttributeCount(); i++) {

View file

@ -1,6 +1,10 @@
package com.simibubi.create.foundation.render.instancing; package com.simibubi.create.foundation.render.instancing;
import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingActorData;
public class KineticRenderMaterials { public class KineticRenderMaterials {
public static final MaterialType<InstanceBuffer<RotatingData>> ROTATING = new MaterialType<>(); public static final MaterialType<InstanceBuffer<RotatingData>> ROTATING = new MaterialType<>();
public static final MaterialType<InstanceBuffer<BeltData>> BELTS = new MaterialType<>(); public static final MaterialType<InstanceBuffer<BeltData>> BELTS = new MaterialType<>();
public static final MaterialType<InstanceBuffer<StaticRotatingActorData>> ACTORS = new MaterialType<>();
} }

View file

@ -1,7 +1,6 @@
package com.simibubi.create.foundation.render.instancing.actors; package com.simibubi.create.foundation.render.instancing.actors;
import com.simibubi.create.foundation.render.instancing.InstanceData; import com.simibubi.create.foundation.render.instancing.InstanceData;
import com.simibubi.create.foundation.render.instancing.RotatingData;
import com.simibubi.create.foundation.render.instancing.VertexFormat; import com.simibubi.create.foundation.render.instancing.VertexFormat;
import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.Vector3f;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -11,7 +10,7 @@ import java.nio.ByteBuffer;
import static com.simibubi.create.foundation.render.instancing.VertexAttribute.*; import static com.simibubi.create.foundation.render.instancing.VertexAttribute.*;
public class StaticRotatingActorData extends InstanceData { public class StaticRotatingActorData extends InstanceData {
public static VertexFormat FORMAT = new VertexFormat(POSITION, FLOAT, NORMAL, NORMAL); public static VertexFormat FORMAT = new VertexFormat(POSITION, FLOAT, NORMAL, VEC3, NORMAL);
private float x; private float x;
private float y; private float y;
@ -20,9 +19,12 @@ public class StaticRotatingActorData extends InstanceData {
private byte rotationAxisX; private byte rotationAxisX;
private byte rotationAxisY; private byte rotationAxisY;
private byte rotationAxisZ; private byte rotationAxisZ;
private byte localOrientationX; private float localRotationX;
private byte localOrientationY; private float localRotationY;
private byte localOrientationZ; private float localRotationZ;
private byte rotationCenterX = 64;
private byte rotationCenterY = 64;
private byte rotationCenterZ = 64;
public StaticRotatingActorData setPosition(BlockPos pos) { public StaticRotatingActorData setPosition(BlockPos pos) {
this.x = pos.getX(); this.x = pos.getX();
@ -48,15 +50,27 @@ public class StaticRotatingActorData extends InstanceData {
return this; return this;
} }
public StaticRotatingActorData setLocalOrientation(Vector3f axis) { public StaticRotatingActorData setRotationCenter(Vector3f axis) {
setRotationAxis(axis.getX(), axis.getY(), axis.getZ()); setRotationCenter(axis.getX(), axis.getY(), axis.getZ());
return this; return this;
} }
public StaticRotatingActorData setLocalOrientation(float localOrientationX, float localOrientationY, float localOrientationZ) { public StaticRotatingActorData setRotationCenter(float rotationCenterX, float rotationCenterY, float rotationCenterZ) {
this.localOrientationX = (byte) (localOrientationX * 127); this.rotationCenterX = (byte) (rotationCenterX * 127);
this.localOrientationY = (byte) (localOrientationY * 127); this.rotationCenterY = (byte) (rotationCenterY * 127);
this.localOrientationZ = (byte) (localOrientationZ * 127); this.rotationCenterZ = (byte) (rotationCenterZ * 127);
return this;
}
public StaticRotatingActorData setLocalRotation(Vector3f axis) {
setLocalRotation(axis.getX(), axis.getY(), axis.getZ());
return this;
}
public StaticRotatingActorData setLocalRotation(float localRotationX, float localRotationY, float localRotationZ) {
this.localRotationX = localRotationX;
this.localRotationY = localRotationY;
this.localRotationZ = localRotationZ;
return this; return this;
} }
@ -65,7 +79,8 @@ public class StaticRotatingActorData extends InstanceData {
putVec3(buf, x, y, z); putVec3(buf, x, y, z);
put(buf, rotationOffset); put(buf, rotationOffset);
putVec3(buf, rotationAxisX, rotationAxisY, rotationAxisZ); putVec3(buf, rotationAxisX, rotationAxisY, rotationAxisZ);
putVec3(buf, localOrientationX, localOrientationY, localOrientationZ); putVec3(buf, localRotationX, localRotationY, localRotationZ);
putVec3(buf, rotationCenterX, rotationCenterY, rotationCenterZ);
} }
} }

View file

@ -6,7 +6,7 @@ public enum Shader {
CONTRAPTION_STRUCTURE("shader/contraption.vert", "shader/contraption.frag"), CONTRAPTION_STRUCTURE("shader/contraption.vert", "shader/contraption.frag"),
CONTRAPTION_ROTATING("shader/contraption_rotating.vert", "shader/contraption.frag"), CONTRAPTION_ROTATING("shader/contraption_rotating.vert", "shader/contraption.frag"),
CONTRAPTION_BELT("shader/contraption_belt.vert", "shader/contraption.frag"), CONTRAPTION_BELT("shader/contraption_belt.vert", "shader/contraption.frag"),
//CONTRAPTION_ACTOR("shader/contraption_actor.vert", "shader/contraption.frag"), CONTRAPTION_ACTOR("shader/contraption_actor.vert", "shader/contraption.frag"),
; ;
public final String vert; public final String vert;

View file

@ -9,10 +9,11 @@ layout (location = 2) in vec2 aTexCoords;
layout (location = 3) in vec3 instancePos; layout (location = 3) in vec3 instancePos;
layout (location = 4) in float rotationOffset; layout (location = 4) in float rotationOffset;
layout (location = 5) in vec3 localRotationAxis; layout (location = 5) in vec3 localRotationAxis;
layout (location = 6) in vec3 localOrientation; layout (location = 6) in vec3 localRotation;
layout (location = 7) in vec3 rotationCenter;
// dynamic data // dynamic data
layout (location = 7) in vec3 relativeMotion; //layout (location = 7) in vec3 relativeMotion;
out float Diffuse; out float Diffuse;
out vec2 TexCoords; out vec2 TexCoords;
@ -40,7 +41,12 @@ mat4 rotate(vec3 axis, float angle) {
0., 0., 0., 1.); 0., 0., 0., 1.);
} }
mat4 rotation(vec3 rot) {
return rotate(vec3(0, 1, 0), rot.y) * rotate(vec3(0, 0, 1), rot.z) * rotate(vec3(1, 0, 0), rot.x);
}
mat4 kineticRotation() { mat4 kineticRotation() {
const float speed = 20;
float degrees = rotationOffset + time * speed * -3./10.; float degrees = rotationOffset + time * speed * -3./10.;
float angle = fract(degrees / 360.) * PI * 2.; float angle = fract(degrees / 360.) * PI * 2.;
@ -55,13 +61,17 @@ float diffuse(vec3 normal) {
} }
void main() { void main() {
vec3 rot = fract(localRotation / 360.) * PI * 2.;
mat4 localRot = rotation(rot);
vec4 localPos = localRot * vec4(aPos - 0.5, 1f) + vec4(0.5, 0.5, 0.5, 0);
mat4 kineticRotation = kineticRotation(); mat4 kineticRotation = kineticRotation();
vec4 localPos = kineticRotation * vec4(aPos - 0.5, 1f) + vec4(instancePos + 0.5, 0); localPos = kineticRotation * vec4(localPos.xyz - rotationCenter, 1) + vec4(instancePos + rotationCenter, 0);
vec4 worldPos = model * localPos; vec4 worldPos = model * localPos;
BoxCoord = (worldPos.xyz - lightBoxMin) / lightBoxSize; BoxCoord = (worldPos.xyz - lightBoxMin) / lightBoxSize;
Diffuse = diffuse(normalize(model * kineticRotation * vec4(aNormal, 0.)).xyz); Diffuse = diffuse(normalize(model * localRot * kineticRotation * vec4(aNormal, 0.)).xyz);
Color = vec4(1.); Color = vec4(1.);
TexCoords = aTexCoords; TexCoords = aTexCoords;
gl_Position = projection * view * worldPos; gl_Position = projection * view * worldPos;