Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

What is noise:setBounds, please

I see John using it, and I'd love to understand what it does. Why would be even better.

Are there plans for more extensive documentation for the craft stuff? Is there some way I could assist with that?

Thanks,

R

Comments

  • dave1707dave1707 Mod
    Posts: 8,193

    @RonJeffries I think the setBounds allows you to set the bounds of the output value. You can set the range to be between a lower and upper value. I know there’s not much documentation on some of the stuff, that’s why you have to write your own test routines to see what happens.

  • Posts: 496

    Good guess. I'm ticking through examples. I hate to think of everyone having to do that. Will be willing to help with docs if I ever learn enough. :)

  • SimeonSimeon Admin Mod
    Posts: 5,202

    @RonJeffries

    I've actually been hosting the Codea documentation on Github for some time

    https://github.com/TwoLivesLeft/Codea-Documentation

    So if you find issues / typos / incorrect info you could log it as an issue there (or if you are feeling more adventurous, just make a pull request with what you think it should be saying)

  • Posts: 496

    thanks, i'll try to do that!

  • Posts: 496

    @john if you have time:

    as i read the voxel terrain example, i see that generation saves chunk:size(), which i would think would be constant. and i see no place where the code uses any position info outside chunk-relative px py pz. i'd expect there would need to be some varying value going into the noise tree to provide different terrain profiles in different chunks.

    can please you help me see where chunk to chunk variability comes from? Thanks!

  • JohnJohn Admin Mod
    Posts: 603

    @RonJeffries - The function chunk:setWithNoise(n) passes the noise tree to the chunk which then runs the noise over every voxel, providing the world-space position of each voxel. The noise evaluates to the specific block type at each of the voxel positions in world-space. The reason for having a noise tree is mainly for performance. You can set each voxel individually in Lua but it would be extremely slow.

    I think you can access the chunk position by using chunk.entity.position although I haven't tested that.

    I'll need to add this method and some others to the documentation.

  • Posts: 1,605
    @John - when you update the documentation could you provide a small example of this feature - sounds like the speed gain would be significant.
  • Posts: 496

    @john thanks! does it pass the current voxel's x,y,z into the root of the noise function, thus scanning from 0 to some large integer?

    it's really a bear getting information out of a function called on threads, but it occurs to me that I can just create some chunks and call the set and see what happens. Maybe I'll do that this morning instead of whatever I formerly had planned, which I've forgotten anyway.

    Thanks ...

  • Posts: 496

    @Bri_G there is a simpler (but still complex) example of using this approach in the on-line documentation in GitHub. I've been playing with making it work ... it no longer does. I'll post it this morning after I get to the coffee shop.

  • Posts: 496

    Arrgh: I was hoping that setWithNoise was a method on volume and that the noise function was able to be emulated by a method. But no. A noise (object?thingie?) is a userdata so there is no way (that I can find) to make a fake one.

    It seems like this stuff is relentlessly holding on to its secrets. I'm not sure at all how to tap in and drag out much information.

    Since noise functions tend to return zero on integer coordinates (sometimes, maybe, not always, often), I was wondering whether the noise function provided to setWithNoise might be called at x.5, y.5, z.5 or something.

    Darned if I can figure out how to get the info one needs if it isn't written down.

    Could read the source code, if I had access to it ...

  • Posts: 1,605
    @RonJeffries - did you get to the coffee shop? need caffeine to boost the brain power? (Know the feeling). If you post your code someone may be able to help.
  • JohnJohn Admin Mod
    Posts: 603

    @RonJeffries - Chunks and Volumes are actually the same thing. Volumes are just attached to a custom entity, while chunks are generated automatically by the voxel terrain system. You can call setWithNoise() on a volume component, and no you can't provide a random function.

    Voxel terrain has voxels.iterateBounds() which lets you quickly call a function for all voxels within a given bounds. volume doesn't have this function, along with the other voxel style/drawing functions, which I suppose is a bit of an oversight/limitation.

    Lib noise uses coherent noise (http://libnoise.sourceforge.net/coherentnoise/index.html). This means that each integer coordinate will always return zero. When noise is applied to chunks, the coordinates are calculated as chunk position / chunk size so that the noise looks ok.

    I'll admit that examples and documentation for voxels are pretty sparse. Part of the reason is just the massive amount of work that Craft involved and the fact that there seemed to be virtually no interest in these features for years, which basically destroyed any motivation for me to continue working on this part of Codea.

  • Posts: 496

    Thanks, John! I can understand that reluctance and, again, I admire the quality (and quantity) of what you have done.

    I'm struggling myself with how far to push on the voxels and general 3D stuff. And it seems like the forum is pretty quiet lately overall. It's a shame, Codea is pretty darn cool.

    I appreciate the above info: I think it fills in the last blanks for me, or most of them.

  • edited March 7 Posts: 496

    @Bri_G as John reports above, what I was trying to do (pass a function to setWithNoise) turns out to be impossible. Noise is a userdata and there's no [practical] way to fake one enough to get a callback. But John's info covers all my current questions. :)

Sign In or Register to comment.