Browse Source

working at lights in mc dungeons

meemknight 2 years ago
parent
commit
1ed9f501e2

+ 4 - 0
Pika/core/pikaSTD/engineLibraresSupport/engineGL3DSupport.cpp

@@ -257,6 +257,10 @@ void pika::gl3d::lightEditorSettingsWindow(int imguiId, ::gl3d::Renderer3D &rend
 		ImGui::DragInt("Directional light shadow texture size", &lightSize);
 		renderer.setDirectionalLightShadowSize(lightSize);
 
+		ImGui::DragFloat3("cascades", renderer.directionalShadows.frustumSplits, 0.01, 0, 1);
+
+
+
 		if (directionalLightSelector < -1)
 		{
 			directionalLightSelector = -1;

BIN
Pika/engineResources/engineSaves/windowPos1.bin


BIN
Pika/engineResources/engineSaves/windowPos2.bin


+ 24 - 6
Pika/gameplay/containers/minecraftDungeons/mcDungeonsEditor.h

@@ -41,8 +41,8 @@ struct McDungeonsEditor: public Container
 	pika::gl3d::General3DEditor editor;
 	pika::pikaImgui::FileSelector loadedLevel;
 
-	glm::vec3 worldSize = {300,20,300};
-	unsigned char worldData[300][20][300] = {};
+	glm::vec3 worldSize = {150,30,150};
+	unsigned char worldData[150][30][150] = {};
 
 	unsigned char &getBlockUnsafe(int x, int y, int z)
 	{
@@ -438,6 +438,11 @@ struct McDungeonsEditor: public Container
 		//t.rotation = {1.5, 0 , 0};
 		entity = renderer.createEntity(model, t);
 
+		renderer.camera.farPlane = 200;
+		renderer.directionalShadows.frustumSplits[0] = 0.06;
+		renderer.directionalShadows.frustumSplits[1] = 0.110;
+		renderer.directionalShadows.frustumSplits[2] = 0.200;
+
 		
 		return true;
 	}
@@ -514,13 +519,25 @@ struct McDungeonsEditor: public Container
 
 			ImGui::DragFloat3("camera pos", &renderer.camera.position[0]);
 
+			ImGui::NewLine();
+
+			{
+				auto uv1 = getAtlasFront(currentBlock);
+				glm::vec4 uv{
+					0.f / 16.f + uv1.x / 16.f,
+					1.f / 16.f + uv1.y / 16.f,
+					1.f / 16.f + uv1.x / 16.f,
+					0.f / 16.f + uv1.y / 16.f
+				};
+				ImGui::Image((void *)(intptr_t)blocksTexture,
+					{35,35}, {uv.x, uv.y}, {uv.z, uv.w});
+			}
+
 			ImGui::NewLine();
 			{
-				unsigned short localCount = 0;
 				for(int mCount =0; mCount <BlockTypes::BlocksCount; mCount++)
 				{
 					auto uv1 = getAtlasFront(mCount);
-
 					glm::vec4 uv{
 						0.f / 16.f + uv1.x / 16.f,
 						1.f / 16.f + uv1.y / 16.f,
@@ -528,6 +545,8 @@ struct McDungeonsEditor: public Container
 						0.f / 16.f + uv1.y / 16.f
 					};
 
+				
+
 					ImGui::PushID(mCount);
 					if (ImGui::ImageButton((void *)(intptr_t)blocksTexture,
 						{35,35}, {uv.x, uv.y}, {uv.z, uv.w}))
@@ -537,11 +556,10 @@ struct McDungeonsEditor: public Container
 
 					ImGui::PopID();
 
-					if (localCount % 5 != 0)
+					if ((mCount+1) % 5 != 0)
 					{
 						ImGui::SameLine();
 					}
-					localCount++;
 
 				}
 			}

+ 4 - 4
Pika/resources/logs.txt

@@ -1,4 +1,4 @@
-#2023-02-26 12:37:37: Created container: Gameplay
-#2023-02-26 12:37:46: Created container: MarioEditor
-#2023-02-26 12:37:54: Destroyed continer: Gameplay #1
-#2023-02-26 12:38:34: Destroyed continer: MarioEditor #2
+#2023-02-26 13:20:48: Created container: Gameplay
+#2023-02-26 13:21:44: Created container: McDungeonsEditor
+#2023-02-26 13:23:54: Destroyed continer: Gameplay #1
+#2023-02-26 13:23:54: Destroyed continer: McDungeonsEditor #2

+ 5 - 1
Pika/thirdparty/gl3d/gl3d.cpp

@@ -40527,7 +40527,11 @@ namespace gl3d
 							glm::vec3 lightDir = internal.directionalLights[lightIndex].direction;
 							//glm::mat4 lightView = lookAtSafe(-lightDir, {}, { 0.f,1.f,0.f });
 
-							glm::mat4 lightView = lookAtSafe(camera.position - (lightDir), camera.position, { 0.f,1.f,0.f });
+							glm::vec3 direction = lightDir;
+							glm::vec3 eye = camera.position - (direction);
+							glm::vec3 center = eye + direction;
+
+							glm::mat4 lightView = lookAtSafe(eye, center, { 0.f,1.f,0.f });
 							//glm::mat4 lightView = lookAtSafe(camera.position, camera.position + lightDir, { 0.f,1.f,0.f });
 
 							//zoffset is used to move the light further