* 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 sampler2D m_Texture; // this should hold the texture rendered by the horizontal blur pass
|
||||||
uniform float m_Size;
|
uniform float m_Size;
|
||||||
uniform float m_Scale;
|
uniform float m_Scale;
|
||||||
|
|
||||||
varying vec2 texCoord;
|
varying vec2 texCoord;
|
||||||
|
|
||||||
|
void main(){
|
||||||
void main(void)
|
float blurSize = m_Scale/m_Size;
|
||||||
{ float blurSize = m_Scale/m_Size;
|
|
||||||
vec4 sum = vec4(0.0);
|
vec4 sum = vec4(0.0);
|
||||||
|
|
||||||
// blur in x (vertical)
|
// blur in x (vertical)
|
||||||
|
@ -82,6 +82,8 @@ MaterialDef Point Sprite {
|
|||||||
|
|
||||||
RenderState {
|
RenderState {
|
||||||
PointSprite On
|
PointSprite On
|
||||||
|
Blend AlphaAdditive
|
||||||
|
DepthWrite Off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,14 @@
|
|||||||
uniform float m_ExposurePow;
|
uniform float m_ExposurePow;
|
||||||
uniform float m_ExposureCutoff;
|
uniform float m_ExposureCutoff;
|
||||||
uniform sampler2D m_Texture;
|
uniform sampler2D m_Texture;
|
||||||
varying vec2 texCoord;
|
|
||||||
|
|
||||||
|
varying vec2 texCoord;
|
||||||
|
|
||||||
#ifdef HAS_GLOWMAP
|
#ifdef HAS_GLOWMAP
|
||||||
uniform sampler2D m_GlowMap;
|
uniform sampler2D m_GlowMap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void main(){
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
vec4 color = vec4(0.0);
|
vec4 color = vec4(0.0);
|
||||||
#ifdef DO_EXTRACT
|
#ifdef DO_EXTRACT
|
||||||
color = texture2D( m_Texture, texCoord );
|
color = texture2D( m_Texture, texCoord );
|
||||||
|
@ -15,9 +15,11 @@ out vec4 outFragColor;
|
|||||||
void main(){
|
void main(){
|
||||||
vec4 color = vec4(0.0);
|
vec4 color = vec4(0.0);
|
||||||
#ifdef DO_EXTRACT
|
#ifdef DO_EXTRACT
|
||||||
color = getColor(m_Texture, texCoord);
|
color = getColorSingle(m_Texture, texCoord);
|
||||||
if ( (color.r + color.g + color.b) / 3.0 >= m_ExposureCutoff ) {
|
if ( (color.r + color.g + color.b) / 3.0 >= m_ExposureCutoff ) {
|
||||||
color = pow(color, vec4(m_ExposurePow));
|
color = pow(color, vec4(m_ExposurePow));
|
||||||
|
}else{
|
||||||
|
color = vec4(0.0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
//uniform float exposurePow;
|
|
||||||
//uniform float exposureCutoff;
|
|
||||||
uniform sampler2D m_Texture;
|
uniform sampler2D m_Texture;
|
||||||
uniform sampler2D m_BloomTex;
|
uniform sampler2D m_BloomTex;
|
||||||
uniform float m_BloomIntensity;
|
uniform float m_BloomIntensity;
|
||||||
|
|
||||||
varying vec2 texCoord;
|
varying vec2 texCoord;
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
vec4 colorRes = texture2D(m_Texture, texCoord);
|
vec4 colorRes = texture2D(m_Texture, texCoord);
|
||||||
vec4 bloom = texture2D(m_BloomTex, texCoord);
|
vec4 bloom = texture2D(m_BloomTex, texCoord);
|
||||||
gl_FragColor = bloom * m_BloomIntensity + colorRes;
|
gl_FragColor = bloom * m_BloomIntensity + colorRes;
|
||||||
|
@ -7,8 +7,7 @@ uniform float m_BloomIntensity;
|
|||||||
|
|
||||||
in vec2 texCoord;
|
in vec2 texCoord;
|
||||||
|
|
||||||
void main(void)
|
void main(){
|
||||||
{
|
|
||||||
vec4 colorRes = getColor(m_Texture,texCoord);
|
vec4 colorRes = getColor(m_Texture,texCoord);
|
||||||
vec4 bloom = texture2D(m_BloomTex, texCoord);
|
vec4 bloom = texture2D(m_BloomTex, texCoord);
|
||||||
gl_FragColor = bloom * m_BloomIntensity + colorRes;
|
gl_FragColor = bloom * m_BloomIntensity + colorRes;
|
||||||
|
@ -40,6 +40,15 @@ 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){
|
vec4 getDepth(in sampler2D tex,in vec2 texC){
|
||||||
return texture2D(tex,texC);
|
return texture2D(tex,texC);
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,11 @@ public class ParticleEmitter extends Geometry {
|
|||||||
|
|
||||||
this.setNumParticles(numParticles);
|
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);
|
controls.add(control);
|
||||||
|
|
||||||
switch (meshType) {
|
switch (meshType) {
|
||||||
@ -836,7 +841,6 @@ public class ParticleEmitter extends Geometry {
|
|||||||
|
|
||||||
TempVars vars = TempVars.get();
|
TempVars vars = TempVars.get();
|
||||||
|
|
||||||
|
|
||||||
BoundingBox bbox = (BoundingBox) this.getMesh().getBound();
|
BoundingBox bbox = (BoundingBox) this.getMesh().getBound();
|
||||||
|
|
||||||
Vector3f min = vars.vect1;
|
Vector3f min = vars.vect1;
|
||||||
@ -852,9 +856,7 @@ public class ParticleEmitter extends Geometry {
|
|||||||
max.set(Vector3f.NEGATIVE_INFINITY);
|
max.set(Vector3f.NEGATIVE_INFINITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (this.emitParticle(min, max)) {
|
while (emitParticle(min, max));
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
bbox.setMinMax(min, max);
|
bbox.setMinMax(min, max);
|
||||||
this.setBoundRefresh();
|
this.setBoundRefresh();
|
||||||
@ -1080,6 +1082,12 @@ public class ParticleEmitter extends Geometry {
|
|||||||
super.read(im);
|
super.read(im);
|
||||||
InputCapsule ic = im.getCapsule(this);
|
InputCapsule ic = im.getCapsule(this);
|
||||||
shape = (EmitterShape) ic.readSavable("shape", DEFAULT_SHAPE);
|
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);
|
meshType = ic.readEnum("meshType", ParticleMesh.Type.class, ParticleMesh.Type.Triangle);
|
||||||
int numParticles = ic.readInt("numParticles", 0);
|
int numParticles = ic.readInt("numParticles", 0);
|
||||||
this.setNumParticles(numParticles);
|
this.setNumParticles(numParticles);
|
||||||
@ -1117,6 +1125,9 @@ public class ParticleEmitter extends Geometry {
|
|||||||
particleMesh.initParticleData(this, particles.length);
|
particleMesh.initParticleData(this, particles.length);
|
||||||
|
|
||||||
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER);
|
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER);
|
||||||
|
if (particleInfluencer == DEFAULT_INFLUENCER){
|
||||||
|
particleInfluencer = particleInfluencer.clone();
|
||||||
|
}
|
||||||
|
|
||||||
if (im.getFormatVersion() == 0){
|
if (im.getFormatVersion() == 0){
|
||||||
// compatibility before the control inside particle emitter
|
// compatibility before the control inside particle emitter
|
||||||
|
@ -177,9 +177,10 @@ public class ParticleTriMesh extends ParticleMesh {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (facingVelocity){
|
if (facingVelocity){
|
||||||
left.set(p.velocity).normalizeLocal().multLocal(p.size);
|
left.set(p.velocity).normalizeLocal();
|
||||||
camDir.cross(left, up);
|
camDir.cross(left, up);
|
||||||
up.multLocal(p.size);
|
up.multLocal(p.size);
|
||||||
|
left.multLocal(p.size);
|
||||||
}else if (faceNormal != null){
|
}else if (faceNormal != null){
|
||||||
up.set(faceNormal).crossLocal(Vector3f.UNIT_X);
|
up.set(faceNormal).crossLocal(Vector3f.UNIT_X);
|
||||||
faceNormal.cross(up, left);
|
faceNormal.cross(up, left);
|
||||||
|
@ -63,9 +63,11 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
|
|||||||
@Override
|
@Override
|
||||||
public ParticleInfluencer clone() {
|
public ParticleInfluencer clone() {
|
||||||
try {
|
try {
|
||||||
return (ParticleInfluencer) super.clone();
|
DefaultParticleInfluencer clone = (DefaultParticleInfluencer) super.clone();
|
||||||
|
clone.startVelocity = startVelocity.clone();
|
||||||
|
return clone;
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
return null;
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class EmptyParticleInfluencer implements ParticleInfluencer {
|
|||||||
try {
|
try {
|
||||||
return (ParticleInfluencer) super.clone();
|
return (ParticleInfluencer) super.clone();
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
return new EmptyParticleInfluencer();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,7 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(AppStateManager stateManager, Application app) {
|
public void initialize(AppStateManager stateManager, Application app) {
|
||||||
super.initialize(stateManager, app);
|
if (!super.isInitialized()){
|
||||||
|
|
||||||
InputManager inputManager = app.getInputManager();
|
InputManager inputManager = app.getInputManager();
|
||||||
inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ));
|
inputManager.addMapping("ScreenShot", new KeyTrigger(KeyInput.KEY_SYSRQ));
|
||||||
inputManager.addListener(this, "ScreenShot");
|
inputManager.addListener(this, "ScreenShot");
|
||||||
@ -47,6 +46,9 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen
|
|||||||
appName = app.getClass().getSimpleName();
|
appName = app.getClass().getSimpleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.initialize(stateManager, app);
|
||||||
|
}
|
||||||
|
|
||||||
public void onAction(String name, boolean value, float tpf) {
|
public void onAction(String name, boolean value, float tpf) {
|
||||||
if (value){
|
if (value){
|
||||||
capture = true;
|
capture = true;
|
||||||
|
@ -54,6 +54,7 @@ import com.jme3.shadow.BasicShadowRenderer;
|
|||||||
import com.jme3.texture.Texture;
|
import com.jme3.texture.Texture;
|
||||||
import com.jme3.texture.Texture.WrapMode;
|
import com.jme3.texture.Texture.WrapMode;
|
||||||
import com.jme3.util.SkyFactory;
|
import com.jme3.util.SkyFactory;
|
||||||
|
import com.jme3.util.TangentBinormalGenerator;
|
||||||
|
|
||||||
public class TestEverything extends SimpleApplication {
|
public class TestEverything extends SimpleApplication {
|
||||||
|
|
||||||
@ -127,11 +128,13 @@ public class TestEverything extends SimpleApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setupFloor(){
|
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("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
|
||||||
mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
|
mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
|
||||||
mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
|
mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
|
||||||
|
|
||||||
Box floor = new Box(Vector3f.ZERO, 50, 1f, 50);
|
Box floor = new Box(Vector3f.ZERO, 50, 1f, 50);
|
||||||
|
TangentBinormalGenerator.generate(floor);
|
||||||
floor.scaleTextureCoordinates(new Vector2f(5, 5));
|
floor.scaleTextureCoordinates(new Vector2f(5, 5));
|
||||||
Geometry floorGeom = new Geometry("Floor", floor);
|
Geometry floorGeom = new Geometry("Floor", floor);
|
||||||
floorGeom.setMaterial(mat);
|
floorGeom.setMaterial(mat);
|
||||||
|
@ -75,8 +75,8 @@ public class TestExplosionEffect extends SimpleApplication {
|
|||||||
flame.setGravity(0, -5, 0);
|
flame.setGravity(0, -5, 0);
|
||||||
flame.setLowLife(.4f);
|
flame.setLowLife(.4f);
|
||||||
flame.setHighLife(.5f);
|
flame.setHighLife(.5f);
|
||||||
flame.setInitialVelocity(new Vector3f(0, 7, 0));
|
flame.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 7, 0));
|
||||||
flame.setVelocityVariation(1f);
|
flame.getParticleInfluencer().setVelocityVariation(1f);
|
||||||
flame.setImagesX(2);
|
flame.setImagesX(2);
|
||||||
flame.setImagesY(2);
|
flame.setImagesY(2);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
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.setEndColor(new ColorRGBA(1f, 0.8f, 0.36f, 0f));
|
||||||
spark.setStartSize(.5f);
|
spark.setStartSize(.5f);
|
||||||
spark.setEndSize(.5f);
|
spark.setEndSize(.5f);
|
||||||
|
|
||||||
// spark.setShape(new EmitterSphereShape(Vector3f.ZERO, .05f));
|
|
||||||
spark.setFacingVelocity(true);
|
spark.setFacingVelocity(true);
|
||||||
spark.setParticlesPerSec(0);
|
spark.setParticlesPerSec(0);
|
||||||
spark.setGravity(0, 5, 0);
|
spark.setGravity(0, 5, 0);
|
||||||
spark.setLowLife(1.1f);
|
spark.setLowLife(1.1f);
|
||||||
spark.setHighLife(1.5f);
|
spark.setHighLife(1.5f);
|
||||||
spark.setInitialVelocity(new Vector3f(0, 20, 0));
|
spark.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 20, 0));
|
||||||
spark.setVelocityVariation(1);
|
spark.getParticleInfluencer().setVelocityVariation(1);
|
||||||
spark.setImagesX(1);
|
spark.setImagesX(1);
|
||||||
spark.setImagesY(1);
|
spark.setImagesY(1);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user