* Minor shader formatting
* Particles now have proper glow * Fixed bug where references to static variables would stay in ParticleEmitter and particleInfluencer, causing havoc * Fixed warning in InputManager when using ScreenshotAppState * TestEverything now uses TangentBinormalGenerator, since before there was no tangents for the floor git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7821 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
e3574d2fe7
commit
235646f38f
@ -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;
|
||||
|
||||
|
||||
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)
|
||||
|
@ -82,6 +82,8 @@ MaterialDef Point Sprite {
|
||||
|
||||
RenderState {
|
||||
PointSprite On
|
||||
Blend AlphaAdditive
|
||||
DepthWrite Off
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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){
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class EmptyParticleInfluencer implements ParticleInfluencer {
|
||||
try {
|
||||
return (ParticleInfluencer) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
return new EmptyParticleInfluencer();
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,17 +34,19 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
|
||||
|
||||
@Override
|
||||
public void initialize(AppStateManager stateManager, Application app) {
|
||||
if (!super.isInitialized()){
|
||||
InputManager inputManager = app.getInputManager();
|
||||
inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ));
|
||||
inputManager.addListener(this, "ScreenShot");
|
||||
|
||||
List<ViewPort> vps = app.getRenderManager().getPostViews();
|
||||
ViewPort last = vps.get(vps.size()-1);
|
||||
last.addProcessor(this);
|
||||
|
||||
appName = app.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
super.initialize(stateManager, app);
|
||||
|
||||
InputManager inputManager = app.getInputManager();
|
||||
inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ));
|
||||
inputManager.addListener(this, "ScreenShot");
|
||||
|
||||
List<ViewPort> vps = app.getRenderManager().getPostViews();
|
||||
ViewPort last = vps.get(vps.size()-1);
|
||||
last.addProcessor(this);
|
||||
|
||||
appName = app.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public void onAction(String name, boolean value, float tpf) {
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user