Particle Filling sample scene ?

I was trying to get the particle filling to work and couldn’t achieve any results.

Maybe using a prt from realflow is the problem ? Yet the prt itself rendered nicely.

ri.AttributeBegin() ri.Option( "pointsvolume", "ParticleRadius", 1.0 ) ri.Option( "pointsvolume", "VoxelSpacing", 1.0 ) ri.Option( "pointsvolume", "VoxelSubdivisions", 0 ) ri.Option( "pointsvolume", "Jitter", True ) #the following are used when "Jitter" is True ri.Option( "pointsvolume", "JitteredParticlesPerVoxel", 1 ) ri.Option( "pointsvolume", "RandomSeed", 42 ) ri.Option( "pointsvolume", "NumDistinctRandomValues", 1024 ) ri.Option( "pointsvolume", "WellDistributedJittering", False ) ri.Option( "pointsvolume", "ParticleRadius", 1.0 ) ri.PointsVolume( "particles.prt" ) ri.AttributeEnd()

My sample scene py:

[code]import KrakatoaSR
import random
ri = KrakatoaSR.Ri()

ri.Option( “render”, “DensityPerParticle”, 0.25 )
ri.Option( “render”, “DensityExponent”, -6 )
ri.Option( “render”, “UseEmissionColor”, True )
ri.Option( “render”, “RenderingMethod”, “voxel” )
ri.Option( “render”, “VoxelSize”, 0.05 )
ri.Option( “render”, “VoxelFilterRadius”, 1 )

ri.FrameBegin( 0 )
ri.Format( 1920, 1080, 1.0 )
ri.Display( “render_output2.jpg”, “file”, “rgba” )
ri.Display( “+normal_pass.exr”, “file”, “N” )
ri.Projection( “perspective”, “fov”, 40 )

ri.AttributeBegin()
ri.Transform( 0,0,-1,0, 0,1,0,0, 1,0,0,0, 50,0,0,1 )
ri.LightSource( “directlight”, “mylight”,
“Flux”, (12.5,12.5,12.5),
“DecayExponent”, 0,
“ShadowsEnabled”, True,
“ShadowDensity”, 1.0,
“ShadowMapWidth”, 512,
“UseNearAttenuation”, False,
“UseFarAttenuation”, False,
“NearAttenuationStart”, 0.0,
“NearAttenuationEnd”, 40.0,
“FarAttenuationStart”, 80.0,
“FarAttenuationEnd”, 200.0,
“LightShape”, “round”, ##can also be “square”
“LightAspect”, 1.0,
“InnerRadius”, 43.0,
“OuterRadius”, 80.0
)
ri.AttributeEnd()

ri.Illuminate( “mylight”, True )

move the camera 10 units from the world origin

ri.Transform(
150,0,0,0,
0,100,0,0,
0,0,1,0,
0,0,175,1 )

ri.WorldBegin()

ri.AttributeBegin()
ri.Transform( 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 )
ri.Transform( 1,0,0,0, 0,1,0,0, 0,0,1,0, 1,0,0,1.5 )
ri.Option( “pointsvolume”, “ParticleRadius”, 10.0 )
ri.Option( “pointsvolume”, “VoxelSpacing”, 5.0 )
ri.Option( “pointsvolume”, “VoxelSubdivisions”, 1 )
ri.Option( “pointsvolume”, “Jitter”, True )
#the following are used when “Jitter” is True
ri.Option( “pointsvolume”, “JitteredParticlesPerVoxel”, 50 )
ri.Option( “pointsvolume”, “RandomSeed”, 42 )
ri.Option( “pointsvolume”, “NumDistinctRandomValues”, 1024 )
ri.Option( “pointsvolume”, “WellDistributedJittering”, False )
ri.Option( “pointsvolume”, “ParticleRadius”, 10.0 )
ri.PointsVolume( “circle05.prt” )
ri.AttributeEnd()

ri.WorldEnd()

ri.FrameEnd()
[/code]

This is the part I wanted to use, is there a simple scene .py where I can just insert my own prt file and check it ?

cheers and thanks for the effort !

Tyler

I just want to confirm a few things about your scene setup before I can figure out what the issue is:

For the first thing, can you check to make sure you have your camera set up properly so that it is actually viewing the particles. At the same time, can you check to see if your particles are getting lit by the light specified. Normally this is all taken care of if the scene was generated with an exporter (such as our Maya, Houdini, or 3dsmax exporter). It seems you have hand-coded the scene description, which can be tricky to get right. I’m a little concerned about the scene you gave me because the the camera-to-world transformation you specified seems to have a scale on it (which you can do, but it seems unusual).

The following code is exactly your scene, but it removes the PointsVolume part, and instead just loads the prt file directly. When you say the PRT rendered nicely, does this same setup render for you? If you render this, do the particles show up in the final render? If they do not show up, then the issue probably lies in the scene setup, and not the particle filling itself.

import KrakatoaSR
import random
ri = KrakatoaSR.Ri()

ri.Option( "render", "DensityPerParticle", 0.25 )
ri.Option( "render", "DensityExponent", -6 )
ri.Option( "render", "UseEmissionColor", True )
ri.Option( "render", "RenderingMethod", "voxel" )
ri.Option( "render", "VoxelSize", 0.05 )
ri.Option( "render", "VoxelFilterRadius", 1 )

ri.FrameBegin( 0 )
ri.Format( 1920, 1080, 1.0 )
ri.Display( "render_output2.jpg", "file", "rgba" )
ri.Display( "+normal_pass.exr", "file", "N" )   
ri.Projection( "perspective", "fov", 40 )

ri.AttributeBegin()
ri.Transform( 0,0,-1,0,  0,1,0,0,  1,0,0,0,  50,0,0,1 )
ri.LightSource( "directlight", "mylight",
       "Flux", (12.5,12.5,12.5),
       "DecayExponent", 0,
       "ShadowsEnabled", True,
       "ShadowDensity", 1.0,
       "ShadowMapWidth", 512,
       "UseNearAttenuation", False,
       "UseFarAttenuation", False,
       "NearAttenuationStart", 0.0,
       "NearAttenuationEnd", 40.0,
       "FarAttenuationStart", 80.0,
       "FarAttenuationEnd", 200.0,
       "LightShape", "round",   ##can also be "square"
       "LightAspect", 1.0,
       "InnerRadius", 43.0,
       "OuterRadius", 80.0   
       )
ri.AttributeEnd()

ri.Illuminate( "mylight", True )

# move the camera 10 units from the world origin
ri.Transform(
   150,0,0,0,
   0,100,0,0,
   0,0,1,0,
   0,0,175,1  )

ri.WorldBegin()

ri.AttributeBegin()
ri.Transform( 1,0,0,0,  0,1,0,0,  0,0,1,0,  0,0,0,1 )
ri.Transform( 1,0,0,0,  0,1,0,0,  0,0,1,0,  1,0,0,1.5 )
ri.PointsFile( "circle05.prt" )
ri.AttributeEnd()


ri.WorldEnd()

ri.FrameEnd()

Thank you very much, Conrad for helping me on this.

Yes, the scene renders fine, as you can see, the Camera is a tad far from the particles, but for the filling it should work fine.

So how do I (we) continue ?

I attached the image and the prt.

cheers

Tyler
Circle05.zip (927 KB)

I played around with your scene in an attempt to make it look good. I came up with some settings that demonstrate the particle multiplication effects in Krakatoa. I’ve attached an image of an updated version of your scene. It includes a few changes which I’ve listed below. I also included the scene description below that uses your .PRT file, so you can render this also and play around with it. The attached image has about 15 million particles. Your original particles count was about 13 thousand.

Some notes:

-I found the problem why the particles were disappearing when rendering using the PointsVolume command. Your PRT file has a “Density” channel in it, and that was being ignored when using the PointsVolume call (it’s kind of buggy behaviour, I will look into changing it). Therefore, what I needed to do was increase the density. I increased “DensityPerParticle” from “-6” to “1” and the particles started showing up.

-After that, I tweaked the “pointsvolume” settings. I modified the “ParticleRadius” setting. That setting defines how many units around the original particles the new particles will be seeded. I changed it from “10” (which is very large for your particles) to “0.5”. Using 0.5 seems to be enough to “fill in the gaps” of your existing particles.

-Secondly, I tweaked the “pointsvolume” setting called “VoxelSpacing”. New particle are seeded on a voxel grid around existing particles. The grid size is defined by this “VoxelSpacing” parameter. So the lower the value, the tighter the particles will be packed. I changed it from “5” to “0.05”. This parameter needs to be smaller than the “ParticleRadius” parameter to look good.

The attached image was generated from this scene. Tweak the lines marked “tweak this” and you can change it to however you want it to look:

import KrakatoaSR
import random
ri = KrakatoaSR.Ri()

ri.Option( "render", "DensityPerParticle", 0.25 )  #tweak this
ri.Option( "render", "DensityExponent", 1 )  #tweak this
ri.Option( "render", "RenderingMethod", "particle" )

ri.FrameBegin( 0 )
ri.Format( 1920, 1080, 1.0 )
ri.Display( "Circle05.exr", "file", "rgba" )
ri.Display( "+Circle05Normals.exr", "file", "N" )
ri.Projection( "perspective", "fov", 40 )

ri.Transform( 1.0,0.0,0.0,0,  0.0,1.0,0.0,0,  0.0,0.0,-1.0,0,  0,45.0,150.0,1 )

ri.WorldBegin()

ri.AttributeBegin()
ri.Transform( 0.707,0.0,-0.707,0,  0.0,1.0,0.0,0,  0.707,0.0,0.707,0,  100.0,-50.0,100.0,1 )
ri.LightSource( "directlight", "mylight",
	"Flux", (12.5,12.5,12.5),
	"DecayExponent", 0,
	"ShadowsEnabled", True,
	"ShadowDensity", 1.0,
	"ShadowMapWidth", 512,
	"UseNearAttenuation", False,
	"UseFarAttenuation", False,
	"NearAttenuationStart", 0.0,
	"NearAttenuationEnd", 40.0,
	"FarAttenuationStart", 80.0,
	"FarAttenuationEnd", 200.0,
	"LightShape", "round",
	"LightAspect", 1.0,
	"InnerRadius", 43.0,
	"OuterRadius", 80.0   
)
ri.AttributeEnd()

ri.Illuminate( "mylight", True )


ri.AttributeBegin()

#ri.Option( "channels", "DefaultColor", (0.6,0.894118,0.721569) )
ri.Transform( 1.0,0.0,0.0,0,  0.0,1.0,0.0,0,  0.0,0.0,1.0,0,  0.0,0.0,0.0,1 )


ri.Option( "pointsvolume", "VoxelSpacing", 0.05 )  #tweak this
ri.Option( "pointsvolume", "VoxelSubdivisions", 0 )
ri.Option( "pointsvolume", "Jitter", True )
ri.Option( "pointsvolume", "JitteredParticlesPerVoxel", 1 )
ri.Option( "pointsvolume", "RandomSeed", 42 )
ri.Option( "pointsvolume", "NumDistinctRandomValues", 1024 )
ri.Option( "pointsvolume", "WellDistributedJittering", False )
ri.Option( "pointsvolume", "ParticleRadius", 0.5 )  #tweak this

ri.PointsVolume( "Circle05.prt" )

ri.AttributeEnd()


ri.WorldEnd()

ri.FrameEnd()

Wow, now thats really reassuring.
Looks incredible. I guess, for an animation I also have to use the “well distribution” ?

Thank you for the time and efforts, this is what I expected from Krakatoa!

Will start to play around and keep you updated.

Cheers

Tyler

Not necessarily.
Random particles are distributed in the voxels based on a random seed and the coordinates of the voxel, so the same voxel will always produce the same distribution over time, regardless of the “well distributed” option. Only changing the random seed would change the pattern.

The Well Distributed option ensures that there will be no accidental clumpings of particles due to the random nature of the distribution, and that the random pattern in each voxel will be tileable, avoiding overlapping at the borders between the voxels. Multiple pre-calculated tileable patterns with N particles each (where N is defined by “NumDistinctRandomValues”) will be precalculated, and this allows you to create up to that number of random particles per voxel with well-controlled spacing. The pre-calculations involved in this method can make it a bit slower.

When Well Distributed is off, N particles (number controlled by “JitteredParticlesPerVoxel”) will be seeded in each voxel randomly. This is faster, but there is some probability that two or more particles might land very close to each-other, while other areas of the volume could get none. But statistically speaking, especially with high particle counts, it might not be very obvious. Unless you see undesired clumping, you can keep the option off to shave off a little render time.

In your case, each voxel gets just one particle, placed somewhere randomly inside the voxel. And as you can see, it looks pretty sweet. And if you animate the particles, the distribution within the same voxel will always remain the same, so there will be no flickering. Depending on the particle count, this could be either desired or not. In some cases, for example when trying to visualize the random nature of foam, you might want to cycle the RandomSeed between frames to force the distribution to change over time.
This can be seen at the bottom of the following Krakatoa MX example that uses a RealFlow simulation and the Frost particle mesher to achieve a similar result (since KMX does not provide the built-in internal particle multiplication of KSR yet):
thinkboxsoftware.com/krakato … -and-frost
Before we animated the random seed, the random pattern stood still and the water moved through it, which looked very wrong.

Hope this helps.

This helps me great deal, Bobo! Now I understand the settings and approach much better.

I thought the frost/krakatoa combination maybe was an alternative to the extra particle generation.

But now I see, that Krakatoa SR is indeed superior to the MX solution, right ?

Thank you for the deeper explanations. Looking forward to a complete manual/reference guide;)

Cheers

Tyler

I would say that the results are quire comparable, but the KMX solution involves jumping through hoops and costs a lot more - KMX is $1000 and Frost is $495 more. It involves the conversion of particles to a mesh, then the mesh into a level set, while KSR just jumps right to it and skips the intermediate step, which is bound to be faster, too. The KMX+Frost approach was the inspiration and I suspect it might become part of a future Krakatoa MX version…

I hear you about the docs. Stay tuned!

I never doubted the quality of the results.
Good to know though, that SR skips these steps. Will take enough time to code/develop the exporter for C4D alone.
Good that frost isnt mandatory for the particle cloning.

Awesome, I will wait patiently…

Out of curiosity.

Will it be possible in future releases of Krakatoa SR to use RealFlow bin files instead of prt files for the particle filling ?

Is there a major difference between the infos channels that are needed/used for this procedure that prt can contain and bin cannot ?

cheers

Tyler

So what about if we want to skip the particles entirely and just supply the level set / voxels with the channels we need assigned?

We are discussing this as a future possibility. Obviously it is not possible yet.

Have you tried loading BIN files directly? I would expect them to work, unless the Density channel is saved as 0.0 (I think it happens in some Hybrido-resimulated particles when trying to produce vorticity) since “Density” has a different meaning in RF and Krakatoa. It might be better to use PRT files saved out of RealFlow 2012 since you can uncheck the Density channel in the PRT saving options.
But we support loading of BIN files in Krakatoa MX and according to our documentation we support loading them in Krakatoa SR, too, I just haven’t tried recently.
Give it a try and let us know whether it works or not.

The BIN files contain the major channels like Position and Velocity that KSR needs, but also a lot of internal data the is not needed for rendering. On top of that, BIN files are not compressed, so they tend to be quite large. Saving just Position and Velocity as compressed PRT will save you a lot of disk space. Unless you already have the BIN files anyway and don’t want to duplicate the data…

Thanks for the clarification, Bobo.

Unfortunately the bin format is only supported for normal particle loading.

I tried loading bin files as pointsvolume and the error returned not supported, so at the moment only prt and obj is working.

Maybe this can be changed in a future update, if theres no technical limit ?

Cheers

Tyler

You should be able to use .bin files for particle filling. Is it not working for you?

C:\Krakatoa>sample_scene5.py Traceback (most recent call last): File "C:\Krakatoa\sample_scene5.py", line 61, in <module> ri.PointsVolume( "Circle05.bin" ) RuntimeError: load_mesh_file: Didn't recognize the file format of the input mesh file "Circle05.bin"

This is what I get with the bin file thats also posted as prt in this thread.

uglykids.org/ref/sample_scene5.zip (includes the particle bin file)

Any ideas ?

Thanks in advance
sample_scene5.zip (842 Bytes)

Turns out there was a bug in the code. Thank you for pointing that out! It should be all fixed now. The sample scene you gave me now renders.

Attached is a new Windows version of KrakatoaSR.pyd that has the fix. It is not a proper release, so I don’t want to put it in the “Builds” section, but the next official build will include the fix.
KrakatoaSR_Windows_PointsVolumeBugFix.zip (3.29 MB)

Thank you very much, Conrad. I will test this thoroughly later… :slight_smile:

The attached scene from the thread above creates a memory leak on my machine, not rendering and using 24 GB of ram, any ideas `?

I only replaced the fixed pyd file.

There’s no memory leak here… it’s just that the scene you gave me is attempting to create almost 200 million particles. Which is a few too many :slight_smile:
You will need to adjust your “VoxelSpacing” setting. Currently it is set to “0.05”.

For this particular scene, I ran some tests and this is what I came up with (values are approximate):
0.5 VoxelSpacing - 205,000 particles
0.25 VoxelSpacing - 1,600,000 particles
0.175 VoxelSpacing - 4,664,723 particles
0.0875 VoxelSpacing - 37,317,784 particles

0.05 VoxelSpacing - 198,648,000 (too many!)

I’d recommend starting with VoxelSpacing=0.5 and halfing it until it looks good. Keep in mind, the particle count will go up exponentially to the VoxelSpacing parameter.