Advertisement
yashpolke

vex_codes_volumeWranlge

Nov 15th, 2016
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.23 KB | None | 0 0
  1. Density mult in Y:
  2.  
  3. f@density = chramp("density",f@density);
  4. f@density *= ch('scale');
  5. f@density *= 1.0 - pow(relbbox(v@P).y,ch('falloff'));
  6.  
  7. *********************************************************************************
  8.  
  9. Density mult based in proximity to point:
  10.  
  11. vector lineOfSight = point( 1, "P", i@ptnum );
  12.  
  13. int handle = pcopen( 1, "P", v@P, chf( "radius" ), 1000 );
  14. float dist = pcimportbyidxf( handle, "point.distance", 0 );
  15. pcclose( handle );
  16.  
  17. float condition = ( v@P.y  >= ( chf( "radius" )/ dist + chf( "falloff" ) ) ) ? ( f@density *= pow( clamp( f@density, 0.1,0.3 ) + pow( chf( "fade" ),chf( "exp_padding" ) ), chf( "exp" ) )) : ( f@density = f@density );
  18.  
  19. ***************************************************************************************************************
  20.  
  21. Stamp points:
  22.  
  23. f@density = 0.0f;
  24. f@temperature = 0.0f;
  25.  
  26. vector relVoxel = relbbox(0,v@P);
  27. int pc = pcopen(1,"P",v@P,(ch('voxel_size')/2.0)*1.4143,chi('max_points'));
  28.  
  29. while (pciterate(pc)) {
  30.  
  31.     vector point;
  32.     pcimport(pc,"P",point);
  33.     vector relPoint = relbbox(0,point);
  34.    
  35.     // only stamp points immediately in this voxel
  36.     if (int(relPoint.x * @resx) != int(relVoxel.x * @resx))
  37.         continue;
  38.     if (int(relPoint.y * @resy) != int(relVoxel.y * @resy))
  39.         continue;
  40.     if (int(relPoint.z * @resz) != int(relVoxel.z * @resz))
  41.         continue;
  42.        
  43.     float sample;
  44.     pcimport(pc,"temperature",sample);
  45.     f@temperature += sample;
  46.    
  47.     pcimport(pc,"density",sample);
  48.     f@density += sample;
  49. }
  50.  
  51. //f@temperature /= float(pcnumfound(@ptnum));
  52. //f@density /= float(pcnumfound(@ptnum));
  53. //f@density = clamp(f@density, 0.0f, 1.0f);
  54.  
  55. *************************************************************************************
  56. ***Blur by density***
  57. float fps = 1.0/ch("fps");
  58.  
  59. vector vel = volumesamplev(1, "vel", v@P);
  60. float steps = max(float(ch("steps")), 2);
  61. float d_mult = 1.0/steps;
  62. float s_mult = -d_mult*0.5;
  63. float sum = 0.0;
  64. int i;
  65.  
  66. for(i=0; i<steps; ++i)
  67. {
  68. float d = volumesample(0, "density", v@P - vel*fps*ch("length")*s_mult);
  69. sum += d * d_mult;
  70. s_mult += d_mult;
  71. }
  72.  
  73. f@density = sum;
  74. *************************************************************************************
  75. *************************************************************************************
  76. *************************************************************************************
  77. *************************************************************************************
  78. *************************************************************************************
  79. *************************************************************************************
  80. *************************************************************************************
  81. *************************************************************************************
  82. *************************************************************************************
  83. *************************************************************************************
  84. *************************************************************************************
  85. *************************************************************************************
  86. *************************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement