diff --git a/engine/src/core-data/Common/MatDefs/Blur/HGaussianBlur.frag b/engine/src/core-data/Common/MatDefs/Blur/HGaussianBlur.frag index ee22b51dc..35ba78bb9 100644 --- a/engine/src/core-data/Common/MatDefs/Blur/HGaussianBlur.frag +++ b/engine/src/core-data/Common/MatDefs/Blur/HGaussianBlur.frag @@ -1,11 +1,11 @@ uniform sampler2D m_Texture; // this should hold the texture rendered by the horizontal blur pass uniform float m_Size; uniform float m_Scale; -varying vec2 texCoord; +varying vec2 texCoord; -void main(void) -{ float blurSize = m_Scale/m_Size; +void main(){ + float blurSize = m_Scale/m_Size; vec4 sum = vec4(0.0); // blur in x (vertical) diff --git a/engine/src/core-data/Common/MatDefs/Misc/Particle.j3md b/engine/src/core-data/Common/MatDefs/Misc/Particle.j3md index c33d91d4f..e28d41ab3 100644 --- a/engine/src/core-data/Common/MatDefs/Misc/Particle.j3md +++ b/engine/src/core-data/Common/MatDefs/Misc/Particle.j3md @@ -82,6 +82,8 @@ MaterialDef Point Sprite { RenderState { PointSprite On + Blend AlphaAdditive + DepthWrite Off } } } \ No newline at end of file diff --git a/engine/src/core-data/Common/MatDefs/Post/bloomExtract.frag b/engine/src/core-data/Common/MatDefs/Post/bloomExtract.frag index e11c6119b..23aa45e28 100644 --- a/engine/src/core-data/Common/MatDefs/Post/bloomExtract.frag +++ b/engine/src/core-data/Common/MatDefs/Post/bloomExtract.frag @@ -1,16 +1,14 @@ uniform float m_ExposurePow; uniform float m_ExposureCutoff; uniform sampler2D m_Texture; -varying vec2 texCoord; +varying vec2 texCoord; #ifdef HAS_GLOWMAP uniform sampler2D m_GlowMap; #endif - -void main(void) -{ +void main(){ vec4 color = vec4(0.0); #ifdef DO_EXTRACT color = texture2D( m_Texture, texCoord ); @@ -22,9 +20,9 @@ void main(void) #endif #ifdef HAS_GLOWMAP - vec4 glowColor = texture2D( m_GlowMap, texCoord ); - glowColor = pow(glowColor,vec4(m_ExposurePow)); - color+=glowColor; + vec4 glowColor = texture2D(m_GlowMap, texCoord); + glowColor = pow(glowColor, vec4(m_ExposurePow)); + color += glowColor; #endif gl_FragColor = color; diff --git a/engine/src/core-data/Common/MatDefs/Post/bloomExtract15.frag b/engine/src/core-data/Common/MatDefs/Post/bloomExtract15.frag index aeb2e1105..7194f9c7d 100644 --- a/engine/src/core-data/Common/MatDefs/Post/bloomExtract15.frag +++ b/engine/src/core-data/Common/MatDefs/Post/bloomExtract15.frag @@ -15,10 +15,12 @@ out vec4 outFragColor; void main(){ vec4 color = vec4(0.0); #ifdef DO_EXTRACT - color = getColor(m_Texture, texCoord); + color = getColorSingle(m_Texture, texCoord); if ( (color.r + color.g + color.b) / 3.0 >= m_ExposureCutoff ) { color = pow(color, vec4(m_ExposurePow)); - } + }else{ + color = vec4(0.0); + } #endif #ifdef HAS_GLOWMAP diff --git a/engine/src/core-data/Common/MatDefs/Post/bloomFinal.frag b/engine/src/core-data/Common/MatDefs/Post/bloomFinal.frag index b9d2ead66..9499e589c 100644 --- a/engine/src/core-data/Common/MatDefs/Post/bloomFinal.frag +++ b/engine/src/core-data/Common/MatDefs/Post/bloomFinal.frag @@ -1,18 +1,12 @@ -//uniform float exposurePow; -//uniform float exposureCutoff; uniform sampler2D m_Texture; uniform sampler2D m_BloomTex; uniform float m_BloomIntensity; varying vec2 texCoord; - - -void main(void) -{ - - vec4 colorRes=texture2D(m_Texture, texCoord); - vec4 bloom=texture2D(m_BloomTex, texCoord); - gl_FragColor =bloom*m_BloomIntensity+colorRes; +void main(){ + vec4 colorRes = texture2D(m_Texture, texCoord); + vec4 bloom = texture2D(m_BloomTex, texCoord); + gl_FragColor = bloom * m_BloomIntensity + colorRes; } diff --git a/engine/src/core-data/Common/MatDefs/Post/bloomFinal15.frag b/engine/src/core-data/Common/MatDefs/Post/bloomFinal15.frag index c795145f9..34268c565 100644 --- a/engine/src/core-data/Common/MatDefs/Post/bloomFinal15.frag +++ b/engine/src/core-data/Common/MatDefs/Post/bloomFinal15.frag @@ -7,10 +7,9 @@ uniform float m_BloomIntensity; in vec2 texCoord; -void main(void) -{ +void main(){ vec4 colorRes = getColor(m_Texture,texCoord); vec4 bloom = texture2D(m_BloomTex, texCoord); - gl_FragColor =bloom * m_BloomIntensity + colorRes; + gl_FragColor = bloom * m_BloomIntensity + colorRes; } diff --git a/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib b/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib index e1f8f92a5..f5936c008 100644 --- a/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib +++ b/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib @@ -37,7 +37,16 @@ vec4 getColor(in sampler2D tex, in vec2 texC){ } vec4 getColor(in sampler2DMS tex, in vec2 texC){ - return textureFetch(tex,texC,m_NumSamples); + return textureFetch(tex, texC, m_NumSamples); +} + +vec4 getColorSingle(in sampler2D tex, in vec2 texC){ + return texture2D(tex, texC); +} + +vec4 getColorSingle(in sampler2DMS tex, in vec2 texC){ + ivec2 iTexC = ivec2(texC * textureSize(tex)); + return texelFetch(tex, iTexC, 0); } vec4 getDepth(in sampler2D tex,in vec2 texC){ diff --git a/engine/src/core/com/jme3/effect/ParticleEmitter.java b/engine/src/core/com/jme3/effect/ParticleEmitter.java index 0ee6313ba..9059ab52e 100644 --- a/engine/src/core/com/jme3/effect/ParticleEmitter.java +++ b/engine/src/core/com/jme3/effect/ParticleEmitter.java @@ -168,6 +168,11 @@ public class ParticleEmitter extends Geometry { meshType = type; this.setNumParticles(numParticles); + + // Must create clone of shape/influencer so that a reference to a static is + // not maintained + shape = shape.deepClone(); + particleInfluencer = particleInfluencer.clone(); controls.add(control); @@ -836,7 +841,6 @@ public class ParticleEmitter extends Geometry { TempVars vars = TempVars.get(); - BoundingBox bbox = (BoundingBox) this.getMesh().getBound(); Vector3f min = vars.vect1; @@ -852,9 +856,7 @@ public class ParticleEmitter extends Geometry { max.set(Vector3f.NEGATIVE_INFINITY); } - while (this.emitParticle(min, max)) { - ; - } + while (emitParticle(min, max)); bbox.setMinMax(min, max); this.setBoundRefresh(); @@ -1080,6 +1082,12 @@ public class ParticleEmitter extends Geometry { super.read(im); InputCapsule ic = im.getCapsule(this); shape = (EmitterShape) ic.readSavable("shape", DEFAULT_SHAPE); + + if (shape == DEFAULT_SHAPE){ + // Prevent reference to static + shape = shape.deepClone(); + } + meshType = ic.readEnum("meshType", ParticleMesh.Type.class, ParticleMesh.Type.Triangle); int numParticles = ic.readInt("numParticles", 0); this.setNumParticles(numParticles); @@ -1117,6 +1125,9 @@ public class ParticleEmitter extends Geometry { particleMesh.initParticleData(this, particles.length); particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER); + if (particleInfluencer == DEFAULT_INFLUENCER){ + particleInfluencer = particleInfluencer.clone(); + } if (im.getFormatVersion() == 0){ // compatibility before the control inside particle emitter diff --git a/engine/src/core/com/jme3/effect/ParticleTriMesh.java b/engine/src/core/com/jme3/effect/ParticleTriMesh.java index 8ce619734..55bd936cc 100644 --- a/engine/src/core/com/jme3/effect/ParticleTriMesh.java +++ b/engine/src/core/com/jme3/effect/ParticleTriMesh.java @@ -177,9 +177,10 @@ public class ParticleTriMesh extends ParticleMesh { } if (facingVelocity){ - left.set(p.velocity).normalizeLocal().multLocal(p.size); + left.set(p.velocity).normalizeLocal(); camDir.cross(left, up); up.multLocal(p.size); + left.multLocal(p.size); }else if (faceNormal != null){ up.set(faceNormal).crossLocal(Vector3f.UNIT_X); faceNormal.cross(up, left); diff --git a/engine/src/core/com/jme3/effect/influencers/DefaultParticleInfluencer.java b/engine/src/core/com/jme3/effect/influencers/DefaultParticleInfluencer.java index 22a9c6a8d..ade14069c 100644 --- a/engine/src/core/com/jme3/effect/influencers/DefaultParticleInfluencer.java +++ b/engine/src/core/com/jme3/effect/influencers/DefaultParticleInfluencer.java @@ -63,9 +63,11 @@ public class DefaultParticleInfluencer implements ParticleInfluencer { @Override public ParticleInfluencer clone() { try { - return (ParticleInfluencer) super.clone(); + DefaultParticleInfluencer clone = (DefaultParticleInfluencer) super.clone(); + clone.startVelocity = startVelocity.clone(); + return clone; } catch (CloneNotSupportedException e) { - return null; + throw new AssertionError(); } } diff --git a/engine/src/core/com/jme3/effect/influencers/EmptyParticleInfluencer.java b/engine/src/core/com/jme3/effect/influencers/EmptyParticleInfluencer.java index 56265a77e..dced19646 100644 --- a/engine/src/core/com/jme3/effect/influencers/EmptyParticleInfluencer.java +++ b/engine/src/core/com/jme3/effect/influencers/EmptyParticleInfluencer.java @@ -50,7 +50,7 @@ public class EmptyParticleInfluencer implements ParticleInfluencer { try { return (ParticleInfluencer) super.clone(); } catch (CloneNotSupportedException e) { - return new EmptyParticleInfluencer(); + throw new AssertionError(); } } } diff --git a/engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java b/engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java index d7ddfc300..ba2556df4 100644 --- a/engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java +++ b/engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java @@ -34,17 +34,19 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen @Override public void initialize(AppStateManager stateManager, Application app) { - super.initialize(stateManager, app); - - InputManager inputManager = app.getInputManager(); - inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ)); - inputManager.addListener(this, "ScreenShot"); + if (!super.isInitialized()){ + InputManager inputManager = app.getInputManager(); + inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ)); + inputManager.addListener(this, "ScreenShot"); - List vps = app.getRenderManager().getPostViews(); - ViewPort last = vps.get(vps.size()-1); - last.addProcessor(this); + List vps = app.getRenderManager().getPostViews(); + ViewPort last = vps.get(vps.size()-1); + last.addProcessor(this); - appName = app.getClass().getSimpleName(); + appName = app.getClass().getSimpleName(); + } + + super.initialize(stateManager, app); } public void onAction(String name, boolean value, float tpf) { diff --git a/engine/src/test/jme3test/effect/TestEverything.java b/engine/src/test/jme3test/effect/TestEverything.java index d30821b00..b358815b4 100644 --- a/engine/src/test/jme3test/effect/TestEverything.java +++ b/engine/src/test/jme3test/effect/TestEverything.java @@ -54,6 +54,7 @@ import com.jme3.shadow.BasicShadowRenderer; import com.jme3.texture.Texture; import com.jme3.texture.Texture.WrapMode; import com.jme3.util.SkyFactory; +import com.jme3.util.TangentBinormalGenerator; public class TestEverything extends SimpleApplication { @@ -127,11 +128,13 @@ public class TestEverything extends SimpleApplication { } public void setupFloor(){ - Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"); + Material mat = assetManager.loadMaterial("Textures/Terrain/Cobblestone/Cobblestone.j3m"); mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat); mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat); mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat); + Box floor = new Box(Vector3f.ZERO, 50, 1f, 50); + TangentBinormalGenerator.generate(floor); floor.scaleTextureCoordinates(new Vector2f(5, 5)); Geometry floorGeom = new Geometry("Floor", floor); floorGeom.setMaterial(mat); diff --git a/engine/src/test/jme3test/effect/TestExplosionEffect.java b/engine/src/test/jme3test/effect/TestExplosionEffect.java index e9aae6c7d..7ceae96bc 100644 --- a/engine/src/test/jme3test/effect/TestExplosionEffect.java +++ b/engine/src/test/jme3test/effect/TestExplosionEffect.java @@ -75,8 +75,8 @@ public class TestExplosionEffect extends SimpleApplication { flame.setGravity(0, -5, 0); flame.setLowLife(.4f); flame.setHighLife(.5f); - flame.setInitialVelocity(new Vector3f(0, 7, 0)); - flame.setVelocityVariation(1f); + flame.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 7, 0)); + flame.getParticleInfluencer().setVelocityVariation(1f); flame.setImagesX(2); flame.setImagesY(2); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); @@ -137,15 +137,13 @@ public class TestExplosionEffect extends SimpleApplication { spark.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f)); spark.setStartSize(.5f); spark.setEndSize(.5f); - -// spark.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f)); spark.setFacingVelocity(true); spark.setParticlesPerSec(0); spark.setGravity(0, 5, 0); spark.setLowLife(1.1f); spark.setHighLife(1.5f); - spark.setInitialVelocity(new Vector3f(0, 20, 0)); - spark.setVelocityVariation(1); + spark.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 20, 0)); + spark.getParticleInfluencer().setVelocityVariation(1); spark.setImagesX(1); spark.setImagesY(1); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");