Improved Sapling test + my NURBS grass improved

First, code used for the grass.

import numpy as npimport bpy,mathutils
from random import random,randrange,getrandbits


def space():
    return randrange(-10000,10000)/100
def randhalf():
    return random()*2-1
ints=bpy.data.objects['hf_x00y00.001']
tree=mathutils.bvhtree.BVHTree.FromObject(ints,bpy.context.scene,render=True, epsilon=0.0001)
for tog in range(3):
    curve = bpy.data.curves.new('ProceduralGrass', 'CURVE')
    curve.dimensions = '3D'
    curve.bevel_depth=.1
    curve.bevel_resolution=1
    curve.resolution_u=2
    curve.twist_mode='TANGENT'
    curve.twist_smooth=.13
    count=0
    for y in np.arange(0,165,.1):
        for x in np.arange(120,240,.1):
            if not getrandbits(10):
                x+=random()
                y+=random()
                rc=tree.ray_cast((x,y,200),(0,0,-1),200.0)
                if rc[0]!=None:
                    #vert.co=rc[0]
                    #vert.normal=rc[1]
                    count+=1
                    place=(*rc[0],1)
                    scale=random()*.1+.1
                    for j in range(randrange(3,13)):
                        x,y,z,w=place
                        spline = curve.splines.new(type='NURBS')
                        spline.points.add(3)
                        spline.points[1].co=(x,y,z,w)
                        spline.points[1].radius=10*scale
                        spline.points[0].co=(x+randhalf()*2*scale,y+randhalf()*2*scale,z-4*scale,10*scale)
                        spline.points[0].radius=30*scale
                        x+=randhalf()*((4+tog)**2)*scale
                        y+=randhalf()*((4+tog)**2)*scale
                        z+=random()*((5-tog)**2)*scale
                        spline.points[2].co=(x,y,z,w)
                        spline.points[2].radius=3*scale
                        x+=randhalf()*((8+tog)**2)*scale
                        y+=randhalf()*((8+tog)**2)*scale
                        z+=random()*((4-tog)**2)*scale
                        spline.points[3].co=(x,y,z,w)
                        spline.points[3].radius=2*scale
    curve_object = bpy.data.objects.new('ProceduralGrass', curve)
    scene = bpy.context.scene
    scene.objects.link(curve_object)
    curve_object.location=ints.location
    print(count)

Second, the render itself. I was trying to keep it simple.


2 Likes

Third, the clay render and the blend file.


https://mega.nz/#!ZnhAXS7S!woaVwhCVg3EB2NtygpuMcRo96tfsbJwo0fqEHPxVYfk

1 Like