Просмотр исходного кода

remove hide shadow baking (use game-generated static shadows)

Nicolas Cannasse 4 лет назад
Родитель
Сommit
575d94b667
2 измененных файлов с 3 добавлено и 93 удалено
  1. 1 67
      hide/view/Prefab.hx
  2. 2 26
      hrt/prefab/Light.hx

+ 1 - 67
hide/view/Prefab.hx

@@ -352,7 +352,6 @@ class Prefab extends FileView {
 		toolsDefs.push({id: "snapToGroundToggle", title : "Snap to ground", icon : "anchor", type : Toggle((v) -> sceneEditor.snapToGround = v)});
 		toolsDefs.push({id: "localTransformsToggle", title : "Local transforms", icon : "compass", type : Toggle((v) -> sceneEditor.localTransform = v)});
 		toolsDefs.push({id: "gridToggle", title : "Toggle grid", icon : "th", type : Toggle((v) -> { showGrid = v; updateGrid(); }) });
-		toolsDefs.push({id: "bakeLights", title : "Bake lights", icon : "lightbulb-o", type : Button(() -> bakeLights()) });
 		var texContent : Element = null;
 		toolsDefs.push({id: "sceneInformationToggle", title : "Scene information", icon : "info-circle", type : Toggle((b) -> statusText.visible = b), rightClick: () -> {
 			if( texContent != null ) {
@@ -445,71 +444,6 @@ class Prefab extends FileView {
 		haxe.Timer.delay(function() sceneEditor.event.wait(0.5, updateStats), 0);
 	}
 
-	function bakeLights() {
-		var curSel = sceneEditor.curEdit.elements;
-		sceneEditor.selectElements([]);
-		var passes = [];
-		for( m in scene.s3d.getMaterials() ) {
-			var s = m.getPass("shadow");
-			if( s != null && !s.isStatic ) passes.push(s);
-		}
-		for( p in passes )
-			p.isStatic = true;
-
-		function isDynamic(elt: hrt.prefab.Prefab) {
-			var p = elt;
-			while(p != null) {
-				if(p.name == "dynamic")
-					return true;
-				p = p.parent;
-			}
-			return false;
-		}
-
-		for(elt in data.flatten()) {
-			if(Std.is(elt, Instance) || isDynamic(elt)) {
-				var mats = sceneEditor.context.shared.getMaterials(elt);
-				for(mat in mats) {
-					var p = mat.getPass("shadow");
-					if(p != null)
-						p.isStatic = false;
-				}
-			}
-		}
-
-		scene.s3d.computeStatic();
-		for( p in passes )
-			p.isStatic = false;
-		var lights = data.getAll(hrt.prefab.Light);
-		for( l in lights ) {
-			if(!l.visible)
-				continue;
-			l.saveBaked(sceneEditor.context);
-		}
-		sceneEditor.selectElements(curSel);
-	}
-
-	function bakeVolumetricLightmaps(){
-		var volumetricLightmaps = data.getAll(hrt.prefab.vlm.VolumetricLightmap);
-		var total = 0;
-		for( v in volumetricLightmaps )
-			total += v.volumetricLightmap.getProbeCount();
-		if( total == 0 )
-			return;
-		if( !ide.confirm("Bake "+total+" probes?") )
-			return;
-		function bakeNext() {
-			var v = volumetricLightmaps.shift();
-			if( v == null ) {
-				ide.message("Done");
-				return;
-			}
-			v.startBake(sceneEditor.curEdit, bakeNext);
-			sceneEditor.selectElements([v]);
-		}
-		bakeNext();
-	}
-
 	function resetCamera( top : Bool ) {
 		var targetPt = new h3d.col.Point(0, 0, 0);
 		var curEdit = sceneEditor.curEdit;
@@ -672,7 +606,7 @@ class Prefab extends FileView {
 						case "Scene":
 							applySceneFilter(typeid, on);
 					}
-					
+
 				content.find(function(item) return item.label == typeid).checked = on;
 			}});
 		}

+ 2 - 26
hrt/prefab/Light.hx

@@ -147,24 +147,9 @@ class Light extends Object3D {
 
 		cookieTex = initTexture(cookiePath);
 		updateInstance(ctx);
-
-		if( ctx.shared.parent == null )
-			loadBaked(ctx);
 		return ctx;
 	}
 
-	function loadBaked( ctx : Context ) {
-		var light = Std.downcast(ctx.local3d, h3d.scene.pbr.Light);
-		if( light == null ) return;
-		if( light.shadows.mode == Static || light.shadows.mode == Mixed ){
-			var res = ctx.shared.loadPrefabDat("shadowMap", "bake", name);
-			if( res != null ) light.shadows.loadStaticData(res.entry.getBytes());
-			#if !editor
-			if( res == null ) light.shadows.mode = None; // Prevent crash if shadows are not baked
-			#end
-		}
-	}
-
 	override function updateInstance( ctx : Context, ?propName : String ) {
 		super.updateInstance(ctx, propName);
 
@@ -361,23 +346,14 @@ class Light extends Object3D {
 			sel.name = "__selection";
 		}
 
-		// no "Mixed" in editor (prevent double shadowing)
-		if( light != null && light.shadows.mode == Mixed ) light.shadows.mode = Static;
-
-		// when selected, force Dynamic mode (realtime preview)
-		//if( isSelected && shadows.mode != None ) light.shadows.mode = Dynamic;
+		// no "Mixed" in editor
+		if( light != null && light.shadows.mode == Mixed ) light.shadows.mode = Dynamic;
 
 		#end
 	}
 
 	#if editor
 
-	public function saveBaked( ctx : Context ) {
-		var light = cast(ctx.shared.contexts.get(this).local3d,h3d.scene.pbr.Light);
-		var bytes = light.shadows.saveStaticData();
-		ctx.shared.savePrefabDat("shadowMap", "bake", name, bytes);
-	}
-
 	override function setSelected( ctx : Context, b : Bool ) {
 		var sel = ctx.local3d.getObjectByName("__selection");
 		if( sel != null ) sel.visible = b;