Page 1 of 12 12311 ... LastLast
Results 1 to 20 of 230
  1. #1

    Rock generator script

    *** Script is now in Blender contrib. Latest version can now be found at https://developer.blender.org/diffus...dd_mesh_rocks/ ***

    Edit: Link to just the script: Script is now a module: http://www.mediafire.com/file/9bmlds..._rock_mesh.zip
    Link to the x64 NumPy build used: http://www.mediafire.com/file/y6x7xd.../numpy-x64.zip
    Link to an x86 NumPy build that should work: http://www.mediafire.com/file/6c6y56.../numpy-x86.zip

    Edit 2: PDF manual: http://www.mediafire.com/file/28x2o0...7/rock_doc.pdf

    Edit 3: I have a version of the script that does not use NumPy available; No longer needed.

    Edit 4: I have been building an archive of all past versions, so if you really want to use one of those, they are available: http://www.mediafire.com/?ca1nt2zag1ipz

    Edit 5: Due to internal restructuring and morphing the script into a full Python module, I have removed some links that are no longer relevant.

    Hey all,

    Over the past couple weeks or so I have been getting my feet wet in Python and the Blender API. This was mainly spurred because of a project I started that is going to require me modeling a couple hundred rocks, and I figured this was a great opportunity to pick up some Python and the Blender API, though it is admittedly the Rube Goldberg approach. So as a result I started a rock generation script that (when finished) will generated rocks based on some user input, use modifiers for deformation, and then generate a material and procedural textures for each. At this point in time, the first two parts are mostly finished with the last not even started.

    The script relies heavily on random value generation, right now it is primarily Gaussian based with an artificial skew allowed afterward. I would like to eventually replace this with a beta distribution for better results and better performance, but right now I have not yet figured out how to implement the bounds that are on the mean and variance to get valid alpha and beta values.

    What the script does is it will generate a number of rocks, per user specification. Then using a user specified lower and upper bound for x, y, and z dimensions individually, in addition to the skew of the distribution (will be mean with the beta distribution) it will generate a hexahendron for the mesh. Once this is done, it will add 2 subsurf modifiers and 2 displacement modifiers. The level of the subsurf's is based on the user setting the "detail" of the rock. The displacement modifiers are given a new random texture (in progress) and the strength of the displacement is randomly assigned based on a given user mean.

    Some other random notes:
    Currently I am not allowing over 1024 rocks to be generated, but that number will increase.
    Use small values for the roughness. Large values produce some . . . interesting . . . results.
    I would like to multi-thread the script as it should multi-thread very well, but seeing as I don't know parallel programming and don't have the time to learn for quite some time, that is not happening unless some else would like to pick this up and help.

    Link to download: http://www.mediafire.com/file/6cn236..._rock_mesh.zip

    Credit to where it's due. The process/concept is not entirely my own. This is based on a BlenderGuru tutorial: http://www.blenderguru.com/how-to-ma...stic-asteroid/

    Important:
    Because of performance concerns, this script uses NumPy for the random generator. I have included a 64-bit build of NumPy with the script, but if you are using a 32-bit build of Blender you will need to grab this yourself. Installation is fairly easy, but if you need help, let me know. I can help. I realize this is probably an annoyance, but I went and profiled python's built in beta and Gaussian number generators against those in NumPy before deciding that they were going to be used in the script, and I found the NumPy generators to generally be at least 10x faster for the beta and 2x for the Gaussian, with the NumPy beta being fastest, followed by the NumPy Gaussian, Python Gaussian, and far in last the Python beta.

    Most of my work in profiling the distributions and calculations to date for creating the skewed distributions can be found at http://www.mediafire.com/file/tavs5c...20Research.zip. If you would run the python script and let me know the results and the specs of your machine, I would appreciate it. It might just be that I am getting unique results and if so I would rather adopt a method that better reflects most machines.

    Ok, this keeps getting longer so I better post this before I add something else . . .
    Last edited by BrikBot; 06-Oct-14 at 06:38. Reason: Updated links
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  2. #2
    Member Meta-Androcto's Avatar
    Join Date
    Aug 2006
    Location
    australia
    Posts
    4,045
    hi, on win64 I am getting errors with this script.
    I needed to move numpy to the addons/modules folder, that fixed 1 error.
    then this section gives me trouble.
    Code:
        if texture.type = 'CLOUDS':
            
        elif texture.type = 'MUSGRAVE':
    
        elif texture.type = 'DISTORTER_NOISE':
    
        elif texture.type = 'STUCCI':
    
        elif texture.type = 'VORONOI':
    if i change the first line of error to >

    if texture.type == 'CLOUDS':
    that error is fixed but leads to more.
    thanks I hope to get it working.



  3. #3
    Member JayDez's Avatar
    Join Date
    Sep 2009
    Location
    The cold north
    Posts
    586
    The problem with the code that meta-androcto has posted (if that is the only code) is that 1) you are using an assignment operator instead of a comparing one. All of them should use '==' instead of '='. Also if there is no code in between each 'elif' then the script will not run either. You must put something there. (although I'm guessing that you have and Meta only decided to post some of it...)



  4. #4
    Sorry about that . . . I did a dumb one. I zipped before I saved
    Here's the script as it was supposed to uploaded: http://www.mediafire.com/file/vgecmd..._mesh_rocks.py

    That should run without issues.

    Originally Posted by JayDez View Post
    You must put something there. (although I'm guessing that you have and Meta only decided to post some of it...)
    Unfortunately, that version really did not have anything there. Yeah, I seriously got this off to a great start. . . . *facepalm*
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  5. #5
    Member JayDez's Avatar
    Join Date
    Sep 2009
    Location
    The cold north
    Posts
    586
    I couldn't actually the test the script, but from what I can see it should work great. Looks good (nice long descriptive comments too!).



  6. #6
    Member PKHG's Avatar
    Join Date
    Sep 2009
    Location
    NL
    Posts
    1,928
    I replaced random form numpy by
    import random ... (together with "vor der Hand liegenden" changes)
    And got this nice example: rocks1.jpg
    Last edited by PKHG; 26-Apr-11 at 06:01. Reason: changes added



  7. #7
    Originally Posted by PKHG View Post
    I replaced random form numpy by
    import random ... (together with "vor der Hand liegenden" changes)
    And got this nice example:
    rocks1.jpg
    So what were those other changes? Just to fix the call difference between NumPy's (random.normal) and Python's (random.gauss) generators? I'm curious now

    Ok, so there seems to be a little confusion on installing NumPy so that Blender can use it, and I am probably partially to blame since I have not really explained it. You will need to place it somewhere where Blender will find it. There a couple such places but the best is in the the modules folder in Blender's installation directory. On a Windos OS this would default to "C:\Program Files\Blender Foundation\Blender\2.57\scripts\modules\". If you installed Blender somewhere else then you will need to track down the appropriate folder. The unzipped folder will need to be called "numpy" and inside the numpy folder will be a bunch of folders and python files. This folder is what you place it in the modules folder. The next time you start Blender afterwards it should find the package.

    I have now tested the x86 distribution an it does work, so feel free to contact me if you have issues so we can get it working.

    Now for a small update (but no new script right now). I have added the ability to add a smooth modifier (basically to create a water worn appearance). As a test I set it to generate 100 rocks with most of the other parameters changed a little and did a render (I will post tonight once I'm back at my laptop). In the process I think I need to allow the user to use a lower view detail level than the render, so I will add that in sometime tonight. Assuming I don't break anything in the process and the Internet here plays nice I will have an updated script up. . . .
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  8. #8
    Member PKHG's Avatar
    Join Date
    Sep 2009
    Location
    NL
    Posts
    1,928
    I replaced normal by gauss and integer_random by intrand (or so)
    You can find out easily by using : import random in place of numpy things.

    With respect to numpy (and scipy), as fare as I now one needs the for Python 3.2 compiled *.dll (or so) not only the python def's as you gave it in the *.zip (for me 32).



  9. #9
    Originally Posted by PKHG View Post
    I replaced normal by gauss and integer_random by intrand (or so)
    You can find out easily by using : import random in place of numpy things.
    That's what I thought, but figured I'd ask anyway. Thanks!

    Originally Posted by PKHG View Post
    With respect to numpy (and scipy), as fare as I now one needs the for Python 3.2 compiled *.dll (or so) not only the python def's as you gave it in the *.zip (for me 32).
    Just dropping the extracted folder in should work, as I have done so on a Win7 virtual machine and earlier today my netbook (both x86) and neither have Python or NumPy formally installed and it worked in both. If there is an issue I would like to know though since if enough people are having issues with NumPy then I may go ahead an use Python's random even though it is slower. Working/usable code comes before fast code.

    Originally Posted by JayDez View Post
    I couldn't actually the test the script, but from what I can see it should work great. Looks good (nice long descriptive comments too!).
    Thanks! Can you tell that undocumented code annoys me to no end?

    Ok, I have updated the both the .zip with the script and the .py file. Changes from the last version is I added some smooth options and tweaked the displacement textures a little and with it have notices two things. First, I think I "pseudo-broke" the texture generator by adding scaling and a little randomness to the scaling on the displacement textures as I am getting some really high scaling values occasionally that I should not be getting. I am going to add an option for the user to control the scaling, but that is for the future. Second, having probably generated 1000+ rocks at this point testing each little addition to the code, I seem to be noticing that Musgrave based textures create some strange results. Right now I am not going to do anything about it, but thought I'd give a heads up.

    Thanks for the feedback to date. Looking forward to more.
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  10. #10
    A small-ish update. I added a second mesh that can be generated (with two more on the way), though the generation parameters need a lot of tweaking still. Also, I have added another displacement modifier which is basically a duplicate to the first displacement. It simply adds some more depth and roughness to the rocks. Finally, I completely re-thought how I was doing the displacement textures scaling. I now have the script changing the scale of the entire object and the texture will scale with it. The downside is that if you make a stretched rock, the textures also stretch.

    I updated the links to the .zip and the .py that are in my first post to point to the latest of each.
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  11. #11
    Member Meta-Androcto's Avatar
    Join Date
    Aug 2006
    Location
    australia
    Posts
    4,045
    hi,
    would you be interested in joining here: http://projects.blender.org/projects/bf-extensions/
    It would be great to get your script in upload then when it's stable, move it forward to Contrib scripts in our svn.
    You can read more here: http://wiki.blender.org/index.php/Dev:Py/Sharing
    If you have any questions, drop in to irc freenode #blenderpython & say hi
    or you can pm me here.
    thanks, no real problems putting your script through it's tests.
    thanks.



  12. #12
    Member
    Join Date
    Mar 2006
    Location
    none
    Posts
    977
    hi BrikBot,

    http://saschahenrichs.blogspot.com/2...odeling-1.html

    this tutorial(for 3dsmax) uses voronoi texture as displacement to make a sharp edged rock.maybe interesting for you.



  13. #13
    Originally Posted by Meta-Androcto View Post
    hi,
    would you be interested in joining here: http://projects.blender.org/projects/bf-extensions/
    It would be great to get your script in upload then when it's stable, move it forward to Contrib scripts in our svn.
    You can read more here: http://wiki.blender.org/index.php/Dev:Py/Sharing
    If you have any questions, drop in to irc freenode #blenderpython & say hi
    or you can pm me here.
    thanks, no real problems putting your script through it's tests.
    thanks.
    Thanks for the feedback, and I would be honored to do so

    Originally Posted by rusted View Post
    hi BrikBot,

    http://saschahenrichs.blogspot.com/2...odeling-1.html

    this tutorial(for 3dsmax) uses voronoi texture as displacement to make a sharp edged rock.maybe interesting for you.
    Thanks so much for the link! I have been trying to get that exact effect with a Musgrave and was being . . . less than successful. I adjusted the first displacement and the order of the modifiers for a much much better result.

    Beyond that, I have started laying the ground work for generating materials for the rocks (no materials are generated or added right now), and I have added two more meshes. I found a couple nasty bugs in the vert location generation (not critical, but made some ugly meshes) for two of the meshes, which I have fixed. Finally, I have continued to tweak the generated values for the textures. Links in first post have been updated.

    If you have any ideas for a mesh that has eight +/- two verts, I would be happy to see if I can incorporate it as another mesh option. Currently I have a total of four meshes, but have constrained them to exactly eight verts. If you do dream some up, remember to keep the vert count low because of the subsurf modifiers that are applied and then upload the .blend. I can code the meshes from there.

    Both rock generations attached used the default values, though the second I set the upper end of the size on all dimensions to 2. The material was one I quickly tweaked from the default (nothing fancy).
    Attached Images Attached Images
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  14. #14
    there is no panel for parameters yet for this !

    are you planning to add one may be to get don't know like size and proportions may be

    don't understand your questions mesh that has eight +/- two verts,
    get the bound height may be ?
    or max X ect..

    can you re give an example for this ?



    nice work
    i like the latest stones looks quit good

    you also have another texture which can be use to do rock the planet texture
    which can make nice rocks too
    have you seen this one ?

    also in branch render SVN there is the micro displacement that can be use and don't use a alot of vertices !


    happy 2.5
    Nice 3D models = 25 % K.I.S.S + 25 % common sense + 25 % Inspiration + 25 % Knowledge
    Win 10 64 bits / Thanks and a Happy 2.79 with Cycles



  15. #15
    Originally Posted by RickyBlender View Post
    there is no panel for parameters yet for this !

    are you planning to add one may be to get don't know like size and proportions may be

    don't understand your questions mesh that has eight +/- two verts,
    get the bound height may be ?
    or max X ect..
    I think we have a little confusion here. To keep the script simpler, I am hard coding in meshes with the actual location/scale of the resulting shape being determined by a min and max for the X/Y/Z axises that the user specifies. The code then randomly chooses one of the meshes for each individual rock which adds some additional variety to the resulting rocks. Right now I have hard coded in the meshes that you will find in the attached .blend file. I would like to start getting materials generated, and for now the four meshes are sufficient (I will add more later). So for now I am not going to be creating new meshes but if someone comes up with a good new mesh I will certainly add it in. All I need is a .blend file with the mesh so I can plan out the verts and faces before I code them.

    For the materials, no, there is no box for the material settings yet. I have only started setting up the backend that will actually generate the materials and will add the front end when most of the backend is finished. I don't want to give access to code that is not yet functional as that will cause the script to crash and be unusable.

    Originally Posted by RickyBlender View Post
    can you re give an example for this ?
    See attached .blend of what I am talking about for each mesh. If you add up the number of verts in each mesh, you find that each has exactly 8 verts.

    Originally Posted by RickyBlender View Post
    nice work
    i like the latest stones looks quit good

    you also have another texture which can be use to do rock the planet texture
    which can make nice rocks too
    have you seen this one ?
    I believe you are talking about the materials I used in the two test renders I posted. Those are in no way representative of what you'll get, since I seriously only adjusted the spec and diffuse so they did not look plastic (I did not change any colors, nor did I add textures). However, I am open to ideas and feedback so if you have an example, please show it. I will gladly do my best to incorporate them.

    Originally Posted by RickyBlender View Post
    also in branch render SVN there is the micro displacement that can be use and don't use a alot of vertices !
    I am not familiar with this. Do you have any links that I can go look at?
    Attached Files Attached Files
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  16. #16
    for the micro displacement this is an old feature in render branch
    which may help get better texture

    but you can get the latest render branch form graphical org
    and check out on web for video on this feature or Fox dog i think did some video on this and shows this feature

    but also check out the other grapical org built you mightnfind one with the planet texture



    Planet texture / Volume texturing for stones
    http://farsthary.wordpress.com/2010/...-and-cartoons/
    New built for vista
    http://www.graphicall.org/builds/bui...n=show&id=1650

    now this one is old but can show you this feature
    Nice 3D models = 25 % K.I.S.S + 25 % common sense + 25 % Inspiration + 25 % Knowledge
    Win 10 64 bits / Thanks and a Happy 2.79 with Cycles



  17. #17
    The planet texture looks really interesting. Whether or not I'll use it, I don't know yet. I would like to minimize the number of external requirements, and that would add a second. At the same time, it looks like it would produce some fantastic looking results. I'll have to play with it some first.

    For the micropoly displacement textures, it sounds great and the two examples I have seen of it look pretty good. Problem is that I can't find any sign of it otherwise. I think they might have dropped it (at least for now). So if someone else comes across it, I would like to know.
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  18. #18
    Member Meta-Androcto's Avatar
    Join Date
    Aug 2006
    Location
    australia
    Posts
    4,045
    BrikBot,
    I would noy worry about textures, especially not patches that may/may not get into Blender considering the Render refactor.
    This type of dependency is not recommended at all.
    Numpy, on the other hand, is cool.
    Thanks.



  19. #19
    Will do then, meta! Heh, makes my life a little easier. . . .

    So just a quick clarification question: what are the rough requirements for an acceptable external dependency? I don't plan or want to add anything beyond NumPy, but it would be nice to know just in case or possibly for a future project.
    Blog: tumblr blog <-> posterous blog
    Videos: Vimeo <-> YouTube



  20. #20
    Member Evil Moon MOose's Avatar
    Join Date
    Feb 2011
    Location
    Copperas Cove Texas
    Posts
    1,953
    I like the newer one, is the download link updated for the newer rocks? as they look much better than that clowdy, very odd rock setup in the first picture
    View my portfolio here... My Portfolio
    Sackboy Animation! Check it out!
    By the way, I have a god complex....and blender only helps it....



Page 1 of 12 12311 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •