Skip to content

Commit

Permalink
Port pseudo3d branch into current implementation and refactor RayHand…
Browse files Browse the repository at this point in the history
…ler configuration (#124)

* Update libGDX to 1.9.11

* Merge kdenzel's pseudo3d with proper formatting code

* Fix deprecated

* Port Positional and Point Light from pseudo3d

* Better shadow color

* Try to support pseudo3d cone light

* Add pseudo3d test

* Organize `dynamicShadowRender`

* Render pseudo3d shadows on their own FBO

* Improve shadow color

* Improve shadow color

* Fix DirectionalLight

* Fix shader compilation

* Allow setting diffuse and gamma correction at runtime

* Deprecate static setters and public modifiers (BREAKING isDiffuse) in favor of `RayHandlerOptions`

* Check shape position for all shape types

* Clean up

* Fix compatibility with OpenGL 3+
  • Loading branch information
fgnm authored Jan 2, 2024
1 parent 69963ac commit f7de0fd
Show file tree
Hide file tree
Showing 19 changed files with 1,566 additions and 127 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.project
.settings/
.idea/
.gradle/
build/
libs/
target/
*.class
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sourceSets {
}
}

ext.gdxVersion = "1.9.10"
ext.gdxVersion = "1.9.11"
version = "1.6-SNAPSHOT"

repositories {
Expand Down
12 changes: 9 additions & 3 deletions src/box2dLight/ChainLight.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package box2dLight;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
Expand Down Expand Up @@ -115,14 +116,19 @@ public ChainLight(RayHandler rayHandler, int rays, Color color,
startY = new float[rays];
this.chain = (chain != null) ?
new FloatArray(chain) : new FloatArray();


Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray;
if (Gdx.gl30 != null) {
vertexDataType = VertexDataType.VertexBufferObjectWithVAO;
}

lightMesh = new Mesh(
VertexDataType.VertexArray, false, vertexNum, 0,
vertexDataType, false, vertexNum, 0,
new VertexAttribute(Usage.Position, 2, "vertex_positions"),
new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
softShadowMesh = new Mesh(
VertexDataType.VertexArray, false, vertexNum * 2,
vertexDataType, false, vertexNum * 2,
0, new VertexAttribute(Usage.Position, 2, "vertex_positions"),
new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"),
new VertexAttribute(Usage.Generic, 1, "s"));
Expand Down
5 changes: 5 additions & 0 deletions src/box2dLight/ConeLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public ConeLight(RayHandler rayHandler, int rays, Color color,

@Override
public void update () {
if (rayHandler.pseudo3d) {
prepareFixtureData();
updateDynamicShadowMeshes();
}

updateBody();
if (dirty) setEndPoints();

Expand Down
Loading

0 comments on commit f7de0fd

Please sign in to comment.