jPCT-AE - a 3d engine for Android > Support

Blur on some objects (Fire/Explosion effect)

(1/2) > >>

Andrey8000:
Hello, how can i make blur effect on some objects in JPCT-ae? I need it to create explosion effect in my game.
Or may be glow effect around object?

EgonOlsen:
A blur effect requires render to texture and a custom shader for a post-processing blur effect. That can get complicated and performance will suffer on anything but the latest and greatest devices. A glow effect is easier and can be obtained by adding a bill boarded plane with a transparent texture and additive blending.

pigoto:
If it helps, I just made a glow affect; I'm working on a sort of cloud thing.. which is hard to describe, but at the moment it's a ball of random glowing balls so might be similar to what you're after.

This is an object that glows:


--- Code: ---class CloudParticleGlow extends Object3D {
private static final long serialVersionUID = 1L;
private static Object3D glow = null;
private static float offset = 1.8f;
    private static float zoffset = 0.4f;


CloudParticleGlow(String texture) {
    super(glow);
    glow = new Object3D(2);
glow.addTriangle( new SimpleVector( -offset, -offset, -zoffset ), 0, 0,
                           new SimpleVector( -offset, offset, -zoffset ), 0, 1,
                           new SimpleVector( offset, offset, -zoffset ), 1, 1,
                           TextureManager.getInstance().getTextureID( texture ) );
glow.addTriangle( new SimpleVector( offset, offset, -zoffset ), 1, 1,
                           new SimpleVector( offset, -offset, -zoffset ), 1, 0,
                           new SimpleVector( -offset, -offset, -zoffset ), 0, 0,
                           TextureManager.getInstance().getTextureID( texture ) );
   
glow.setBillboarding(Object3D.BILLBOARDING_ENABLED);
glow.setTransparency(5);
glow.setLighting(Object3D.LIGHTING_NO_LIGHTS);
glow.setAdditionalColor(new RGBColor(255, 255, 255));
glow.build();
  }

}
--- End code ---

This is an invisible "container" that I made the parent of my glow object:


--- Code: ---class CloudParticle extends Object3D {
private static final long serialVersionUID = 1L;
private static Object3D particle = null;

  static {
  particle = Primitives.getCone(0.3f);
  particle.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
  particle.setTransparency(0);
  }

  CloudParticle() {
    super(particle);
  }

}
--- End code ---

I created an array of each, with both arrays the same size; I make each Particle the parent to the equivalent Glow, and I make every first item in the particle array the parent of all other particles:


--- Code: ---particles = new CloudParticle[particleCount];
glow = new CloudParticleGlow[particleCount];

for (int i = 0; i < particleCount; i++) {
String texture = "glowgreen";
switch (rand.nextInt(3)) {
case(0):
texture = "glowred";
break;
case(1):
texture = "glowblue";
break;
case(2):
texture = "gloworange";
break;
}

particles[i] = new CloudParticle();
glow[i] = new CloudParticleGlow(texture);
particles[i].addChild(glow[i]);
world.addObject(particles[i]);
world.addObject(glow[i]);

if (i > 0) {
particles[0].addChild(particles[i]);
}

--- End code ---

I can then rotate or move an individual particle or all to move individual glows, or I can move the central particle to move everything.

This is in progress but I think with the right texture and movement could be expanded for fire / explosion.

[attachment deleted by admin]

Andrey8000:
2 pigoto. It's great, but how about performance when so many objects?

EgonOlsen:
You don't need that many objects to create a simple glow (like the glow of a light source). One plane is sufficient to create something like this:

Navigation

[0] Message Index

[#] Next page

Go to full version