|
@@ -9,8 +9,7 @@ class Environment extends Object3D {
|
|
|
var env : h3d.scene.pbr.Environment;
|
|
|
|
|
|
public var power : Float = 1.0;
|
|
|
- public var threshold : Float = 1.0;
|
|
|
- public var scale : Float = 1.0;
|
|
|
+ public var hdrMax : Float = 10.0;
|
|
|
public var rotation : Float = 0.0;
|
|
|
public var sampleBits : Int = 12;
|
|
|
public var diffSize : Int = 64;
|
|
@@ -25,8 +24,7 @@ class Environment extends Object3D {
|
|
|
override function load( obj : Dynamic ) {
|
|
|
super.load(obj);
|
|
|
power = obj.power != null ? obj.power : 1.0;
|
|
|
- threshold = obj.threshold != null ? obj.threshold : 1.0;
|
|
|
- scale = obj.scale != null ? obj.scale : 1.0;
|
|
|
+ hdrMax = obj.hdrMax != null ? obj.hdrMax : 10.0;
|
|
|
rotation = obj.rotation != null ? obj.rotation : 0.0;
|
|
|
sampleBits = obj.sampleBits != null ? obj.sampleBits : 12;
|
|
|
diffSize = obj.diffSize != null ? obj.diffSize : 64;
|
|
@@ -39,28 +37,22 @@ class Environment extends Object3D {
|
|
|
override function save() {
|
|
|
var obj : Dynamic = super.save();
|
|
|
obj.power = power;
|
|
|
- obj.threshold = threshold;
|
|
|
- obj.scale = scale;
|
|
|
obj.rotation = rotation;
|
|
|
obj.sampleBits = sampleBits;
|
|
|
obj.diffSize = diffSize;
|
|
|
obj.specSize = specSize;
|
|
|
obj.ignoredSpecLevels = ignoredSpecLevels;
|
|
|
obj.sourceMapPath = sourceMapPath;
|
|
|
+ obj.hdrMax = hdrMax;
|
|
|
if( configName != null ) obj.configName = configName;
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
function loadFromBinary() {
|
|
|
- var path = new haxe.io.Path(sourceMapPath);
|
|
|
try {
|
|
|
env.dispose();
|
|
|
- if( configName != null )
|
|
|
- path.file += "-" + configName;
|
|
|
- path.ext = "envd.dds";
|
|
|
- env.diffuse = hxd.res.Loader.currentInstance.load(path.toString()).toImage().toTexture();
|
|
|
- path.ext = "envs.dds";
|
|
|
- env.specular = hxd.res.Loader.currentInstance.load(path.toString()).toImage().toTexture();
|
|
|
+ env.diffuse = hxd.res.Loader.currentInstance.load(getBinaryPath(true)).toImage().toTexture();
|
|
|
+ env.specular = hxd.res.Loader.currentInstance.load(getBinaryPath(false)).toImage().toTexture();
|
|
|
env.specular.mipMap = Linear;
|
|
|
env.specLevels = env.getMipLevels() - ignoredSpecLevels;
|
|
|
return true;
|
|
@@ -69,19 +61,22 @@ class Environment extends Object3D {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function getBinaryPath( diffuse : Bool ) {
|
|
|
+ var path = new haxe.io.Path(sourceMapPath);
|
|
|
+ if( configName != null )
|
|
|
+ path.file += "-" + configName;
|
|
|
+ path.ext = diffuse ? "envd.dds" : "envs.dds";
|
|
|
+ return path.toString();
|
|
|
+ }
|
|
|
+
|
|
|
function saveToBinary() {
|
|
|
#if (hl || hxnodejs)
|
|
|
var fs = cast(hxd.res.Loader.currentInstance.fs, hxd.fs.LocalFileSystem);
|
|
|
if( fs == null ) return;
|
|
|
- var path = new haxe.io.Path(fs.baseDir+sourceMapPath);
|
|
|
- if( configName != null )
|
|
|
- path.file += "-" + configName;
|
|
|
var diffuse = hxd.Pixels.toDDS([for( i in 0...6 ) env.diffuse.capturePixels(i)],true);
|
|
|
- path.ext = "envd.dds";
|
|
|
- sys.io.File.saveBytes(path.toString(), diffuse);
|
|
|
+ sys.io.File.saveBytes(fs.baseDir + getBinaryPath(true), diffuse);
|
|
|
var specular = hxd.Pixels.toDDS([for( i in 0...6 ) for( mip in 0...env.getMipLevels() ) env.specular.capturePixels(i,mip)],true);
|
|
|
- path.ext = "envs.dds";
|
|
|
- sys.io.File.saveBytes(path.toString(), specular);
|
|
|
+ sys.io.File.saveBytes(fs.baseDir + getBinaryPath(false), specular);
|
|
|
#end
|
|
|
}
|
|
|
|
|
@@ -127,8 +122,7 @@ class Environment extends Object3D {
|
|
|
env.diffSize = diffSize;
|
|
|
env.sampleBits = sampleBits;
|
|
|
env.ignoredSpecLevels = ignoredSpecLevels;
|
|
|
- env.threshold = threshold;
|
|
|
- env.scale = scale;
|
|
|
+ env.hdrMax = hdrMax;
|
|
|
|
|
|
env.rot = rotation;
|
|
|
env.power = power;
|
|
@@ -170,7 +164,7 @@ class Environment extends Object3D {
|
|
|
<dl>
|
|
|
<dt>SkyBox</dt><dd><input type="texturepath" field="sourceMapPath"/></dd>
|
|
|
<dt>Rotation</dt><dd><input type="range" min="0" max="360" field="rotation"/></dd>
|
|
|
- <dt>Power</dt><dd><input type="range" min="0" max="10" field="power"/></dd>
|
|
|
+ <dt>Power</dt><dd><input type="range" min="0" max="2" field="power"/></dd>
|
|
|
</dl>
|
|
|
</div>
|
|
|
<div class="group closed" name="Generation">
|
|
@@ -179,10 +173,13 @@ class Environment extends Object3D {
|
|
|
<dt>Specular</dt><dd><input type="range" min="1" max="2048" step="1" field="specSize"/></dd>
|
|
|
<dt>Sample Count</dt><dd><input type="range" min="1" max="12" step="1" field="sampleBits"/></dd>
|
|
|
<dt>Ignored Spec Levels</dt><dd><input type="range" min="0" max="3" step="1" field="ignoredSpecLevels"/></dd>
|
|
|
- <dt>HDR Threshold</dt><dd><input type="range" min="0" max="1" step="0.1" field="threshold"/></dd>
|
|
|
- <dt>HDR Scale</dt><dd><input type="range" min="0" max="10" field="scale"/></dd>
|
|
|
+ <dt>HDR Max</dt><dd><input type="range" min="0" max="100" field="hdrMax"/></dd>
|
|
|
<dt>Config Name</dt><dd><input type="text" field="configName"/></dd>
|
|
|
<dt> </dt><dd><input type="button" class="compute" value="Compute"/></dd>
|
|
|
+ <dt>View</dt><dd>
|
|
|
+ <input type="button" style="width:90px" class="showDif" value="Diffuse"/>
|
|
|
+ <input type="button" style="width:90px" class="showSpec" value="Specular"/>
|
|
|
+ </dd>
|
|
|
</dl>
|
|
|
</div>
|
|
|
');
|
|
@@ -196,6 +193,14 @@ class Environment extends Object3D {
|
|
|
ctx.onChange(this,"force");
|
|
|
});
|
|
|
|
|
|
+ props.find(".showDif").click(function(_) {
|
|
|
+ ctx.ide.openFile(getBinaryPath(true));
|
|
|
+ });
|
|
|
+
|
|
|
+ props.find(".showSpec").click(function(_) {
|
|
|
+ ctx.ide.openFile(getBinaryPath(false));
|
|
|
+ });
|
|
|
+
|
|
|
ctx.properties.add(props, this, function(pname) {
|
|
|
ctx.onChange(this, pname);
|
|
|
});
|