paint.py 917 B

1234567891011121314151617181920212223242526272829303132333435
  1. import sys
  2. sys.path.append('.')
  3. import layerlab as ll
  4. albedo = [0.6, 0.6, 0.6]
  5. eta = 1.5
  6. alpha = 0.25 # Beckmann roughness
  7. # Construct quadrature scheme suitable for the material
  8. n, m = ll.parameterHeuristicMicrofacet(eta = eta, alpha = alpha)
  9. mu, w = ll.quad.gaussLobatto(n)
  10. print("# of nodes = %i, fourier orders = %i" % (n, m))
  11. # Construct coating layer
  12. print("Creating coating layer")
  13. coating = ll.Layer(mu, w, m)
  14. coating.setMicrofacet(eta = eta, alpha = alpha)
  15. output = []
  16. for channel in range(3):
  17. # Construct diffuse bottom layer for each channel
  18. print("Creating diffuse layer")
  19. l = ll.Layer(mu, w, m)
  20. l.setDiffuse(albedo[channel])
  21. # Apply coating
  22. print("Applying coating..")
  23. l.addToTop(coating)
  24. output.append(l)
  25. # .. and write to disk
  26. print("Writing to disk..")
  27. storage = ll.BSDFStorage.fromLayerRGB("paint.bsdf", output[0], output[1], output[2])
  28. storage.close()