Skip to content

Commit

Permalink
adds viewHeight and viewWidth (IrisShaders#5)
Browse files Browse the repository at this point in the history
* add viewHeight and viewWidth

* whoops

* typos :|

* Update Uniforms.java
  • Loading branch information
ColdIce1605 authored Nov 4, 2020
1 parent b312e02 commit a56ad2d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/net/coderbot/iris/uniforms/Uniforms.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package net.coderbot.iris.uniforms;

import java.nio.FloatBuffer;

import net.coderbot.iris.texunits.TextureUnit;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL21;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.GlProgram;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.util.math.Vector4f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL21;

import java.nio.FloatBuffer;

public class Uniforms {
private int texture;
Expand All @@ -22,6 +21,9 @@ public class Uniforms {
private int gbufferProjection;
private int gbufferProjectionInverse;

private int viewHeight;
private int viewWidth;

private int cameraPosition;

private int shadowLightPosition;
Expand All @@ -37,6 +39,9 @@ public Uniforms(GlProgram program) {
gbufferProjection = GL21.glGetUniformLocation(programId, "gbufferProjection");
gbufferProjectionInverse = GL21.glGetUniformLocation(programId, "gbufferProjectionInverse");

viewHeight = GL21.glGetUniformLocation(programId, "viewHeight");
viewWidth = GL21.glGetUniformLocation(programId, "viewWidth");

cameraPosition = GL21.glGetUniformLocation(programId, "cameraPosition");

shadowLightPosition = GL21.glGetUniformLocation(programId, "shadowLightPosition");
Expand All @@ -52,6 +57,10 @@ public void update() {
updateMatrix(gbufferProjection, CapturedRenderingState.INSTANCE.getGbufferProjection());
updateMatrix(gbufferProjectionInverse, invertedCopy(CapturedRenderingState.INSTANCE.getGbufferProjection()));

GL21.glUniform1f(viewHeight, MinecraftClient.getInstance().getWindow().getHeight());
GL21.glUniform1f(viewWidth, MinecraftClient.getInstance().getWindow().getWidth());


updateVector(cameraPosition, MinecraftClient.getInstance().gameRenderer.getCamera().getPos());

// TODO: Simplify this
Expand Down

0 comments on commit a56ad2d

Please sign in to comment.