Class IndirectLight.Builder

  • Enclosing class:
    IndirectLight

    public static class IndirectLight.Builder
    extends java.lang.Object
    Use Builder to construct an IndirectLight object instance.
    • Constructor Detail

      • Builder

        public Builder()
        Use Builder to construct an IndirectLight object instance.
    • Method Detail

      • reflections

        @NonNull
        public IndirectLight.Builder reflections​(@NonNull
                                                 Texture cubemap)
        Set the reflections cubemap mipmap chain.
        Parameters:
        cubemap - A mip-mapped cubemap generated by cmgen. Each cubemap level encodes the irradiance for a roughness level.
        Returns:
        This Builder, for chaining calls.
      • irradiance

        @NonNull
        public IndirectLight.Builder irradiance​(@IntRange(from=1L,to=3L)
                                                int bands,
                                                @NonNull
                                                float[] sh)
        Sets the irradiance as Spherical Harmonics.

        The irradiance coefficients must be pre-convolved by < n &sdot l > and pre-multiplied by the Lambertian diffuse BRDF 1/&pi and specified as Spherical Harmonics coefficients.

        Additionally, these Spherical Harmonics coefficients must be pre-scaled by the reconstruction factors Al,m.

        The final coefficients can be generated using the cmgen tool.

        The index in the sh array is given by:
        index(l, m) = 3 × (l * (l + 1) + m)
        sh[index(l,m) + 0] = LRl,m × 1/&pi × Al,m × Cl
        sh[index(l,m) + 1] = LGl,m × 1/&pi × Al,m × Cl
        sh[index(l,m) + 2] = LBl,m × 1/&pi × Al,m × Cl

        index l m Al,m Cl 1/&pi × Al,m × Cl
        00 0 0.2820953.1415926 0.282095
        11-1-0.4886022.0943951-0.325735
        21 0 0.4886022.0943951 0.325735
        31 1-0.4886022.0943951-0.325735
        42-2 1.0925480.785398 0.273137
        52-1-1.0925480.785398 -0.273137
        62 0 0.3153920.785398 0.078848
        72 1-1.0925480.785398 -0.273137
        82 2 0.5462740.785398 0.136569

        Only 1, 2 or 3 bands are allowed.

        Because the coefficients are pre-scaled, sh[0] is the environment's average irradiance.

        Parameters:
        bands - Number of spherical harmonics bands. Must be 1, 2 or 3.
        sh - Array containing the spherical harmonics coefficients. The size of the array must be 3 × bands2 (i.e. 1, 4 or 9 float3 coefficients respectively).
        Returns:
        This Builder, for chaining calls.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the sh array length is smaller than 3 × bands2
      • radiance

        @NonNull
        public IndirectLight.Builder radiance​(@IntRange(from=1L,to=3L)
                                              int bands,
                                              @NonNull
                                              float[] sh)
        Sets the irradiance from the radiance expressed as Spherical Harmonics.

        The radiance must be specified as Spherical Harmonics coefficients Ll,m, where each coefficient is comprised of three floats for red, green and blue components, respectively

        The index in the sh array is given by:
        index(l, m) = 3 × (l * (l + 1) + m)
        sh[index(l,m) + 0] = LRl,m
        sh[index(l,m) + 1] = LGl,m
        sh[index(l,m) + 2] = LBl,m

        index l m
        00 0
        11-1
        21 0
        31 1
        42-2
        52-1
        62 0
        72 1
        82 2
        Parameters:
        bands - Number of spherical harmonics bands. Must be 1, 2 or 3.
        sh - Array containing the spherical harmonics coefficients. The size of the array must be 3 × bands2 (i.e. 1, 4 or 9 float3 coefficients respectively).
        Returns:
        This Builder, for chaining calls.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the sh array length is smaller than 3 × bands2
      • irradiance

        @NonNull
        public IndirectLight.Builder irradiance​(@NonNull
                                                Texture cubemap)
        Sets the irradiance as a cubemap.

        The irradiance can alternatively be specified as a cubemap instead of Spherical Harmonics coefficients. It may or may not be more efficient, depending on your hardware (essentially, it's trading ALU for bandwidth).

        This irradiance cubemap can be generated with the cmgen tool.
        Parameters:
        cubemap - Cubemap representing the Irradiance pre-convolved by < n &sdot l >.
        Returns:
        This Builder, for chaining calls.
        See Also:
        irradiance(int bands, float[] sh)
      • intensity

        @NonNull
        public IndirectLight.Builder intensity​(float envIntensity)
        Environment intensity (optional).

        Because the environment is encoded usually relative to some reference, the range can be adjusted with this method.

        Parameters:
        envIntensity - Scale factor applied to the environment and irradiance such that the result is in lux, or lumen/m^2 (default = 30000)
        Returns:
        This Builder, for chaining calls.
      • rotation

        @NonNull
        public IndirectLight.Builder rotation​(@NonNull @Size(min=9L)
                                              float[] rotation)
        Specifies the rigid-body transformation to apply to the IBL.
        Parameters:
        rotation - 3x3 rotation matrix. Must be a rigid-body transform.
        Returns:
        This Builder, for chaining calls.
      • build

        @NonNull
        public IndirectLight build​(@NonNull
                                   Engine engine)
        Creates the IndirectLight object and returns a pointer to it.
        Parameters:
        engine - The Engine to associate this IndirectLight with.
        Returns:
        A newly created IndirectLight
        Throws:
        java.lang.IllegalStateException - if a parameter to a builder function was invalid.