Class MaterialComponent

java.lang.Object
gaiasky.scene.record.NamedComponent
gaiasky.scene.record.MaterialComponent
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, IObserver, IUpdatable<MaterialComponent>, IComponent, IMaterialProvider

public final class MaterialComponent extends NamedComponent implements IObserver, IMaterialProvider, IUpdatable<MaterialComponent>
Contains the material of a model or part of a model.
  • Field Details

    • sharedReflectionCubemap

      public static final CubemapComponent sharedReflectionCubemap
      Reflection cubemap for all materials.
    • texInitialised

      public boolean texInitialised
    • texLoading

      public boolean texLoading
    • diffuse

      public String diffuse
    • specular

      public String specular
    • normal

      public String normal
    • emissive

      public String emissive
    • ring

      public String ring
    • height

      public String height
    • ringnormal

      public String ringnormal
    • roughness

      public String roughness
    • metallic

      public String metallic
    • ao

      public String ao
    • occlusionMetallicRoughness

      public String occlusionMetallicRoughness
    • texture0

      public String texture0
    • texture1

      public String texture1
    • volume0

      public String volume0
    • volume1

      public String volume1
    • volume2

      public String volume2
    • volume3

      public String volume3
    • diffuseUnpacked

      public String diffuseUnpacked
    • specularUnpacked

      public String specularUnpacked
    • normalUnpacked

      public String normalUnpacked
    • emissiveUnpacked

      public String emissiveUnpacked
    • ringUnpacked

      public String ringUnpacked
    • heightUnpacked

      public String heightUnpacked
    • ringnormalUnpacked

      public String ringnormalUnpacked
    • roughnessUnapcked

      public String roughnessUnapcked
    • metallicUnpacked

      public String metallicUnpacked
    • aoUnpacked

      public String aoUnpacked
    • occlusionMetallicRoughnessUnpacked

      public String occlusionMetallicRoughnessUnpacked
    • texture0Unpacked

      public String texture0Unpacked
    • texture1Unpacked

      public String texture1Unpacked
    • volume0Unpacked

      public String volume0Unpacked
    • volume1Unpacked

      public String volume1Unpacked
    • volume2Unpacked

      public String volume2Unpacked
    • volume3Unpacked

      public String volume3Unpacked
    • volumeDepthThreshold

      public double[] volumeDepthThreshold
      Per-slot minimum density for a volume to act as an occluder, indexed like the volume slots (volume0..volume3). Entry i is the smallest density of volume i that is allowed to write to the depth buffer, so anything drawn later (stars, labels, points, lines) is hidden behind it.

      A missing entry, or one that is zero or negative, means that slot never occludes: it is drawn, but nothing is hidden behind it. That is the right setting for an emissive volume such as gas, whose faint outer haze must not cut an opaque hole in the star field. Only an absorbing volume (dust) should carry a threshold.

      The value is a fraction of the volume's own normalisation (the same one the shader samples as density, i.e. the alpha channel of an RGBA volume), so it is independent of the texture resolution. Compare it against the file's density histogram: for the shipped ArmDust volume the median occupied voxel is 0.024 and a third of them sit above 0.05, so [0.0, 0.02] keeps roughly half the dust mass as an occluder and discards the blur tail.

      Example, in the material node of a scene:

      "material": {
        "volume0": "$data/.../galaxy_Gas_rgba.raw.gz",      // gas: emits only
        "volume1": "$data/.../galaxy_ArmDust_rgba.raw.gz",  // dust: absorbs
        "volumeDepthThreshold": [0.0, 0.02]                 // slot 0 never occludes, slot 1 does
      }
      
      Note that the array elements must be written with a decimal point: the scene loader types a JSON array from its first element, so [0, 0.02] would be read as an int array.
    • diffuseColor

      public float[] diffuseColor
    • specularColor

      public float[] specularColor
    • metallicColor

      public float[] metallicColor
    • emissiveColor

      public float[] emissiveColor
    • diffuseScatteringColor

      public float[] diffuseScatteringColor
    • ringDiffuseScatteringColor

      public float[] ringDiffuseScatteringColor
    • roughnessColor

      public float roughnessColor
    • heightScale

      public Float heightScale
      Height scale in internal units. The mapping value of white in the height map (maximum height value in this body). Black is mapped to 0.
    • heightSize

      public com.badlogic.gdx.math.Vector2 heightSize
    • heightData

      public IHeightData heightData
    • nc

      public NoiseComponent nc
    • diffuseSvt

      public VirtualTextureComponent diffuseSvt
    • specularSvt

      public VirtualTextureComponent specularSvt
    • heightSvt

      public VirtualTextureComponent heightSvt
    • normalSvt

      public VirtualTextureComponent normalSvt
    • emissiveSvt

      public VirtualTextureComponent emissiveSvt
    • roughnessSvt

      public VirtualTextureComponent roughnessSvt
    • metallicSvt

      public VirtualTextureComponent metallicSvt
    • aoSvt

    • svts

      public com.badlogic.gdx.utils.Array<VirtualTextureComponent> svts
    • diffuseCubemap

      public CubemapComponent diffuseCubemap
    • specularCubemap

      public CubemapComponent specularCubemap
    • normalCubemap

      public CubemapComponent normalCubemap
    • emissiveCubemap

      public CubemapComponent emissiveCubemap
    • heightCubemap

      public CubemapComponent heightCubemap
    • roughnessCubemap

      public CubemapComponent roughnessCubemap
    • metallicCubemap

      public CubemapComponent metallicCubemap
    • aoCubemap

      public CubemapComponent aoCubemap
    • aoTexture

      public com.badlogic.gdx.graphics.Texture aoTexture
      AO texture.
    • occlusionClouds

      public boolean occlusionClouds
      Occlusion clouds: ambient occlusion uses the cloud texture.
    • lut

      public String lut
      Biome lookup texture name. This is the name stripped of suffixes and prefixes. Examples:

      biome_lut_earthlike_00.jpg -> earthlike

      biome_lut_desert_03.jpg -> desert

    • lutHueShift

      public float lutHueShift
    • lutSaturation

      public float lutSaturation
    • colorIfTexture

      public boolean colorIfTexture
      Add also color even if texture is present
  • Constructor Details

    • MaterialComponent

      public MaterialComponent()
  • Method Details

    • getLUTManager

      public static BiomeLUTManager getLUTManager()
    • initialize

      public void initialize(String name, com.badlogic.gdx.assets.AssetManager manager)
    • initialize

      public void initialize(String name)
      Specified by:
      initialize in interface IComponent
      Overrides:
      initialize in class NamedComponent
    • isFinishedLoading

      public boolean isFinishedLoading(com.badlogic.gdx.assets.AssetManager manager)
    • hasSVT

      public boolean hasSVT()
    • initMaterial

      public void initMaterial(com.badlogic.gdx.assets.AssetManager manager, IntModelInstance instance, float[] diffuseCol, boolean culling)
    • initMaterial

      public void initMaterial(com.badlogic.gdx.assets.AssetManager manager, Material mat, Material ring, float[] diffuseCol, boolean culling)
    • setGenerated

      public void setGenerated(boolean generated)
    • getMaterial

      public Material getMaterial()
      Specified by:
      getMaterial in interface IMaterialProvider
    • getRingMaterial

      public Material getRingMaterial()
    • setBase

      @Deprecated public void setBase(String diffuse)
      Deprecated.
      use setDiffuse(String) instead
    • setDiffuse

      public void setDiffuse(String diffuse)
    • setSpecular

      public void setSpecular(String specular)
    • setSpecularValue

      public void setSpecularValue(Double specular)
    • setSpecular

      public void setSpecular(Double specular)
    • setSpecularValues

      public void setSpecularValues(double[] specular)
    • setSpecular

      public void setSpecular(double[] specular)
    • setNormal

      public void setNormal(String normal)
    • setNight

      @Deprecated public void setNight(String emissive)
      Deprecated.
    • setEmissive

      public void setEmissive(String emissive)
    • setEmissive

      public void setEmissive(Double emissive)
    • setEmissive

      public void setEmissive(double[] emissive)
    • setDiffuseScattering

      public void setDiffuseScattering(Double diffuseScattering)
    • setDiffuseScattering

      public void setDiffuseScattering(double[] diffuseScattering)
    • setRing

      public void setRing(String ring)
    • setRingDiffuse

      public void setRingDiffuse(String ringDiffuse)
    • setRingnormal

      public void setRingnormal(String ringNormal)
    • setRingNormal

      public void setRingNormal(String ringNormal)
    • setRingDiffuseScattering

      public void setRingDiffuseScattering(Double ringDiffuseScattering)
    • setRingDiffuseScattering

      public void setRingDiffuseScattering(double[] ringDiffuseScattering)
    • setHeight

      public void setHeight(String height)
    • setHeightScaleKm

      public void setHeightScaleKm(Double heightScale)
    • setHeightScaleM

      public void setHeightScaleM(Double heightScale)
    • setHeightScale

      public void setHeightScale(Double heightScale)
    • setHeightMapTopKm

      public void setHeightMapTopKm(Double heightMapTopKm)
    • setHeightMapTopM

      public void setHeightMapTopM(Double heightMapTopM)
    • setColorIfTexture

      public void setColorIfTexture(Boolean colorIfTexture)
    • setNoise

      public void setNoise(NoiseComponent noise)
    • setLUT

      public void setLUT(String biomeLookupTex)
    • setBiomelut

      public void setBiomelut(String biomeLookupTex)
    • setBiomeLUT

      public void setBiomeLUT(String biomeLookupTex)
    • setLUTHueShift

      public void setLUTHueShift(Double hueShift)
    • setBiomehueshift

      public void setBiomehueshift(Double hueShift)
    • setBiomeHueShift

      public void setBiomeHueShift(Double hueShift)
    • setLUTSaturation

      public void setLUTSaturation(Double saturation)
    • setBiomeSaturation

      public void setBiomeSaturation(Double saturation)
    • setReflection

      @Deprecated public void setReflection(Double metallicColor)
      Deprecated.
    • setMetallic

      public void setMetallic(Double metallicColor)
    • setMetallic

      public void setMetallic(String metallic)
    • setReflection

      public void setReflection(double[] metallic)
    • setRoughness

      public void setRoughness(String roughness)
    • setRoughness

      public void setRoughness(Double roughness)
    • setAo

      public void setAo(String ao)
    • setOcclusionMetallicRoughness

      public void setOcclusionMetallicRoughness(String texture)
    • setTexture0

      public void setTexture0(String texture0)
    • setTexture1

      public void setTexture1(String texture1)
    • setVolume0

      public void setVolume0(String tex)
    • setVolume1

      public void setVolume1(String tex)
    • setVolume2

      public void setVolume2(String tex)
    • setVolume3

      public void setVolume3(String tex)
    • setVolumeDepthThreshold

      public void setVolumeDepthThreshold(double[] thresholds)
    • setVolumeDepthThreshold

      public void setVolumeDepthThreshold(int[] thresholds)
      Overload for a scene that writes its thresholds without a decimal point, e.g. [0, 1]. The scene loader types a JSON array from the type of its first element, so [0, 0.02] arrives as a double[] and [0, 1] as an int[]; without this the load would fail with a reflection error rather than silently using the wrong values.
    • setDiffuseCubemap

      public void setDiffuseCubemap(String cubemap)
    • setNormalCubemap

      public void setNormalCubemap(String cubemap)
    • setSpecularCubemap

      public void setSpecularCubemap(String cubemap)
    • setEmissiveCubemap

      public void setEmissiveCubemap(String cubemap)
    • setNightCubemap

      public void setNightCubemap(String cubemap)
    • setHeightCubemap

      public void setHeightCubemap(String cubemap)
    • setMetallicCubemap

      public void setMetallicCubemap(String cubemap)
    • setRoughnessCubemap

      public void setRoughnessCubemap(String cubemap)
    • setReflectionCubemap

      public void setReflectionCubemap(String reflectionCubemap)
    • setAmbientOcclusionCubemap

      public void setAmbientOcclusionCubemap(String cubemap)
    • setOcclusionClouds

      public void setOcclusionClouds(boolean state)
    • setAmbientOcclusionCubemap

      public void setAmbientOcclusionCubemap(CubemapComponent cubemap)
    • setSkybox

      public void setSkybox(String diffuseCubemap)
    • setDiffuseSVT

      public void setDiffuseSVT(VirtualTextureComponent virtualTextureComponent)
    • setDiffuseSVT

      public void setDiffuseSVT(Map<Object,Object> virtualTexture)
    • setSpecularSVT

      public void setSpecularSVT(VirtualTextureComponent virtualTextureComponent)
    • setSpecularSVT

      public void setSpecularSVT(Map<Object,Object> virtualTexture)
    • setNormalSVT

      public void setNormalSVT(VirtualTextureComponent virtualTextureComponent)
    • setNormalSVT

      public void setNormalSVT(Map<Object,Object> virtualTexture)
    • setHeightSVT

      public void setHeightSVT(VirtualTextureComponent virtualTextureComponent)
    • setHeightSVT

      public void setHeightSVT(Map<Object,Object> virtualTexture)
    • setEmissiveSVT

      public void setEmissiveSVT(VirtualTextureComponent virtualTextureComponent)
    • setEmissiveSVT

      public void setEmissiveSVT(Map<Object,Object> virtualTexture)
    • setMetallicSVT

      public void setMetallicSVT(VirtualTextureComponent virtualTextureComponent)
    • setMetallicSVT

      public void setMetallicSVT(Map<Object,Object> virtualTexture)
    • setRoughnessSVT

      public void setRoughnessSVT(VirtualTextureComponent virtualTextureComponent)
    • setRoughnessSVT

      public void setRoughnessSVT(Map<Object,Object> virtualTexture)
    • setAoSVT

      public void setAoSVT(VirtualTextureComponent virtualTextureComponent)
    • setAoSVT

      public void setAoSVT(Map<Object,Object> virtualTexture)
    • convertToComponent

      public static VirtualTextureComponent convertToComponent(Map<Object,Object> map)
    • hasHeight

      public boolean hasHeight()
    • disposeTexture

      public void disposeTexture(com.badlogic.gdx.assets.AssetManager manager, Material material, String name, String nameUnpacked, int attributeIndex, com.badlogic.gdx.graphics.Texture tex)
    • disposeCubemap

      public void disposeCubemap(com.badlogic.gdx.assets.AssetManager manager, Material mat, int attributeIndex, CubemapComponent cubemap)
    • disposeTextures

      public void disposeTextures(com.badlogic.gdx.assets.AssetManager manager)
      Disposes and unloads all currently loaded textures immediately
      Parameters:
      manager - The asset manager
    • disposeNoiseBuffers

      public void disposeNoiseBuffers()
    • notify

      public void notify(Event event, Object source, Object... data)
      Description copied from interface: IObserver
      Event notification call.
      Specified by:
      notify in interface IObserver
      Parameters:
      event - The event type.
      source - The source object, if any.
      data - The data associated with this event.
    • getTexturesString

      public String getTexturesString()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copyFrom

      public void copyFrom(MaterialComponent other)
    • randomizeAll

      public void randomizeAll(long seed)
    • randomizeRockyPlanet

      public void randomizeRockyPlanet(long seed)
    • randomizeEarthLike

      public void randomizeEarthLike(long seed)
    • randomizeDesert

      public void randomizeDesert(long seed)
    • randomizeTropical

      public void randomizeTropical(long seed)
    • randomizeLava

      public void randomizeLava(long seed)
    • randomizeAlien

      public void randomizeAlien(long seed)
    • randomizeFrozenPlanet

      public void randomizeFrozenPlanet(long seed)
    • randomizeGasGiant

      public void randomizeGasGiant(long seed)
    • print

      public void print(Logger.Log log)
    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • updateWith

      public void updateWith(MaterialComponent object)
      Specified by:
      updateWith in interface IUpdatable<MaterialComponent>