From 602e662503c01eabf8054a587f0d650a73716385 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Fri, 12 Jul 2024 00:54:54 +0530 Subject: [PATCH] holy shit finally nuke shadows out of the engine --- src/Debug.hx | 2 ++ src/DifBuilder.hx | 6 +++--- src/DtsObject.hx | 2 +- src/Renderer.hx | 15 +++++++++++++-- src/collision/BoxCollisionEntity.hx | 3 +++ src/collision/CollisionEntity.hx | 4 ++++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Debug.hx b/src/Debug.hx index 8d5f254e..1a29b5fd 100644 --- a/src/Debug.hx +++ b/src/Debug.hx @@ -27,6 +27,8 @@ class Debug { debugTriangles.remove(); } debugTriangles = new h3d.scene.Mesh(prim, h3d.mat.Material.create()); + debugTriangles.material.receiveShadows = false; + debugTriangles.material.castShadows = false; prim.addUVs(); prim.addNormals(); MarbleGame.instance.scene.addChild(debugTriangles); diff --git a/src/DifBuilder.hx b/src/DifBuilder.hx index 75753e8b..3f14041f 100644 --- a/src/DifBuilder.hx +++ b/src/DifBuilder.hx @@ -832,20 +832,20 @@ class DifBuilder { thisprops.light = false; // We will calculate our own lighting material.props = thisprops; material.shadows = false; - material.receiveShadows = true; + material.receiveShadows = false; fwd(); }); }); prim.addTangents(); } else { material.shadows = false; - material.receiveShadows = true; + material.receiveShadows = false; } } else { Console.warn('Unable to load ${grp} texture for dif ${path}'); material = Material.create(); material.shadows = false; - material.receiveShadows = true; + material.receiveShadows = false; } // material.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1)); if (Debug.wireFrame) diff --git a/src/DtsObject.hx b/src/DtsObject.hx index f4813133..69d411db 100644 --- a/src/DtsObject.hx +++ b/src/DtsObject.hx @@ -425,7 +425,7 @@ class DtsObject extends GameObject { } material.shadows = false; if (this.isCollideable) - material.receiveShadows = true; + material.receiveShadows = false; if (material.texture == null && !iflMaterial) { var dtsshader = new DtsTexture(); dtsshader.currentOpacity = 1; diff --git a/src/Renderer.hx b/src/Renderer.hx index 53c2d139..4d86c2c5 100644 --- a/src/Renderer.hx +++ b/src/Renderer.hx @@ -1,5 +1,6 @@ package src; +import h3d.Vector; import src.Console; class Renderer extends h3d.scene.Renderer { @@ -29,8 +30,18 @@ class Renderer extends h3d.scene.Renderer { } override function render() { - if (has("shadow")) - renderPass(shadow, get("shadow")); + // if (has("shadow")) + // renderPass(shadow, get("shadow")); + + // The shadow bullshit + ctx.setGlobalID(@:privateAccess shadow.shadowMapId, { + texture: @:privateAccess shadow.dshader.shadowMap, + channel: @:privateAccess shadow.format == h3d.mat.Texture.nativeFormat ? hxsl.Channel.PackedFloat : hxsl.Channel.R + }); + ctx.setGlobalID(@:privateAccess shadow.shadowProjId, @:privateAccess shadow.getShadowProj()); + ctx.setGlobalID(@:privateAccess shadow.shadowColorId, new Vector(0, 0, 0, 0)); + ctx.setGlobalID(@:privateAccess shadow.shadowPowerId, 0.0); + ctx.setGlobalID(@:privateAccess shadow.shadowBiasId, 0.0); renderPass(defaultPass, get("skyshape")); renderPass(defaultPass, get("default")); diff --git a/src/collision/BoxCollisionEntity.hx b/src/collision/BoxCollisionEntity.hx index 0116f695..f017034d 100644 --- a/src/collision/BoxCollisionEntity.hx +++ b/src/collision/BoxCollisionEntity.hx @@ -27,10 +27,12 @@ class BoxCollisionEntity extends CollisionEntity implements IBVHObject { if (Debug.drawBounds) { if (_dbgEntity == null) { _dbgEntity = cast this.boundingBox.makeDebugObj(); + _dbgEntity.getMaterials()[0].castShadows = false; _dbgEntity.getMaterials()[0].mainPass.wireframe = true; MarbleGame.instance.scene.addChild(_dbgEntity); } else { _dbgEntity = cast this.boundingBox.makeDebugObj(); + _dbgEntity.getMaterials()[0].castShadows = false; _dbgEntity.getMaterials()[0].mainPass.wireframe = true; MarbleGame.instance.scene.addChild(_dbgEntity); } @@ -42,6 +44,7 @@ class BoxCollisionEntity extends CollisionEntity implements IBVHObject { if (Debug.drawBounds) { if (_dbgEntity != null) { _dbgEntity = cast this.boundingBox.makeDebugObj(); + _dbgEntity.getMaterials()[0].castShadows = false; _dbgEntity.getMaterials()[0].mainPass.wireframe = true; MarbleGame.instance.scene.addChild(_dbgEntity); } diff --git a/src/collision/CollisionEntity.hx b/src/collision/CollisionEntity.hx index 496b40d8..9c6ce29a 100644 --- a/src/collision/CollisionEntity.hx +++ b/src/collision/CollisionEntity.hx @@ -114,11 +114,13 @@ class CollisionEntity implements IOctreeObject implements IBVHObject { if (Debug.drawBounds) { if (_dbgEntity == null) { _dbgEntity = cast this.boundingBox.makeDebugObj(); + _dbgEntity.getMaterials()[0].castShadows = false; _dbgEntity.getMaterials()[0].mainPass.wireframe = true; MarbleGame.instance.scene.addChild(_dbgEntity); } else { _dbgEntity.remove(); _dbgEntity = cast this.boundingBox.makeDebugObj(); + _dbgEntity.getMaterials()[0].castShadows = false; _dbgEntity.getMaterials()[0].mainPass.wireframe = true; MarbleGame.instance.scene.addChild(_dbgEntity); } @@ -143,11 +145,13 @@ class CollisionEntity implements IOctreeObject implements IBVHObject { if (Debug.drawBounds) { if (_dbgEntity == null) { _dbgEntity = cast this.boundingBox.makeDebugObj(); + _dbgEntity.getMaterials()[0].castShadows = false; _dbgEntity.getMaterials()[0].mainPass.wireframe = true; MarbleGame.instance.scene.addChild(_dbgEntity); } else { _dbgEntity.remove(); _dbgEntity = cast this.boundingBox.makeDebugObj(); + _dbgEntity.getMaterials()[0].castShadows = false; _dbgEntity.getMaterials()[0].mainPass.wireframe = true; MarbleGame.instance.scene.addChild(_dbgEntity); }