shadow fix
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
b37f80c18d
commit
bfbdf5cf3e
@ -1,3 +1,3 @@
|
||||
#maven.buildNumber.plugin properties file
|
||||
#Sat Jul 20 11:59:30 EDT 2024
|
||||
buildNumber=186
|
||||
#Mon Jul 29 21:49:03 EDT 2024
|
||||
buildNumber=188
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
+ bug fixes
|
||||
fix bug where synchronization packet for non-existant entity crashes engine
|
||||
fix rendering pipelines (black when looking at character from angle with item, shadows are not darker color, etc)
|
||||
fix items falling through floor
|
||||
fix jump tree not applying force while movement tree is active
|
||||
|
||||
|
||||
@ -482,6 +482,8 @@ Option to load all cells on init scene file
|
||||
Insidious Entity protocol bugfix on server
|
||||
Refactor network protocols to enforce async/sync split
|
||||
|
||||
(07/30/2024)
|
||||
Fix depth texture for shadow rendering
|
||||
|
||||
# TODO
|
||||
|
||||
|
||||
@ -227,7 +227,6 @@ public class Globals {
|
||||
public static Matrix4f lightDepthMatrix = new Matrix4f();
|
||||
|
||||
//locations for shadow map specific variables
|
||||
public static int shadowMapTextureLoc = 0;
|
||||
public static int depthMapShaderProgramLoc = 0;
|
||||
|
||||
|
||||
|
||||
@ -126,6 +126,8 @@ public class RenderingEngine {
|
||||
private static String glslVersion = null;
|
||||
|
||||
|
||||
//shadow stuff
|
||||
public static Texture lightBufferDepthTexture;
|
||||
|
||||
|
||||
|
||||
@ -342,7 +344,7 @@ public class RenderingEngine {
|
||||
lightDepthShaderProgram = ShaderProgram.loadSpecificShader("/Shaders/lightDepth/lightDepth.vs", "/Shaders/lightDepth/lightDepth.fs");
|
||||
Globals.depthMapShaderProgramLoc = lightDepthShaderProgram.getShaderId();
|
||||
lightDepthBuffer = FramebufferUtils.generateDepthBuffer(openGLState);
|
||||
Globals.shadowMapTextureLoc = lightDepthBuffer.getTexturePointer();
|
||||
lightBufferDepthTexture = lightDepthBuffer.getDepthTexture();
|
||||
// glEnable(GL_CULL_FACE); // enabled for shadow mapping
|
||||
|
||||
//
|
||||
|
||||
@ -27,12 +27,14 @@ public class Framebuffer {
|
||||
|
||||
//the pointer to the framebuffer
|
||||
int framebufferPointer;
|
||||
//gets the texture pointer to the framebuffer's content
|
||||
int texturePointer;
|
||||
//the mipmap level
|
||||
int mipMap = -1;
|
||||
//the map of attachment point to texture object
|
||||
Map<Integer,Texture> attachTextureMap = new HashMap<Integer,Texture>();
|
||||
//attached texture
|
||||
Texture texture;
|
||||
//the depth texture for the framebuffer
|
||||
Texture depthTexture;
|
||||
|
||||
/**
|
||||
* Creates a framebuffer
|
||||
@ -54,27 +56,28 @@ public class Framebuffer {
|
||||
* @param texture The texture attached to the framebuffer
|
||||
*/
|
||||
public void setTexture(Texture texture){
|
||||
setTexture(texture.getTexturePointer());
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the texture attached to the framebuffer
|
||||
* @param texturePointer The texture attached to the framebuffer
|
||||
* Gets the texture attached to this framebuffer
|
||||
* @return The texture
|
||||
*/
|
||||
public void setTexture(int texturePointer){
|
||||
this.texturePointer = texturePointer;
|
||||
public Texture getTexture(){
|
||||
return texture;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the texture associated with the framebuffer
|
||||
* @return The texture's pointer
|
||||
* Gets the depth texture attached to this framebuffer
|
||||
* @return The depth texture
|
||||
*/
|
||||
public int getTexturePointer(){
|
||||
return texturePointer;
|
||||
public Texture getDepthTexture(){
|
||||
return depthTexture;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds the framebuffer
|
||||
* @param openGLState The opengl state
|
||||
*/
|
||||
public void bind(OpenGLState openGLState){
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
|
||||
@ -176,31 +179,10 @@ public class Framebuffer {
|
||||
this.mipMap = mipMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color attachment
|
||||
* @param texturePointer The color attachment's pointer
|
||||
*/
|
||||
public void attachTexture(OpenGLState openGLState, int texturePointer){
|
||||
attachTexture(openGLState,texturePointer,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color attachment
|
||||
* @param texturePointer The color attachment's pointer
|
||||
* @param attachmentNum The number of the color attachment
|
||||
*/
|
||||
public void attachTexture(OpenGLState openGLState, int texturePointer, int attachmentNum){
|
||||
if(this.mipMap < 0){
|
||||
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to attach a texture to a framebuffer where mipmap hasn't been set."));
|
||||
}
|
||||
this.texturePointer = texturePointer;
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachmentNum, GL_TEXTURE_2D, this.texturePointer, this.mipMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches a color texture to the default texture unit
|
||||
* @param texture
|
||||
* @param openGLState The opengl state
|
||||
* @param texture The texture
|
||||
*/
|
||||
public void attachTexture(OpenGLState openGLState, Texture texture){
|
||||
attachTexture(openGLState, texture, 0);
|
||||
@ -208,21 +190,29 @@ public class Framebuffer {
|
||||
|
||||
/**
|
||||
* Attaches a texture to the framebuffer
|
||||
* @param openGLState The opengl state
|
||||
* @param texture The texture
|
||||
* @param attachmentNum The texture unit to attach to
|
||||
*/
|
||||
public void attachTexture(OpenGLState openGLState, Texture texture, int attachmentNum){
|
||||
this.attachTextureMap.put(attachmentNum,texture);
|
||||
attachTexture(openGLState, texture.getTexturePointer(), attachmentNum);
|
||||
if(this.mipMap < 0){
|
||||
LoggerInterface.loggerRenderer.ERROR(new IllegalStateException("Trying to attach a texture to a framebuffer where mipmap hasn't been set."));
|
||||
}
|
||||
this.texture = texture;
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachmentNum, GL_TEXTURE_2D, texture.getTexturePointer(), this.mipMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the depth attachment for the framebuffer
|
||||
* @param openGLState The opengl state
|
||||
* @param texturePointer The depth attachment's pointer
|
||||
*/
|
||||
public void setDepthAttachment(OpenGLState openGLState, int texturePointer){
|
||||
public void setDepthAttachment(OpenGLState openGLState, Texture depthTexture){
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, framebufferPointer);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texturePointer, this.mipMap);
|
||||
this.depthTexture = depthTexture;
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture.getTexturePointer(), this.mipMap);
|
||||
openGLState.glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
checkStatus();
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class FramebufferUtils {
|
||||
//bind texture to fbo
|
||||
buffer.setMipMapLevel(0);
|
||||
buffer.attachTexture(openGLState,colorTexture);
|
||||
buffer.setDepthAttachment(openGLState,depthTexture.getTexturePointer());
|
||||
buffer.setDepthAttachment(openGLState,depthTexture);
|
||||
//check make sure compiled
|
||||
buffer.checkStatus();
|
||||
return buffer;
|
||||
@ -110,7 +110,7 @@ public class FramebufferUtils {
|
||||
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
//bind texture to fbo
|
||||
buffer.setMipMapLevel(0);
|
||||
buffer.attachTexture(openGLState,colorTexture.getTexturePointer());
|
||||
buffer.attachTexture(openGLState,colorTexture);
|
||||
//check make sure compiled
|
||||
buffer.checkStatus();
|
||||
return buffer;
|
||||
@ -201,7 +201,7 @@ public class FramebufferUtils {
|
||||
|
||||
//bind texture to fbo
|
||||
buffer.setMipMapLevel(0);
|
||||
buffer.setDepthAttachment(openGLState,texture.getTexturePointer());
|
||||
buffer.setDepthAttachment(openGLState,texture);
|
||||
glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
|
||||
@ -232,7 +232,7 @@ public class FramebufferUtils {
|
||||
|
||||
//bind texture to fbo
|
||||
buffer.setMipMapLevel(0);
|
||||
buffer.setDepthAttachment(openGLState,texture.getTexturePointer());
|
||||
buffer.setDepthAttachment(openGLState,texture);
|
||||
glNamedFramebufferDrawBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
glNamedFramebufferReadBuffer(buffer.getFramebufferPointer(), GL_NONE);
|
||||
|
||||
@ -268,9 +268,9 @@ public class FramebufferUtils {
|
||||
|
||||
//bind texture to fbo
|
||||
buffer.setMipMapLevel(0);
|
||||
buffer.attachTexture(openGLState,accumulatorTex.getTexturePointer(),0);
|
||||
buffer.attachTexture(openGLState,revealageTex.getTexturePointer(),1);
|
||||
buffer.setDepthAttachment(openGLState,depthTexture.getTexturePointer());
|
||||
buffer.attachTexture(openGLState,accumulatorTex,0);
|
||||
buffer.attachTexture(openGLState,revealageTex,1);
|
||||
buffer.setDepthAttachment(openGLState,depthTexture);
|
||||
|
||||
// const GLenum transparentDrawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
|
||||
// glDrawBuffers(2, transparentDrawBuffers);
|
||||
|
||||
@ -4,6 +4,7 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.renderer.OpenGLState;
|
||||
import electrosphere.renderer.RenderPipelineState;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
import electrosphere.renderer.actor.ActorTextureMask;
|
||||
import electrosphere.renderer.actor.instance.InstanceData;
|
||||
import electrosphere.renderer.buffer.HomogenousInstancedArray;
|
||||
@ -420,7 +421,7 @@ public class Mesh {
|
||||
|
||||
if(renderPipelineState.getUseShadowMap()){
|
||||
openGLState.glActiveTexture(GL_TEXTURE3);
|
||||
openGLState.glBindTexture(GL_TEXTURE_2D, Globals.shadowMapTextureLoc);
|
||||
openGLState.glBindTexture(GL_TEXTURE_2D, RenderingEngine.lightBufferDepthTexture.getTexturePointer());
|
||||
glUniform1i(glGetUniformLocation(openGLState.getActiveShader().getShaderId(), "shadowMap"), 3);
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
|
||||
@ -205,6 +205,12 @@ public class MainContentPipeline implements RenderPipeline {
|
||||
//
|
||||
renderPipelineState.setSelectedShader(SelectedShaderEnum.PRIMARY);
|
||||
|
||||
|
||||
//
|
||||
// Reset State
|
||||
//
|
||||
RenderingEngine.defaultFramebuffer.bind(openGLState);
|
||||
|
||||
|
||||
|
||||
// glBindVertexArray(0);
|
||||
|
||||
@ -44,10 +44,10 @@ public class RenderScreenPipeline implements RenderPipeline {
|
||||
//aaa
|
||||
switch(RenderingEngine.outputFramebuffer){
|
||||
case 0:
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.screenFramebuffer.getTexturePointer());
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.screenFramebuffer.getTexture().getTexturePointer());
|
||||
break;
|
||||
case 1:
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.lightDepthBuffer.getTexturePointer());
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.lightDepthBuffer.getTexture().getTexturePointer());
|
||||
break;
|
||||
case 2:
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.volumeDepthBackfaceTexture.getTexturePointer());
|
||||
|
||||
@ -59,7 +59,7 @@ public class ActorPanel extends StandardElement implements DrawableElement, Drag
|
||||
public ActorPanel(OpenGLState openGLState, int x, int y, int width, int height, Actor actor){
|
||||
super();
|
||||
elementBuffer = FramebufferUtils.generateTextureFramebuffer(openGLState, width, height);
|
||||
customMat.setTexturePointer(elementBuffer.getTexturePointer());
|
||||
customMat.setTexturePointer(elementBuffer.getTexture().getTexturePointer());
|
||||
this.actor = actor;
|
||||
this.internalPositionX = x;
|
||||
this.internalPositionY = y;
|
||||
|
||||
@ -39,7 +39,7 @@ public class ScrollableContainer extends StandardContainerElement implements Dra
|
||||
super();
|
||||
widgetBuffer = FramebufferUtils.generateTextureFramebuffer(openGLState, width, height);
|
||||
// widgetBuffer = FramebufferUtils.generateScreensizeTextureFramebuffer();
|
||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||
customMat.setTexturePointer(widgetBuffer.getTexture().getTexturePointer());
|
||||
// customMat.setTexturePointer(Globals.assetManager.fetchTexture("Textures/Testing1.png").getTexturePointer());
|
||||
float ndcX = (float)positionX/Globals.WINDOW_WIDTH;
|
||||
float ndcY = (float)positionY/Globals.WINDOW_HEIGHT;
|
||||
@ -186,7 +186,7 @@ public class ScrollableContainer extends StandardContainerElement implements Dra
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||
customMat.setTexturePointer(widgetBuffer.getTexture().getTexturePointer());
|
||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||
planeModel.drawUI();
|
||||
} else {
|
||||
|
||||
@ -71,7 +71,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
*/
|
||||
public Window(OpenGLState openGLState, int positionX, int positionY, int width, int height, boolean showDecorations){
|
||||
widgetBuffer = FramebufferUtils.generateTextureFramebuffer(openGLState, width, height);
|
||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||
customMat.setTexturePointer(widgetBuffer.getTexture().getTexturePointer());
|
||||
float ndcWidth = (float)width/Globals.WINDOW_WIDTH;
|
||||
float ndcHeight = (float)height/Globals.WINDOW_HEIGHT;
|
||||
float ndcX = (float)positionX/Globals.WINDOW_WIDTH;
|
||||
@ -155,7 +155,7 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||
planeModel.pushUniformToMesh(planeModel.getMeshes().get(0).getMeshName(), "color", color);
|
||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||
customMat.setTexturePointer(widgetBuffer.getTexture().getTexturePointer());
|
||||
planeModel.getMeshes().get(0).setMaterial(customMat);
|
||||
planeModel.drawUI();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user