Class IndirectLight.Builder
- java.lang.Object
-
- com.google.android.filament.IndirectLight.Builder
-
- Enclosing class:
- IndirectLight
public static class IndirectLight.Builder extends java.lang.ObjectUseBuilderto construct anIndirectLightobject instance.
-
-
Constructor Summary
Constructors Constructor Description Builder()UseBuilderto construct anIndirectLightobject instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndirectLightbuild(Engine engine)Creates the IndirectLight object and returns a pointer to it.IndirectLight.Builderintensity(float envIntensity)Environment intensity (optional).IndirectLight.Builderirradiance(int bands, float[] sh)Sets the irradiance as Spherical Harmonics.IndirectLight.Builderirradiance(Texture cubemap)Sets the irradiance as a cubemap.IndirectLight.Builderradiance(int bands, float[] sh)Sets the irradiance from the radiance expressed as Spherical Harmonics.IndirectLight.Builderreflections(Texture cubemap)Set the reflections cubemap mipmap chain.IndirectLight.Builderrotation(float[] rotation)Specifies the rigid-body transformation to apply to the IBL.
-
-
-
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 BRDF1/&piand 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
cmgentool.The index in the
sharray is given by:index(l, m) = 3 × (l * (l + 1) + m)sh[index(l,m) + 0] = LRl,m × 1/&pi × Al,m × Clsh[index(l,m) + 1] = LGl,m × 1/&pi × Al,m × Clsh[index(l,m) + 2] = LBl,m × 1/&pi × Al,m × Clindex l m Al,m Cl 1/&pi × Al,m × Cl 0 0 0 0.282095 3.1415926 0.282095 1 1 -1 -0.488602 2.0943951 -0.325735 2 1 0 0.488602 2.0943951 0.325735 3 1 1 -0.488602 2.0943951 -0.325735 4 2 -2 1.092548 0.785398 0.273137 5 2 -1 -1.092548 0.785398 -0.273137 6 2 0 0.315392 0.785398 0.078848 7 2 1 -1.092548 0.785398 -0.273137 8 2 2 0.546274 0.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 be3 × bands2(i.e. 1, 4 or 9float3coefficients respectively).- Returns:
- This Builder, for chaining calls.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if thesharray 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
sharray is given by:index(l, m) = 3 × (l * (l + 1) + m)sh[index(l,m) + 0] = LRl,msh[index(l,m) + 1] = LGl,msh[index(l,m) + 2] = LBl,mindex l m 0 0 0 1 1 -1 2 1 0 3 1 1 4 2 -2 5 2 -1 6 2 0 7 2 1 8 2 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 9float3coefficients respectively).- Returns:
- This Builder, for chaining calls.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- if thesharray 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 thecmgentool.- 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- TheEngineto associate thisIndirectLightwith.- Returns:
- A newly created
IndirectLight - Throws:
java.lang.IllegalStateException- if a parameter to a builder function was invalid.
-
-