diff --git a/h3d/impl/GlDriver.hx b/h3d/impl/GlDriver.hx index b3b589d384..239bf0bd62 100644 --- a/h3d/impl/GlDriver.hx +++ b/h3d/impl/GlDriver.hx @@ -89,6 +89,7 @@ class GlDriver extends Driver { static var UID = 0; public var gl : GL; public static var ALLOW_WEBGL2 = true; + public static var MAX_PRECISION = null; public var textureSupport:hxd.PixelFormat; #end @@ -280,6 +281,9 @@ class GlDriver extends Driver { var glout = new ShaderCompiler(); glout.glES = glES; glout.version = shaderVersion; + #if js + glout.precision = MAX_PRECISION; + #end #if !usegl @:privateAccess glout.intelDriverFix = isIntelGpu; #end diff --git a/h3d/scene/Skin.hx b/h3d/scene/Skin.hx index db9c73c0be..8f095aedf1 100644 --- a/h3d/scene/Skin.hx +++ b/h3d/scene/Skin.hx @@ -75,6 +75,7 @@ class Skin extends MultiMaterial { var paletteChanged : Bool; var skinShader : h3d.shader.SkinBase; var jointsGraphics : Graphics; + var additivePose : Array; public var showJoints : Bool; public var enableRetargeting : Bool = true; @@ -170,10 +171,14 @@ class Skin extends MultiMaterial { return skinData; } - public function setJointRelPosition( name : String, pos : h3d.Matrix ) { + public function setJointRelPosition( name : String, pos : h3d.Matrix, additive = false ) { var j = skinData.namedJoints.get(name); if( j == null ) return; - currentRelPose[j.index] = pos; + if( additive ) { + if( additivePose == null ) additivePose = []; + additivePose[j.index] = pos; + } else + currentRelPose[j.index] = pos; jointsUpdated = true; } @@ -251,6 +256,10 @@ class Skin extends MultiMaterial { m.multiply3x4inline(r, absPos); else m.multiply3x4inline(r, currentAbsPose[j.parent.index]); + if( additivePose != null ) { + var a = additivePose[id]; + if( a != null ) m.multiply3x4inline(a, m); + } if( bid >= 0 ) currentPalette[bid].multiply3x4inline(j.transPos, m); } diff --git a/hxsl/Flatten.hx b/hxsl/Flatten.hx index 7aa1e92e4c..7fbcc9cd7a 100644 --- a/hxsl/Flatten.hx +++ b/hxsl/Flatten.hx @@ -184,7 +184,7 @@ class Flatten { if( idx == idx2 ) readField(expr, pos, size); else { - var k = 4 - pos; + var k = (idx2 << 2) - pos; var type = switch(size) { case 2: Vec2; case 3: Vec3; @@ -193,7 +193,7 @@ class Flatten { } { e : TCall({ e : TGlobal(type), p : e.p, t : TVoid },[ readField(expr, pos, k), - readField(expr, pos + 1, size - k) + readField(expr, pos + k, size - k) ]), t : e.t, p : e.p } } case TMat4: diff --git a/hxsl/GlslOut.hx b/hxsl/GlslOut.hx index 5e149ef03b..e2c3463503 100644 --- a/hxsl/GlslOut.hx +++ b/hxsl/GlslOut.hx @@ -99,6 +99,7 @@ class GlslOut { public var varNames : Map; public var glES : Null; public var version : Null; + public var precision : Null = null; /* Intel HD driver fix: @@ -811,6 +812,9 @@ class GlslOut { if( isCompute ) { // no prec + } else if( precision != null ) { + decl('precision $precision float;'); + decl('precision $precision int;'); } else if( isVertex ) { decl("precision highp float;"); decl("precision highp int;"); @@ -818,7 +822,7 @@ class GlslOut { decl("precision mediump float;"); decl("precision mediump int;"); } - + initVars(s); if( isCompute )