Announcement

Collapse
No announcement yet.

accessing parameters inside a shader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • accessing parameters inside a shader

    hi! maybe it's a stupid question, but how do you access a plugin parameter (the "hit surface" plugin) from a shader? let's say i'd like to get the "radius" parameter of a geomParticleSystem from inside a shader, or the "user_float_pp_1" at particle 10 while shading particle 2 ?

    thanks!
    Chervin SHAFAGHI
    CG Supervisor at CGEV, Paris.

  • #2
    You can look at the sources of the TexParticleSampler texture in [vraysdk]\samples\vray_plugins\texures\vray_texparticle\tex _particle.cpp, but generally it would be something like:

    Code:
    VR::AColor getTexColor(const VR::VRayContext &rc) {
    	VRayPerParticleDataInterface *ppd = (VRayPerParticleDataInterface *)GET_INTERFACE(rc.rayresult.si, EXT_VRAY_PER_PARTICLE_DATA);
    	if (ppd) {
    		PerParticleColorTypes type=ppc_user1;
    		return VR::AColor(ppd->getPerParticleColor(rc, type), 1.0f);
    	}
    	return VR::AColor(0.0f, 0.0f, 0.0f, 1.0f);
    	
    }
    or
    Code:
    VR::real getTexFloat(const VR::VRayContext &rc) {
    	VRayPerParticleDataInterface *ppd = (VRayPerParticleDataInterface *)GET_INTERFACE(rc.rayresult.si, EXT_VRAY_PER_PARTICLE_DATA);
    	if (ppd) {
    		PerParticleFloatTypes type=ppf_radius;
    		return ppd->getPerParticleFloat(rc, type);
    	}
    	return 0.0f;
    }
    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      Hi!

      Thanks for the quick answer, maybe my question was not precise enough, but by "radius" i meant the plugin "radius" parameter, not the per particle radius. Also getPerParticleFloat/getPerParticleColor both return the float/color for the "current" particle (the one being shaded), is there a way to get particle 0 float/color while shading particle 10 ?

      thanks!
      Chervin SHAFAGHI
      CG Supervisor at CGEV, Paris.

      Comment


      • #4
        I think you can get all per particle data using the GeomParticleDataInterface

        Code:
        GeomParticleDataInterface * pdata = (GeomParticleDataInterface *)GET_INTERFACE(rc.rayresult.si, EXT_GEOM_PARTICLE_DATA);
        const PerParticleShadeData* pp = pdata ->getPerParticleData();
        I don't think you can access the global radius though.
        V-Ray/PhoenixFD for Maya developer

        Comment


        • #5
          unfortunately, pdata->getPerParticleData() always seems to return NULL
          Chervin SHAFAGHI
          CG Supervisor at CGEV, Paris.

          Comment

          Working...
          X