Class InstancedRenderSystem
java.lang.Object
gaiasky.render.system.AbstractRenderSystem
gaiasky.render.system.ImmediateModeRenderSystem
gaiasky.render.system.InstancedRenderSystem
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, IObserver, IRenderSystem, Comparable<IRenderSystem>
- Direct Known Subclasses:
BillboardProceduralCPURenderer, BillboardSetRenderer, ElementsSetRenderer, ParticleSetInstancedRenderer, StarSetInstancedRenderer, VariableSetInstancedRenderer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHolds temporary instanced model data.Nested classes/interfaces inherited from class ImmediateModeRenderSystem
ImmediateModeRenderSystem.MeshData, ImmediateModeRenderSystem.OwnUsageModifier and TypeClassDescriptionstatic classprotected static classNested classes/interfaces inherited from class AbstractRenderSystem
AbstractRenderSystem.RenderSystemRunnable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.badlogic.gdx.math.Matrix4Auxiliary matrix.protected com.badlogic.gdx.utils.Array<InstancedRenderSystem.InstancedModel> Instanced model list, one per particle group.protected final com.badlogic.gdx.math.Matrix4Auxiliary reference system transform matrix.protected final ParticleUtilsParticle utils instance.Fields inherited from class ImmediateModeRenderSystem
auxMat, curr, inGpu, meshes, meshIdx, tempIndices, tempVertsModifier and TypeFieldDescriptionprotected final com.badlogic.gdx.math.Matrix4protected ImmediateModeRenderSystem.MeshDataprotected Set<IRenderable> protected com.badlogic.gdx.utils.Array<ImmediateModeRenderSystem.MeshData> protected intprotected int[]protected float[]Fields inherited from class AbstractRenderSystem
alphas, aux3f, comp, postRunners, preRunners, programs, rc, sceneRendererModifier and TypeFieldDescriptionprotected final float[]protected final com.badlogic.gdx.math.Vector3protected Comparator<IRenderable> Comparator of renderables, in case of needprotected com.badlogic.gdx.utils.Array<AbstractRenderSystem.RenderSystemRunnable> protected com.badlogic.gdx.utils.Array<AbstractRenderSystem.RenderSystemRunnable> protected final ExtShaderProgram[]protected final SceneRenderer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstancedRenderSystem(SceneRenderer sceneRenderer, RenderGroup rg, float[] alphas, ExtShaderProgram[] shaders) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAttributesDivisor0(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int posArraySize, boolean useNormals, boolean useTexCoords) Adds the required vertex attributes for this renderer to the given list.protected abstract voidaddAttributesDivisor1(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int primitive) Adds the required vertex attributes for this renderer to the given list.protected intaddMeshData(InstancedRenderSystem.InstancedModel model, int maxVerts, int maxInstances, int maxIndices, String modelType, int primitive) Adds a new mesh data to the meshes list and increases the mesh data index.protected intaddMeshData(InstancedRenderSystem.InstancedModel model, int maxVerts, int maxInstances, int maxIndices, String modelFile, String modelType, int primitive) Adds a new mesh data to the meshes list and increases the mesh data index.protected com.badlogic.gdx.graphics.VertexAttribute[]buildAttributesDivisor0(int posArraySize, boolean useNormals, boolean useTexCoords) Builds the vertex attributes with divisor=0 array and returns it.protected com.badlogic.gdx.graphics.VertexAttribute[]buildAttributesDivisor1(int primitive) Builds the vertex attributes with divisor=1 array and returns it The content of divisor-1 attributes is updated for each instance.static intcomputeTextureIndex(IParticleRecord pr, Random rand, com.badlogic.gdx.graphics.TextureArray textureArray, String textureAttribute) Computes the texture index for a given particle, for particle and orbital elements sets, given their texture array and texture attribute.protected voidgenerateChannelNoise(long seed, double noise, float[] result) Generates color noise per channel, given a seed and an (n).protected InstancedRenderSystem.InstancedModelgetModel(ParticleSet set, int offset) protected InstancedRenderSystem.InstancedModelgetModel(IntModel modelFile, String modelType, Map<String, Object> modelParams, int primitive, int offset) protected InstancedRenderSystem.InstancedModelgetModelQuad(int primitive, int offset) protected floatgetProfileDecay(int shadingType, float profileDecay) Returns the profile decay for the given shading type.protected voidbooleanisWireframe(int primitive) protected abstract voidComputes the offset for each vertex attribute.protected abstract voidComputes the offset for each vertex attribute in the instanced array.protected voidpostRenderObjects(ExtShaderProgram shaderProgram, ICamera camera) protected voidRestore regular blending and depth writes.protected voidpreRenderObjects(ExtShaderProgram shaderProgram, ICamera camera) protected intpreShadingType(Highlight hl, ParticleSet.ShadingType shadingType) Apply blending mode and depth mask depending on the highlight component and shading type.protected voidrenderObject(ExtShaderProgram shaderProgram, ICamera camera, IRenderable renderable) voidrenderStud(List<IRenderable> renderables, ICamera camera, double t) protected voidsetModel(int offset, InstancedRenderSystem.InstancedModel model) protected voidsetRefSysTransformAndDatasetPosUniforms(ExtShaderProgram shaderProgram, GraphNode graph, ParticleSet set) protected voidsetShadingTypeUniforms(ExtShaderProgram shaderProgram, ICamera camera, int shadingType, float sphericalPower, float ambient, GraphNode graph) Sets uniforms pertaining to the shading type.Methods inherited from class ImmediateModeRenderSystem
addAffineTransformUniforms, clearMeshData, clearMeshes, color, color, color, color, createMeshData, dispose, ensureTempIndicesSize, ensureTempVertsSize, getCount, getCounts, getOffset, getOffsets, inGpu, setCount, setInGpu, setOffset, vertexModifier and TypeMethodDescriptionprotected voidaddAffineTransformUniforms(ExtShaderProgram program, AffineTransformations affine) voidclearMeshData(int i) Clears the mesh data at the index ivoidvoidcolor(double r, double g, double b, double a) voidcolor(float colorBits) voidcolor(float r, float g, float b, float a) voidcolor(com.badlogic.gdx.graphics.Color color) protected intCreates a new mesh data object and adds it to the first available index in the meshes arrayvoiddispose()protected voidensureTempIndicesSize(int size) This function makes sure that the tempIndices array has at least the given size.protected voidensureTempVertsSize(int size) This function makes sure that the tempVerts array has at least the given size.protected intgetCount(IRenderable renderable) protected com.badlogic.gdx.utils.IntArraygetCounts(IRenderable renderable) protected intgetOffset(IRenderable renderable) protected com.badlogic.gdx.utils.IntArraygetOffsets(IRenderable renderable) protected booleaninGpu(IRenderable renderable) protected voidsetCount(IRenderable renderable, int count) protected voidsetInGpu(IRenderable renderable, boolean state) protected voidsetOffset(IRenderable renderable, int offset) voidvertex(float x, float y, float z) Methods inherited from class AbstractRenderSystem
addCameraUpCubemapMode, addDepthBufferUniforms, addEffectsUniforms, addGravWaveUniforms, addMotionTrailsUniforms, addPostRunnables, addPreRunnables, addRelativisticUniforms, addVRScale, compareTo, getAlpha, getAlpha, getAlpha, getRenderGroup, getShaderProgram, getShaderProgram, initShaderProgram, render, resize, run, updateBatchSizeModifier and TypeMethodDescriptionprotected voidaddCameraUpCubemapMode(ExtShaderProgram shaderProgram, ICamera camera) Adds the camera up vector (only in non-cubemap mode) to compute the billboard rotation.voidaddDepthBufferUniforms(ExtShaderProgram shaderProgram, ICamera camera) Uniforms needed to compute the logarithmic depth buffer.protected voidaddEffectsUniforms(ExtShaderProgram shaderProgram, ICamera camera) protected voidaddGravWaveUniforms(ExtShaderProgram shaderProgram) protected voidaddMotionTrailsUniforms(ExtShaderProgram shaderProgram, ICamera camera) Uniforms related to the motion trails effect for particle and star groups.voidvoidprotected voidaddRelativisticUniforms(ExtShaderProgram shaderProgram, ICamera camera) protected voidaddVRScale(ExtShaderProgram shaderProgram) intfloatgetAlpha(com.badlogic.ashley.core.Entity entity) floatgetAlpha(IRenderable renderable) Computes the alpha opacity value of a given renderable using its component typesfloatprotected ExtShaderProgramprotected ExtShaderProgramgetShaderProgram(ExtShaderProgram[] programs) protected voidInitializes metadata or essential uniforms in the shader program.voidrender(List<IRenderable> renderables, ICamera camera, double t, RenderingContext rc) Renders the given list of renderable objects.voidresize(int w, int h) Resize the current render target with the given width and height.protected voidrun(com.badlogic.gdx.utils.Array<AbstractRenderSystem.RenderSystemRunnable> runnables, List<IRenderable> renderables, ICamera camera) voidupdateBatchSize(int w, int h) Updates the size of object batches, if any.
-
Field Details
-
models
Instanced model list, one per particle group. -
utils
Particle utils instance. -
aux
protected final com.badlogic.gdx.math.Matrix4 auxAuxiliary matrix. -
refSysTransformF
protected final com.badlogic.gdx.math.Matrix4 refSysTransformFAuxiliary reference system transform matrix.
-
-
Constructor Details
-
InstancedRenderSystem
protected InstancedRenderSystem(SceneRenderer sceneRenderer, RenderGroup rg, float[] alphas, ExtShaderProgram[] shaders)
-
-
Method Details
-
initVertices
protected void initVertices()- Specified by:
initVerticesin classImmediateModeRenderSystem
-
isWireframe
public boolean isWireframe(int primitive) -
setModel
-
getModel
-
getModelQuad
-
getModel
-
addAttributesDivisor0
protected void addAttributesDivisor0(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int posArraySize, boolean useNormals, boolean useTexCoords) Adds the required vertex attributes for this renderer to the given list. These attributes are added only once for all instances (divisor=0)- Parameters:
attributes- The list of attributes with divisor=0posArraySize- Size of the position array (2 or 3).useNormals- Add normal attributes as a vector-3.useTexCoords- Add texture coordinates attribute as a vector-2.
-
addAttributesDivisor1
protected abstract void addAttributesDivisor1(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int primitive) Adds the required vertex attributes for this renderer to the given list. These attributes are added for every instance (divisor=1)- Parameters:
attributes- The list of attributes with divisor=1primitive- The rendering primitive.
-
buildAttributesDivisor0
protected com.badlogic.gdx.graphics.VertexAttribute[] buildAttributesDivisor0(int posArraySize, boolean useNormals, boolean useTexCoords) Builds the vertex attributes with divisor=0 array and returns it. The content of divisor-0 attributes is updated in each iteration of the vertex shader.- Parameters:
posArraySize- Size of the position array (2 or 3).useNormals- Add normal attributes as a vector-3.useTexCoords- Add texture coordinates attribute as a vector-2.- Returns:
- The vertex attributes array
-
buildAttributesDivisor1
protected com.badlogic.gdx.graphics.VertexAttribute[] buildAttributesDivisor1(int primitive) Builds the vertex attributes with divisor=1 array and returns it The content of divisor-1 attributes is updated for each instance.- Parameters:
primitive- The rendering primitive.- Returns:
- The vertex attributes array.
-
offsets0
protected abstract void offsets0(ImmediateModeRenderSystem.MeshData curr, InstancedRenderSystem.InstancedModel model) Computes the offset for each vertex attribute. The offsets will be used later in the render stage.- Parameters:
curr- The current mesh data.model- The instanced model.
-
offsets1
protected abstract void offsets1(ImmediateModeRenderSystem.MeshData curr, InstancedRenderSystem.InstancedModel model) Computes the offset for each vertex attribute in the instanced array. The offsets will be used later in the render stage.- Parameters:
curr- The current mesh data.model- The instanced model.
-
addMeshData
protected int addMeshData(InstancedRenderSystem.InstancedModel model, int maxVerts, int maxInstances, int maxIndices, String modelType, int primitive) Adds a new mesh data to the meshes list and increases the mesh data index.- Parameters:
model- The instanced model instance.maxVerts- The max number of vertices the divisor 0 mesh data can hold.maxInstances- The max number of vertices the divisor 1 mesh data can hold.modelType- The model type string.primitive- The rendering primitive.- Returns:
- The index of the new mesh data.
-
addMeshData
protected int addMeshData(InstancedRenderSystem.InstancedModel model, int maxVerts, int maxInstances, int maxIndices, String modelFile, String modelType, int primitive) Adds a new mesh data to the meshes list and increases the mesh data index.- Parameters:
model- The instanced model instance.maxVerts- The max number of vertices the divisor 0 mesh data can hold.maxInstances- The max number of vertices the divisor 1 mesh data can hold.modelFile- The model file, if any.modelType- The model type string.primitive- The rendering primitive.- Returns:
- The index of the new mesh data.
-
preRenderObjects
-
renderObject
-
postRenderObjects
-
renderStud
- Specified by:
renderStudin classAbstractRenderSystem
-
generateChannelNoise
protected void generateChannelNoise(long seed, double noise, float[] result) Generates color noise per channel, given a seed and an (n).- Parameters:
seed- The seed for the RNG.noise- The noise value in [0,1].result- The result array.
-
preShadingType
Apply blending mode and depth mask depending on the highlight component and shading type.- Parameters:
hl- The highlight component.shadingType- The shading type.- Returns:
- The ordinal shading type.
-
postShadingType
protected void postShadingType()Restore regular blending and depth writes. -
getProfileDecay
protected float getProfileDecay(int shadingType, float profileDecay) Returns the profile decay for the given shading type.- Parameters:
shadingType- The shading type.profileDecay- The profile decay.- Returns:
- The effective profile decay.
-
setShadingTypeUniforms
protected void setShadingTypeUniforms(ExtShaderProgram shaderProgram, ICamera camera, int shadingType, float sphericalPower, float ambient, GraphNode graph) Sets uniforms pertaining to the shading type.- Parameters:
shaderProgram- The program.shadingType- The shading type ordinal.sphericalPower- The spherical power value.
-
setRefSysTransformAndDatasetPosUniforms
protected void setRefSysTransformAndDatasetPosUniforms(ExtShaderProgram shaderProgram, GraphNode graph, ParticleSet set) -
computeTextureIndex
public static int computeTextureIndex(IParticleRecord pr, Random rand, com.badlogic.gdx.graphics.TextureArray textureArray, String textureAttribute) Computes the texture index for a given particle, for particle and orbital elements sets, given their texture array and texture attribute.- Parameters:
pr- The particle recordrand- The RNG.textureArray- The texture array. May be null.textureAttribute- The texture attribute. May be null.- Returns:
- The texture index for the given particle.
-