forked from IrisShaders/Iris
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/net/coderbot/iris/mixin/compat/pixelmon/MixinNormalizedFace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package net.coderbot.iris.mixin.compat.pixelmon; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.mojang.math.Matrix3f; | ||
import com.mojang.math.Matrix4f; | ||
import com.pixelmonmod.pixelmon.client.models.smd.DeformVertex; | ||
import com.pixelmonmod.pixelmon.client.models.smd.NormalizedFace; | ||
import com.pixelmonmod.pixelmon.client.models.smd.TextureCoordinate; | ||
import com.pixelmonmod.pixelmon.client.models.smd.Vertex; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(NormalizedFace.class) | ||
public class MixinNormalizedFace { | ||
|
||
@Shadow | ||
public DeformVertex[] vertices; | ||
|
||
@Shadow | ||
public TextureCoordinate[] textureCoordinates; | ||
|
||
@Shadow | ||
public Vertex faceNormal; | ||
|
||
@Shadow | ||
public Vertex calculateFaceNormal() { | ||
return null; | ||
} | ||
|
||
@Overwrite | ||
public void addFaceForRender(PoseStack matrixStack, VertexConsumer bufferBuilder, int packedLight, int packedOverlay, boolean smoothShading, float partialTick, float r, float g, float b, float a) { | ||
if (!smoothShading && | ||
this.faceNormal == null) | ||
this.faceNormal = calculateFaceNormal(); | ||
for (int i = 0; i < 3; i++) { | ||
Matrix4f pose = matrixStack.last().pose(); | ||
Matrix3f normal = matrixStack.last().normal(); | ||
bufferBuilder.vertex(pose.m00 * this.vertices[i] | ||
.getX(partialTick) + pose.m01 * this.vertices[i].getY(partialTick) + pose.m02 * this.vertices[i].getZ(partialTick) + pose.m03, pose.m10 * this.vertices[i] | ||
.getX(partialTick) + pose.m11 * this.vertices[i].getY(partialTick) + pose.m12 * this.vertices[i].getZ(partialTick) + pose.m13, pose.m20 * this.vertices[i] | ||
.getX(partialTick) + pose.m21 * this.vertices[i].getY(partialTick) + pose.m22 * this.vertices[i].getZ(partialTick) + pose.m23, r, g, b, a, (this.textureCoordinates[i]).u, (this.textureCoordinates[i]).v, packedOverlay, packedLight, normal.m00 * this.vertices[i] | ||
|
||
.getXN(partialTick) + normal.m01 * this.vertices[i].getYN(partialTick) + normal.m02 * this.vertices[i].getZN(partialTick), normal.m10 * this.vertices[i] | ||
.getXN(partialTick) + normal.m11 * this.vertices[i].getYN(partialTick) + normal.m12 * this.vertices[i].getZN(partialTick), normal.m20 * this.vertices[i] | ||
.getXN(partialTick) + normal.m21 * this.vertices[i].getYN(partialTick) + normal.m22 * this.vertices[i].getZN(partialTick)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters