Force reload shaders debug option
This commit is contained in:
		
							parent
							
								
									2f0af2f096
								
							
						
					
					
						commit
						413f9c8b8c
					
				| @ -2,7 +2,7 @@ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| layout (triangles) in; | layout (triangles) in; | ||||||
| layout (triangle_strip, max_vertices = 150) out; | layout (triangle_strip, max_vertices = 200) out; | ||||||
| 
 | 
 | ||||||
| uniform mat4 model; | uniform mat4 model; | ||||||
| uniform mat4 view; | uniform mat4 view; | ||||||
| @ -14,18 +14,36 @@ void main() { | |||||||
| 
 | 
 | ||||||
|     vec4 triangle1Pos = gl_in[0].gl_Position; |     vec4 triangle1Pos = gl_in[0].gl_Position; | ||||||
| 
 | 
 | ||||||
|     for(float x = 0; x < 5; x++){ |     // | ||||||
|         for(float y = 0; y < 5; y++){ |     //Each new vertex is a new triangle using the previous two | ||||||
|             float xPos = x / 10.0; |     // | ||||||
|             float yPos = y / 10.0; | 
 | ||||||
|             origCoord = (triangle1Pos + vec4( 0.0 + xPos, 0.5, 0.0 + yPos, 0.0)).xyz; |     float bladeHeight = 0.2; | ||||||
|             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.0 + xPos, 0.0, 0.0 + yPos, 0.0));  | 
 | ||||||
|  |     for(float x = 0; x < 4; x++){ | ||||||
|  |         for(float y = 0; y < 4; y++){ | ||||||
|  |             float xPos = x / 20.0; | ||||||
|  |             float yPos = y / 20.0; | ||||||
|  |             origCoord = (triangle1Pos + vec4( 0.0 + xPos, 0.45, 0.0 + yPos, 0.0)).xyz; | ||||||
|  |             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.0 + xPos, 0.45, 0.0 + yPos, 0.0));  | ||||||
|             EmitVertex(); |             EmitVertex(); | ||||||
|             origCoord = (triangle1Pos + vec4( 0.1 + xPos, 0.5, 0.0 + yPos, 0.0)).xyz; |             origCoord = (triangle1Pos + vec4( 0.05 + xPos, 0.45, 0.0 + yPos, 0.0)).xyz; | ||||||
|             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.1 + xPos, 0.5, 0.0 + yPos, 0.0)); |             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.05 + xPos, 0.45, 0.0 + yPos, 0.0)); | ||||||
|             EmitVertex(); |             EmitVertex(); | ||||||
|             origCoord = (triangle1Pos + vec4( 0.05 + xPos, 1.0, 0.0 + yPos, 0.0)).xyz; |             origCoord = (triangle1Pos + vec4( 0.025 + xPos, 0.95, 0.025 + yPos, 0.0)).xyz; | ||||||
|             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.0 + xPos, 1.0, 0.0 + yPos, 0.0)); |             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.025 + xPos, 0.45 + bladeHeight, 0.025 + yPos, 0.0)); | ||||||
|  |             EmitVertex(); | ||||||
|  |             origCoord = (triangle1Pos + vec4( 0.05 + xPos, 0.45, 0.05 + yPos, 0.0)).xyz; | ||||||
|  |             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.05 + xPos, 0.45, 0.05 + yPos, 0.0)); | ||||||
|  |             EmitVertex(); | ||||||
|  |             origCoord = (triangle1Pos + vec4( 0.0 + xPos, 0.45, 0.05 + yPos, 0.0)).xyz; | ||||||
|  |             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.0 + xPos, 0.45, 0.05 + yPos, 0.0)); | ||||||
|  |             EmitVertex(); | ||||||
|  |             origCoord = (triangle1Pos + vec4( 0.025 + xPos, 0.95, 0.025 + yPos, 0.0)).xyz; | ||||||
|  |             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.025 + xPos, 0.45 + bladeHeight, 0.025 + yPos, 0.0)); | ||||||
|  |             EmitVertex(); | ||||||
|  |             origCoord = (triangle1Pos + vec4( 0.0 + xPos, 0.45, 0.0 + yPos, 0.0)).xyz; | ||||||
|  |             gl_Position = projection * view * model * (triangle1Pos + vec4( 0.0 + xPos, 0.45, 0.0 + yPos, 0.0));  | ||||||
|             EmitVertex(); |             EmitVertex(); | ||||||
|             EndPrimitive(); |             EndPrimitive(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -547,8 +547,8 @@ public class LoadingThread extends Thread { | |||||||
|         Skybox |         Skybox | ||||||
|          |          | ||||||
|         */ |         */ | ||||||
|         Model skyboxModel = Globals.assetManager.fetchModel(AssetDataStrings.ASSET_STRING_SKYBOX_BASIC); |         // Model skyboxModel = Globals.assetManager.fetchModel(AssetDataStrings.ASSET_STRING_SKYBOX_BASIC); | ||||||
|         Globals.skybox = EntityUtils.spawnDrawableEntity(AssetDataStrings.ASSET_STRING_SKYBOX_BASIC); |         // Globals.skybox = EntityUtils.spawnDrawableEntity(AssetDataStrings.ASSET_STRING_SKYBOX_BASIC); | ||||||
|          |          | ||||||
|          |          | ||||||
|         /* |         /* | ||||||
| @ -709,18 +709,22 @@ public class LoadingThread extends Thread { | |||||||
|         cube.putData(EntityDataStrings.DRAW_VOLUMETRIC, true); |         cube.putData(EntityDataStrings.DRAW_VOLUMETRIC, true); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|         // //queue grass shader |  | ||||||
|         // Globals.assetManager.addShaderToQueue("Shaders/grass1/grass1.vs", "Shaders/grass1/grass1.gs", "Shaders/grass1/grass1.fs"); |         // Globals.assetManager.addShaderToQueue("Shaders/grass1/grass1.vs", "Shaders/grass1/grass1.gs", "Shaders/grass1/grass1.fs"); | ||||||
|         // for(int x = 0; x < 10; x++){ |         // Entity grass = EntityUtils.spawnDrawableEntity("Models/grass1.fbx"); | ||||||
|         //     for(int y = 0; y < 10; y++){ |         // //shader mask | ||||||
|         //         Entity grass = EntityUtils.spawnDrawableEntity("Models/grass1.fbx"); |         // EntityUtils.getActor(grass).maskShader("Cube", "Shaders/grass1/grass1.vs", "Shaders/grass1/grass1.gs", "Shaders/grass1/grass1.fs"); | ||||||
|         //         //shader mask |         // EntityUtils.getPosition(grass).set(3,0,1); | ||||||
|         //         EntityUtils.getActor(grass).maskShader("Cube", "Shaders/grass1/grass1.vs", "Shaders/grass1/grass1.gs", "Shaders/grass1/grass1.fs"); | 
 | ||||||
|         //         EntityUtils.getPosition(grass).set(3 + x / 2.0f,0.0,1 + y / 2.0f); |         //queue grass shader | ||||||
|         //     } |         Globals.assetManager.addShaderToQueue("Shaders/grass1/grass1.vs", "Shaders/grass1/grass1.gs", "Shaders/grass1/grass1.fs"); | ||||||
|         // } |         for(int x = 0; x < 10; x++){ | ||||||
|  |             for(int y = 0; y < 10; y++){ | ||||||
|  |                 Entity grass = EntityUtils.spawnDrawableEntity("Models/grass1.fbx"); | ||||||
|  |                 //shader mask | ||||||
|  |                 EntityUtils.getActor(grass).maskShader("Cube", "Shaders/grass1/grass1.vs", "Shaders/grass1/grass1.gs", "Shaders/grass1/grass1.fs"); | ||||||
|  |                 EntityUtils.getPosition(grass).set(3 + x / 5.0f,0.0,1 + y / 5.0f); | ||||||
|  |             } | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|         //water cube |         //water cube | ||||||
|  | |||||||
| @ -242,6 +242,20 @@ public class AssetManager { | |||||||
|         return vertexPath + "-" + geometryPath + "-" + fragmentPath; |         return vertexPath + "-" + geometryPath + "-" + fragmentPath; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * Nuclear function, reloads all shaders loaded into memory | ||||||
|  |      */ | ||||||
|  |     public void forceReloadAllShaders(){ | ||||||
|  |         for(String shaderKey : shadersLoadedIntoMemory.keySet()){ | ||||||
|  |             String shaderPaths[] = shaderKey.split("-"); | ||||||
|  |             if(shaderPaths[1].equals("null")){ | ||||||
|  |                 shaderPaths[1] = null; | ||||||
|  |             } | ||||||
|  |             shadersInQueue.add(new ActorShaderMask("","",shaderPaths[0],shaderPaths[1],shaderPaths[2])); | ||||||
|  |         } | ||||||
|  |         shadersLoadedIntoMemory.clear(); | ||||||
|  |     } | ||||||
|  |      | ||||||
|      |      | ||||||
|      |      | ||||||
|      |      | ||||||
|  | |||||||
| @ -550,13 +550,13 @@ public class MenuGenerators { | |||||||
|                 return false; |                 return false; | ||||||
|         }}); |         }}); | ||||||
|          |          | ||||||
|         //label 2 (quit) |         //label 3 (load model and debug) | ||||||
|         Button quitButton = new Button(); |         Button debugModelButton = new Button(); | ||||||
|         Label quitLabel = new Label(100,250,fontSize); |         Label debugModelLabel = new Label(100,250,fontSize); | ||||||
|         quitLabel.setText("Print Model Debug Info"); |         debugModelLabel.setText("Print Model Debug Info"); | ||||||
|         quitButton.addChild(quitLabel); |         debugModelButton.addChild(debugModelLabel); | ||||||
|         scrollable.addChild(quitButton); |         scrollable.addChild(debugModelButton); | ||||||
|         quitButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ |         debugModelButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ | ||||||
|             // Main.running = false; |             // Main.running = false; | ||||||
|             Model targetModel = null; |             Model targetModel = null; | ||||||
|             if((targetModel = Globals.assetManager.fetchModel(modelDebugInput.getText())) != null){ |             if((targetModel = Globals.assetManager.fetchModel(modelDebugInput.getText())) != null){ | ||||||
| @ -571,9 +571,21 @@ public class MenuGenerators { | |||||||
|             return false; |             return false; | ||||||
|         }}); |         }}); | ||||||
| 
 | 
 | ||||||
|  |         //label 4 (reload all shaders) | ||||||
|  |         Button reloadShaderButton = new Button(); | ||||||
|  |         Label reloadShaderLabel = new Label(100,350,fontSize); | ||||||
|  |         reloadShaderLabel.setText("Reload all shaders"); | ||||||
|  |         reloadShaderButton.addChild(reloadShaderLabel); | ||||||
|  |         scrollable.addChild(reloadShaderButton); | ||||||
|  |         reloadShaderButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ | ||||||
|  |             // Main.running = false; | ||||||
|  |             Globals.assetManager.forceReloadAllShaders(); | ||||||
|  |             return false; | ||||||
|  |         }}); | ||||||
|  | 
 | ||||||
|         for(int i = 0; i < 9; i++){ |         for(int i = 0; i < 9; i++){ | ||||||
|             Button someButton = new Button(); |             Button someButton = new Button(); | ||||||
|             Label someLabel = new Label(100,350 + i * 100,fontSize); |             Label someLabel = new Label(100,450 + i * 100,fontSize); | ||||||
|             someLabel.setText("aaaaaa" + i); |             someLabel.setText("aaaaaa" + i); | ||||||
|             someButton.addChild(someLabel); |             someButton.addChild(someLabel); | ||||||
|             scrollable.addChild(someButton); |             scrollable.addChild(someButton); | ||||||
|  | |||||||
| @ -952,6 +952,32 @@ public class RenderingEngine { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         // | ||||||
|  |         //Draw front faces of all non-volumetrics | ||||||
|  |         // | ||||||
|  |         cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera); | ||||||
|  |         for(Entity currentEntity : Globals.entityManager.getDrawable()){ | ||||||
|  |             Vector3d position = EntityUtils.getPosition(currentEntity); | ||||||
|  |             if( | ||||||
|  |                     (boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&  | ||||||
|  |                     drawPoint(cameraPos,new Vector3f((float)position.x,(float)position.y,(float)position.z)) && | ||||||
|  |                     !currentEntity.getDataKeys().contains(EntityDataStrings.DRAW_VOLUMETRIC) | ||||||
|  |                     ){ | ||||||
|  |                 //fetch actor | ||||||
|  |                 Actor currentActor = EntityUtils.getActor(currentEntity); | ||||||
|  |                 //calculate camera-modified vector3f | ||||||
|  |                 Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); | ||||||
|  |                 //set projection matrix | ||||||
|  |                 glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "projection"), false, nearVolumeProjectionMatrix.get(new float[16])); | ||||||
|  |                 modelTransformMatrix = modelTransformMatrix.identity(); | ||||||
|  |                 modelTransformMatrix.translate(cameraModifiedPosition); | ||||||
|  |                 modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity)); | ||||||
|  |                 modelTransformMatrix.scale(EntityUtils.getScale(currentEntity)); | ||||||
|  |                 currentActor.applyModelMatrix(modelTransformMatrix); | ||||||
|  |                 currentActor.drawForDepthBuffer(); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|         //stop rendering front faces |         //stop rendering front faces | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user