krid, enjoy your ban. I have warned you again and again.
That was so weird.
@astelix: thanks for your time. Actually I had the same in mind, but the problem here is even if I added smooth transitioning between the textures, it would still not look so good.
I just can’t understand why the alternative billboard effect I add doesn’t work. I tried setBillboardAxis() on a model (quad) and thats exactly what I need. The default one for particles seems to be setBillboardPointEye()…
Particles don’t actually take advantage of the billboard effect; they can’t, because it would be too expensive. The billboard effect that you apply via NodePath would affect all of the geometry under a given node the same way. To apply the billboard effect to a cloud of particles would mean each particle would have to be in its own node!
Instead, particles are rendered using “perspective points”, which is a feature built into your graphics card for exactly this purpose. But because it’s hardcoded into the graphics card, you can’t change its mode, unless you write a custom vertex shader.
David
hey, your samples really look great already.
i allowed myself to upgrade it a little bit.
you can download the new version here:
nemesis13.de/tmp/n13_rain.zip
still it looks very weird when looked from side. the only way to fix that is probably yet another batch of textures for each angle (roll) step. or is there a way to rotate a texture on the fly within panda?
EDIT: found. zip updated
Added more angles, huh?
I was sure there is a way to change the billboard-like effect on particles, because I had heard so many people say they use it for rain, well I guess for limited camera freedom like the cylinder method.
Anyway, adding few more angles make the effect a bit nicer. Untill I can write a shader for the particle rotations I’ll stick to this.
How about adding this to the Code Snippets? I can also post the quad/cylinder rain archive and we can merge it into 1 topic…
Yupp. I made 4 textures for the drops as seen from different pitch angles. I have also done the regular one more stretched and made all particles have more transparency in the particle recipe file. The small trick with rotating UVs fixes the billboard problem for rolling (rotating around the X axis).
By chance you could use only one texture if you manage to squeeze it with changing pitch angle.
Posting this into out snippets section sounds good. It’s simple, yet effective and it’s first of its kind here
What about zooming or moving the camera around? How would you handle that? Moving the emitter along with the cam or with some LOD effects maybe?
Well, I replace
parent.reparentTo(render)
with
parent.reparentTo(base.cam)
parent.setEffect(CompassEffect.make(render))
Got a better idea?
What?
EDIT: Oh, you added an r angle for the rain
Hm, good idea. If I would scale the uvs I could use 1 texture and a do method later task to scale it depending on the pitch each few miliseconds. That would be a lot smoother ( but probably slower)
The disadvantage is that particles farther from the center of the cam should be longer than the ones on the center, unless you use an orthogonal cam…
Is this the cylinder method you guys have been talking about?: mediafire.com/?azrzxyozqof
Hm, yeah, my idea to scale the uv depending on the pitch didn’t really work with your uv roll code:
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.particles.Particles import Particles
from direct.particles.ParticleEffect import ParticleEffect
# set 'sky' colour
base.setBackgroundColor(0.4,0.5,0.8,0)
# just an environment model
env = loader.loadModel('environment')
env.reparentTo(render)
env.setScale(0.02)
env.setPos(0,4,-1)
# parent node to attach the particle effect to
parent = render.attachNewNode('parent')
# parent node and thereby the particle effect will move around with the camera
parent.reparentTo(base.cam)
# but won't rotate with it:
parent.setEffect(CompassEffect.make(render))
parent.setPos(0,0,8)
# enable particles
base.enableParticles()
rain = ParticleEffect()
# set the file to read particle effect settings from
rain.loadConfig(Filename('rain.ptf'))
#Sets particles to birth relative to the parent
rain.start(parent)
# we will need to change some teexturing settings
raintexture = loader.loadTexture("raindrop.png")
ts = TextureStage("ts")
ts.setMode(TextureStage.MReplace)
rain.setTexture(ts, raintexture, 1)
# we will scale the uvs so the raindrop will get shorter depending on the pitch
# textures would repeat by default if we would scale the uvs, so:
raintexture.setWrapU(Texture.WMBorderColor)
raintexture.setWrapV(Texture.WMBorderColor)
raintexture.setBorderColor(VBase4(0, 0, 0, 0))
# a task that will check if the pitch has changed each frame
def setRainDropLenght(task):
p = abs(base.camera.getP())
r = abs(base.camera.getR())
# set the r so it will look like raindrop is always facing the ground
rain.setTexRotate(ts, -r)
if p == 0: # otherwise it wouldn't be visible in this case
rain.setTexScale(ts, 1, 1)
else:
rain.setTexScale(ts, 1, p/10)
print p
return task.cont
taskMgr.add(setRainDropLenght, 'setRainDropLenght', sort=40)
run()