Skip to content

Commit

Permalink
fix particle lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Pannoniae committed Jul 22, 2024
1 parent db8a4b9 commit 06f6028
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions BlockGame.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACollectionsMarshal_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F6381eca44c5bf27e971899bd4745e3a717acc851947313c2a767a43e18c21357_003FCollectionsMarshal_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AColor4_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3cfec35914b54ad8b5a9e578d6e61749ad800_003Fd1_003F0cfe4c99_003FColor4_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AColor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F3cfec35914b54ad8b5a9e578d6e61749ad800_003F86_003Fcea27348_003FColor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AColor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F0ae181a25dcbad0d6ba7bc6ad41d3f4a6ee366953ff464a3d6e115b5587819_003FColor_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AColor_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F921a65827594f7315c1c62fd944c53ecbaaecf73f2b09199752e35371bac4ee9_003FColor_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AColor_002ENamedColors_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Ff7ea64774b1b90b64a1dbb7699259d105d26d5c979d6350536cb979286390_003FColor_002ENamedColors_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADictionary_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F1a7c247d4ea86c26ff612b299bf7d7ae4397e5fff3bbf7f4305d25ae5bd6fd_003FDictionary_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
Expand Down
1 change: 0 additions & 1 deletion src/GL/InstantDraw.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Runtime.InteropServices;
using Silk.NET.OpenGL;
using PrimitiveType = Silk.NET.OpenGL.PrimitiveType;

Expand Down
5 changes: 3 additions & 2 deletions src/render/ParticleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ public void render(double interp) {
InstantDraw.instantShader.setUniform(InstantDraw.uMVP, world.player.camera.getViewMatrix(interp) * world.player.camera.getProjectionMatrix());
// get interp pos
var pos = Vector3D.Lerp(particle.prevPosition, particle.position, (float)interp);
var blockPos = pos.toBlockPos();
var right = Vector3.Cross(world.player.camera.up, world.player.camera.forward);
var up = world.player.camera.up;
var ul = pos.toVec3() - right * (float)particle.size / 2 + up * (float)particle.size / 2;
var ll = pos.toVec3() - right * (float)particle.size / 2 - up * (float)particle.size / 2;
var lr = pos.toVec3() + right * (float)particle.size / 2 - up * (float)particle.size / 2;
var ur = pos.toVec3() + right * (float)particle.size / 2 + up * (float)particle.size / 2;
var skylight = world.getSkyLight((int)pos.X, (int)pos.Y, (int)pos.Z);
var blocklight = world.getBlockLight((int)pos.X, (int)pos.Y, (int)pos.Z);
var skylight = world.getSkyLight(blockPos.X, blockPos.Y, blockPos.Z);
var blocklight = world.getBlockLight(blockPos.X, blockPos.Y, blockPos.Z);
var tint = Game.textureManager.lightTexture.getPixel(blocklight, skylight);

var vert = new BlockVertexTinted(ul.X, ul.Y, ul.Z,
Expand Down
4 changes: 3 additions & 1 deletion src/util/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public static Vector3 toVec3(this Vector3D<double> vec) {
public static Vector3 toVec3(this Vector3D<float> vec) {
return new Vector3(vec.X, vec.Y, vec.Z);
}
public static Vector3 toVec3(this Vector3D<int> vec) {
return new Vector3(vec.X, vec.Y, vec.Z);
}
public static Vector3 toVec3(this Vector3F vec) {
return new Vector3(vec.X, vec.Y, vec.Z);
}
Expand Down Expand Up @@ -60,7 +63,6 @@ public static Matrix4F to4F(Matrix4x4 mat) {
return Unsafe.BitCast<Matrix4x4, Matrix4F>(mat);
}


public static Vector3D<int> toBlockPos(this Vector3D<double> currentPos) {
return new Vector3D<int>((int)Math.Floor(currentPos.X), (int)Math.Floor(currentPos.Y),
(int)Math.Floor(currentPos.Z));
Expand Down

0 comments on commit 06f6028

Please sign in to comment.