About Store Forum Documentation Contact
Donations:
167$/mo



Post Reply 
Shader Parameters for different Instances
Author Message
b1s Offline
Member

Post: #1
Shader Parameters for different Instances
For somereason when Im trying to reproduce this im not getting the correct effect.

I'm trying to replace particles with meshes and use this for the
alpha value according to single particle current life.

On Create()
PHP Code:
MeshPart &part=mesh.parts.New();
MeshBase &base=part.base;
base.create(*Meshes.ptrRequire("particlePlane.mesh"));
base.setNormals();
customMat =*obj.material(); //Pickup material from params
customMat.validate();
mesh.setMaterial(&customMat);
mesh.setAutoTanBin();
mesh.setRender(); 
mesh.setBox(); 


On Draw()
PHP Code:
REPA(particles)
{
meshMatrix Matrix(0);
meshMatrix Matrix().setPos(particles.p[i].pos);
meshMatrix.setDir(-Cam.matrix.z);
meshMatrix.rotateZVec(Time.time()*particles.p[i].ang_vel);    

meshMatrix.scaleOrn((particles.p[i].life/particles.p[i].life_max)*particles.growth_factor);

SPSet("InstanceAlpha",particles.p[i].lif/particles.p[i].life_max);
    
mesh.draw(meshMatrix,particles.p[i].vel,particles.p[i].ang_vel,false);




What I would hope this would do is to spawn the meshes as 0 alpha and gradually go up to 1 alpha.
But what it does is change all the meshes together as they were just normal instances with normal material.

Can you see what am I doing wrong here?
Cant figure this thing out.
(This post was last modified: 07-12-2011 02:49 PM by b1s.)
07-12-2011 02:48 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Shader Parameters for different Instances
Hi,

Please check the tutorial with "shader parameters for multiple instances" (or similar name)

you need to:
-process rendering in RM_BLEND mode
-call Mesh::drawBlend (not draw)
07-14-2011 12:02 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #3
RE: Shader Parameters for different Instances
Mesh::drawBlend (not draw) ok its this one then..
07-14-2011 03:55 PM
Find all posts by this user Quote this message in a reply
Post Reply