Server application for collaborative production of 3D assets and animations.
(define-module (vfx packages rendering)
  #:use-module (gnu packages)
  #:use-module (gnu packages cmake)
  #:use-module (gnu packages llvm)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages tbb)
  #:use-module (gnu packages vulkan)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages graphics)
  #:use-module (gnu packages opencl)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages image)
  #:use-module (gnu packages image-processing)
  #:use-module (gnu packages xml)
  
  #:use-module (vfx packages base)
  #:use-module (vfx packages opencl)
  #:use-module (vfx packages pixar)
  #:use-module (vfx packages lucasfilm)
  #:use-module (vfx packages nvidia)
   
  #:use-module (guix)
  #:use-module (guix git-download)
  #:use-module (guix build-system cmake)
  #:use-module ((guix licenses) #:prefix licenses:))

(define-public radeonprorender
  (package
    (name "radeonprorender")
    (version "2.3.5")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/GPUOpen-LibrariesAndSDKs/RadeonProRenderUSD")
                    (commit "11494e6968065d42cc43feccd8f6c16a77d3b1a8")))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "0v4dkgd2axgj58577vczznsi3vxqbrbbaiqpn2m0psbv2limg4xc"))))
    (build-system cmake-build-system)

    ;; TODO: Fix RadeonProRender
    ;;(arguments
    ;; `(#:phases (modify-phases %standard-phases
    ;;             (add-before 'configure 'remove-cmake-overrides
    ;;                (lambda _
    ;;                  (delete-file "cmake/FindOpenCL.cmake")
    ;;                  #t)))))
    (inputs (list
	      libomp
	      tbb-2020
	      mesa-opencl
	      opencl-headers
	      clew
	      ;;vulkan-headers
	      ;;vulkan-loader
	      ;;shaderc
	      ;;glslang
	      usd
	      materialx
	      openvdb))
    (home-page "https://www.amd.com/en/technologies/radeon-prorender")
    (synopsis "USD compatible physically-based GPU path tracer")
    (description "Fast GPU or CPU accelerated viewport rendering on all
OpenCL 1.2 hardware for the open source USD and Hydra system.")
    (license licenses:asl2.0)))

(define-public gatling
  (package
    (name "gatling")
    (version "0.3.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/pablode/gatling")
                    (commit "d62d022124a46fc2e55ae65a1425102485af1b4f")))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1d0vqdl887ywm9hk75w0h3wfvir2qbk8pfdm8wcb61ka2iz0pf70"))))
    (build-system cmake-build-system)
    (inputs (list
	      vulkan-headers
	      vulkan-loader
	      shaderc
	      glslang
	      mesa
	      usd
	      nvidia-mdl))
    (home-page "https://github.com/pablode/gatling")
    (synopsis "USD compatible GPU path tracer")
    (description "USD Hydra render delegate and standalone renderer that
accepts Universal Scene Description (USD) files. It is cross-platform,
GPU-accelerated, and supports MaterialX, MDL and UsdPreviewSurface materials.")
    (license licenses:gpl3)))

(define-public cycles
  (package
    (name "cycles")
    (version "3.4.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/blender/cycles")
                    (commit "16854e02e0dea1c291c693a9fa782f2907f351c6")))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1q8mg2781xp4ghn06b47g1izs6drqpm7hszsj64999151z9lnh7b"))))
    (build-system cmake-build-system)
    (inputs
     (list
      llvm-15
      clang-15
      boost
      tbb-2020
      libepoxy
      embree
      ;openshadinglanguage-1.12
      openimageio-2.4
      opencolorio-2.2
      openjpeg
      libjpeg-turbo
      libtiff
      libpng
      c-blosc
      openexr-2
      ilmbase
      opensubdiv-3.5
      openvdb-10.0
      zlib
      pugixml))
    (propagated-inputs
     (list usd))
    (arguments
     `(#:tests? #f
       #:configure-flags
       (list "-DWITH_CYCLES_ALEMBIC=OFF"

	     "-DWITH_CYCLES_OPENVDB=ON" ; OpenVDB fails linking:
	     "-DWITH_CYCLES_NANOVDB=OFF" ; ld: /gnu/store/2dqnjd3gk53f0gfrqv6cpzvaqcyw4zwx-openvdb-10.0.1/lib/libopenvdb.so:
					 ; undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'

	     "-DWITH_CYCLES_OSL=OFF" ; OpenShadingLanguage fails linking:
				     ; ld: /gnu/store/hx61w8ys7xn91mmcivnazkjwab64msqs-clang-15.0.6/lib/libclangSema.a(SemaRISCVVectorLookup.cpp.o):
	                             ; undefined reference to symbol '_ZN5clang5RISCV12RVVIntrinsic12getSuffixStrB5cxx11ENS0_9BasicTypeEiN4llvm8ArrayRefINS0_19PrototypeDescriptorEEE'
				     ; ld: /gnu/store/hx61w8ys7xn91mmcivnazkjwab64msqs-clang-15.0.6/lib/libclang-cpp.so.15:
	                             ; error adding symbols: DSO missing from command line

	     "-DWITH_CYCLES_OPENIMAGEDENOISE=OFF"
	     (string-append "-DPXR_ROOT="
                            (assoc-ref %build-inputs "usd")))))
    (home-page "https://www.cycles-renderer.org")
    (synopsis "Open Source Production Rendering")
    (description "Cycles is a physically based production renderer
developed by the Blender project.")
    (license licenses:asl2.0)))