Results 1 to 11 of 11
  1. #1
    Member Richcolburn's Avatar
    Join Date
    Aug 2009
    Location
    Secret lab at the bottom of the Marianas Trench
    Posts
    288

    New tutorial series on Numpy for Blender

    When I spoke at the Blender conference on creating an interactive cloth engine using python, I was surprised how many people knew nothing about Numpy. I've started to share some of the amazing things you can do with it inside of blender. Numpy lets you do things with python that can sometimes outperform comparable c code. Basic operations with Numpy are between 20 and 1000 times faster than typical python looping on big data. The code is also very clean and succinct.

    I have four videos so far and I'm making more.
    No commercials! No paying. Just sharing with the blender community as they've shared so much with me!

    https://www.youtube.com/watch?v=rE6X..._v4uqCh0f93tax
    The 3D Advantage



  2. #2
    Thanks for this. I've used Numpy in some of my code, but felt I didn't understand it enough to use it consistently, or know when using it would be beneficial.
    "Yeah, well, some people meditate, some people get massages. I blend." -Will Smith in Enemy of the State
    AddOn:MatCap Pro



  3. #3
    Really cool of you doing this. Numpy is really the secret sauce you want if you're doing Blender addons. It enables you to make so much more.
    Last edited by ambi; 12-Jan-18 at 15:22.
    CG enthusiast. Tools: Blender - Substance - Unity3D



  4. #4
    Member Secrop's Avatar
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    2,075
    @Richcolburn, that is a very nice reference to have! thanks for it!



  5. #5
    thanks for sharing

    would it be possible to make a video showing how to install Scy pi too!

    and if possible open up a thread to give some scripts example using Numpy and Scipy


    thanks
    happy bl
    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



  6. #6
    @RickyBlender: Just install normal Python 3.5 with Scipy, then delete or rename Blenders Python folder.
    CG enthusiast. Tools: Blender - Substance - Unity3D



  7. #7
    will test that
    but is python 3.5 the latest python ver or earlier then latest one !

    https://www.python.org/downloads/release/python-350/
    this does not have numpy ?

    got a specific link for 3.5 with numpy and scipy ?


    thanks
    happy bl
    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



  8. #8
    Member Richcolburn's Avatar
    Join Date
    Aug 2009
    Location
    Secret lab at the bottom of the Marianas Trench
    Posts
    288
    I made a demo of the modeling cloth tool if anyone is interested in it's current features.
    https://blenderartists.org/forum/sho...60#post3275660
    The 3D Advantage



  9. #9
    Member Richcolburn's Avatar
    Join Date
    Aug 2009
    Location
    Secret lab at the bottom of the Marianas Trench
    Posts
    288
    Posted a couple of new videos in the series https://www.youtube.com/watch?v=rE6X..._v4uqCh0f93tax
    The 3D Advantage



  10. #10
    I've been working on updating my code to use numpy and foreach for better performance, but have hit a snag. Any idea why this simplified version of setting uv images with foreach_set doesn't work?

    Code:
    # get the active object and its UV
    ob = bpy.context.scene.objects.active
    uv = ob.data.uv_textures.active
    
    # use the first loaded image for example
    img = bpy.data.images[0]
    
    # apply the image with a slow for loop (works)
    for data in uv.data:
        data.image = img
    
    # apply the image with fast C loop (doesnt work)
    uv.data.foreach_set('image', [img] * len(uv.data))



  11. #11
    Member Richcolburn's Avatar
    Join Date
    Aug 2009
    Location
    Secret lab at the bottom of the Marianas Trench
    Posts
    288
    Originally Posted by Greatness7 View Post
    I've been working on updating my code to use numpy and foreach for better performance, but have hit a snag. Any idea why this simplified version of setting uv images with foreach_set doesn't work?

    Code:
    # get the active object and its UV
    ob = bpy.context.scene.objects.active
    uv = ob.data.uv_textures.active
    
    # use the first loaded image for example
    img = bpy.data.images[0]
    
    # apply the image with a slow for loop (works)
    for data in uv.data:
        data.image = img
    
    # apply the image with fast C loop (doesnt work)
    uv.data.foreach_set('image', [img] * len(uv.data))
    I'm not sure if there is a way to write an array full of objects to a blender collection. I don't think I've ever gotten an array of images to work with foreach_set or foreach_get. I'll look into it some more but if you find a solution let me know. So far I've only gotten it to work with bool, float, and int types. An image is an object with attributes. Maybe to use foreach_set for the image you just need an index array. Not sure. I couldn't get it to work either.
    The 3D Advantage



Posting Permissions

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