parent
395144e6ee
commit
63033b5504
|
@ -56,7 +56,7 @@ public class Example {
|
|||
TexturedModel tModel = ModelLoader.loadModel("stall.obj", "stallTexture.png");
|
||||
tModel.getTexture().setReflectivity(1f);
|
||||
tModel.getTexture().setShineDamper(7f);
|
||||
Player entity = new Player(tModel, new Vector3f(0,0,-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f));
|
||||
Player entity = new Player(tModel, new Vector3f(0,0,-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f), 5000);
|
||||
ThirdPersonCamera camera = new ThirdPersonCamera(new Vector3f(0,0.1f,0), entity);
|
||||
masterRenderer = new MasterRenderer(camera);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ public class Player extends Entity{
|
|||
|
||||
private static float terrainHeight = 0;
|
||||
|
||||
private double timeModifier = 1;
|
||||
|
||||
private float currentSpeed = 0;
|
||||
private float currentTurn = 0;
|
||||
|
@ -23,21 +24,21 @@ public class Player extends Entity{
|
|||
|
||||
private boolean isInAir = false;
|
||||
|
||||
public Player(TexturedModel model, Vector3f position, float rotX, float rotY, float rotZ, Vector3f scale) {
|
||||
public Player(TexturedModel model, Vector3f position, float rotX, float rotY, float rotZ, Vector3f scale, double timeScale) {
|
||||
super(model, position, rotX, rotY, rotZ, scale);
|
||||
this.timeModifier = timeScale;
|
||||
}
|
||||
|
||||
public void move(Terrain t) {
|
||||
|
||||
checkInputs();
|
||||
super.increaseRotation(0, (float) ((currentTurn / 1000000) * Window.getTime()), 0);
|
||||
float distance = (currentSpeed / 1000000) * Window.getFloatTime();
|
||||
super.increaseRotation(0, (float) ((currentTurn) * Window.getTime() / timeModifier), 0);
|
||||
float distance = (float) ((currentSpeed) * (Window.getTime() / (timeModifier * 2.5)));
|
||||
float dx = (float) (distance * Math.sin(Math.toRadians(super.getRotY())));
|
||||
float dz = (float) (distance * Math.cos(Math.toRadians(super.getRotY())));
|
||||
super.increasePosition(dx, 0, dz);
|
||||
super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime() / 1000000)), 0);
|
||||
super.increasePosition(0, (float) (upwardsSpeed * (Window.getTime() / (timeModifier * 2))), 0);
|
||||
terrainHeight = t.getHeightOfTerrain(super.getPosition().x, super.getPosition().z);
|
||||
upwardsSpeed += GRAVITY * Window.getTime() / 1000000;
|
||||
upwardsSpeed += GRAVITY * Window.getTime() / (timeModifier * 2);
|
||||
if(super.getPosition().y < terrainHeight) {
|
||||
isInAir = false;
|
||||
upwardsSpeed = 0;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
|
@ -42,6 +43,8 @@ public class ShadowMapEntityRenderer {
|
|||
for (TexturedModel model : entities.keySet()) {
|
||||
RawModel rawModel = model.getRawModel();
|
||||
bindModel(rawModel);
|
||||
GL13.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID());
|
||||
for (Entity entity : entities.get(model)) {
|
||||
prepareInstance(entity);
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, rawModel.getVertexCount(),
|
||||
|
@ -49,6 +52,7 @@ public class ShadowMapEntityRenderer {
|
|||
}
|
||||
}
|
||||
GL20.glDisableVertexAttribArray(0);
|
||||
GL20.glDisableVertexAttribArray(1);
|
||||
GL30.glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
@ -63,6 +67,7 @@ public class ShadowMapEntityRenderer {
|
|||
private void bindModel(RawModel rawModel) {
|
||||
GL30.glBindVertexArray(rawModel.getVaoID());
|
||||
GL20.glEnableVertexAttribArray(0);
|
||||
GL20.glEnableVertexAttribArray(1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,7 @@ public class ShadowShader extends ShaderProgram {
|
|||
@Override
|
||||
protected void bindAttributes() {
|
||||
super.bindAttribute(0, "in_position");
|
||||
super.bindAttribute(1, "in_textureCoords");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#version 330
|
||||
#version 400
|
||||
|
||||
out vec4 out_colour;
|
||||
in vec2 textureCoords;
|
||||
|
||||
uniform sampler2D modelTexture;//will use this next week
|
||||
out vec4 out_Colour;
|
||||
|
||||
uniform sampler2D modelTexture;
|
||||
|
||||
void main(void){
|
||||
float alpha = texture(modelTexture, textureCoords).a;
|
||||
if(alpha < 0.5){
|
||||
discard;
|
||||
}
|
||||
|
||||
out_colour = vec4(1.0);
|
||||
|
||||
}
|
||||
out_Colour = vec4(1.0);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#version 150
|
||||
|
||||
in vec3 in_position;
|
||||
in vec2 in_textureCoords;
|
||||
|
||||
out vec2 textureCoords;
|
||||
|
||||
uniform mat4 mvpMatrix;
|
||||
|
||||
void main(void){
|
||||
|
||||
textureCoords = in_textureCoords;
|
||||
|
||||
gl_Position = mvpMatrix * vec4(in_position, 1.0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ void main(void){
|
|||
float objectNearestLight = texture(shadowMap, shadowCoords.xy).r;
|
||||
float lightFactor = 1.0;
|
||||
if(shadowCoords.z > objectNearestLight){
|
||||
lightFactor = 1.0 - 0.4;
|
||||
lightFactor = 1.0 - (shadowCoords.w * 0.4);
|
||||
}
|
||||
|
||||
vec4 blendMapColour = texture(blendMap, pass_textureCoords);
|
||||
|
|
|
@ -18,7 +18,9 @@ uniform vec3 lightPosition[5];
|
|||
uniform mat4 toShadowMapSpace;
|
||||
|
||||
const float density = 0.01;
|
||||
const float gradient = 1;
|
||||
const float gradient = 5;
|
||||
const float shadowDistance = 150.0;
|
||||
const float transitionDistance = 10.0;
|
||||
|
||||
void main(void){
|
||||
|
||||
|
@ -39,4 +41,9 @@ void main(void){
|
|||
float distance = length(positionRelativeToCam.xyz);
|
||||
visibility = exp(-pow((distance * density), gradient));
|
||||
visibility = clamp(visibility, 0.0, 1.0);
|
||||
|
||||
distance = distance - (shadowDistance - transitionDistance);
|
||||
distance = distance / transitionDistance;
|
||||
shadowCoords.w = clamp(1.0-distance, 0.0, 1.0);
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,11 +1,16 @@
|
|||
#version 330
|
||||
#version 400
|
||||
|
||||
out vec4 out_colour;
|
||||
in vec2 textureCoords;
|
||||
|
||||
uniform sampler2D modelTexture;//will use this next week
|
||||
out vec4 out_Colour;
|
||||
|
||||
uniform sampler2D modelTexture;
|
||||
|
||||
void main(void){
|
||||
float alpha = texture(modelTexture, textureCoords).a;
|
||||
if(alpha < 0.5){
|
||||
discard;
|
||||
}
|
||||
|
||||
out_colour = vec4(1.0);
|
||||
|
||||
}
|
||||
out_Colour = vec4(1.0);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#version 150
|
||||
|
||||
in vec3 in_position;
|
||||
in vec2 in_textureCoords;
|
||||
|
||||
out vec2 textureCoords;
|
||||
|
||||
uniform mat4 mvpMatrix;
|
||||
|
||||
void main(void){
|
||||
|
||||
textureCoords = in_textureCoords;
|
||||
|
||||
gl_Position = mvpMatrix * vec4(in_position, 1.0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ void main(void){
|
|||
float objectNearestLight = texture(shadowMap, shadowCoords.xy).r;
|
||||
float lightFactor = 1.0;
|
||||
if(shadowCoords.z > objectNearestLight){
|
||||
lightFactor = 1.0 - 0.4;
|
||||
lightFactor = 1.0 - (shadowCoords.w * 0.4);
|
||||
}
|
||||
|
||||
vec4 blendMapColour = texture(blendMap, pass_textureCoords);
|
||||
|
|
|
@ -18,7 +18,9 @@ uniform vec3 lightPosition[5];
|
|||
uniform mat4 toShadowMapSpace;
|
||||
|
||||
const float density = 0.01;
|
||||
const float gradient = 1;
|
||||
const float gradient = 5;
|
||||
const float shadowDistance = 150.0;
|
||||
const float transitionDistance = 10.0;
|
||||
|
||||
void main(void){
|
||||
|
||||
|
@ -39,4 +41,9 @@ void main(void){
|
|||
float distance = length(positionRelativeToCam.xyz);
|
||||
visibility = exp(-pow((distance * density), gradient));
|
||||
visibility = clamp(visibility, 0.0, 1.0);
|
||||
|
||||
distance = distance - (shadowDistance - transitionDistance);
|
||||
distance = distance / transitionDistance;
|
||||
shadowCoords.w = clamp(1.0-distance, 0.0, 1.0);
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
#Generated by Maven
|
||||
#Tue May 28 12:07:06 AEST 2019
|
||||
#Tue May 28 17:00:00 AEST 2019
|
||||
version=NIGHTLY
|
||||
groupId=me.hydos
|
||||
artifactId=ginger
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue