public override unsafe void PatchVertexBuffer(ref ParticleBufferState bufferState, Vector3 invViewX, Vector3 invViewY, ref ParticleList sorter) { // If you want, you can integrate the base builder here and not call it. It should result in slight speed up base.PatchVertexBuffer(ref bufferState, invViewX, invViewY, ref sorter); // Update the non-default coordinates first, because they update off the default ones if (UVBuilder1 != null) { UVBuilder1.BuildUVCoordinates(ref bufferState, ref sorter, texCoord1); } // Update the default coordinates last if (UVBuilder0 != null) { UVBuilder0.BuildUVCoordinates(ref bufferState, ref sorter, texCoord0); } // If the particles have color field, the base class should have already passed the information if (HasColorField) { return; } // If there is no color stream we don't need to fill anything var colAttribute = bufferState.GetAccessor(VertexAttributes.Color); if (colAttribute.Size <= 0) { return; } // Since the particles don't have their own color field, set the default color to white var color = 0xFFFFFFFF; bufferState.StartOver(); foreach (var particle in sorter) { bufferState.SetAttributePerParticle(colAttribute, (IntPtr)(&color)); bufferState.NextParticle(); } bufferState.StartOver(); }
/// <inheritdoc /> public override unsafe void BuildUVCoordinates(ref ParticleBufferState bufferState, ref ParticleList sorter, AttributeDescription texCoordsDescription) { var lifeField = sorter.GetField(ParticleFields.RemainingLife); if (!lifeField.IsValid()) { return; } var texAttribute = bufferState.GetAccessor(texCoordsDescription); if (texAttribute.Size == 0 && texAttribute.Offset == 0) { return; } var texDefault = bufferState.GetAccessor(bufferState.DefaultTexCoords); if (texDefault.Size == 0 && texDefault.Offset == 0) { return; } foreach (var particle in sorter) { var normalizedTimeline = 1f - *(float *)(particle[lifeField]); var spriteId = startingFrame + (int)(normalizedTimeline * animationSpeedOverLife); Vector4 uvTransform = new Vector4((spriteId % xDivisions) * xStep, (spriteId / xDivisions) * yStep, xStep, yStep); bufferState.TransformAttributePerParticle(texDefault, texAttribute, this, ref uvTransform); bufferState.NextParticle(); } bufferState.StartOver(); }
/// <inheritdoc /> public unsafe override void PatchVertexBuffer(ref ParticleBufferState bufferState, Vector3 invViewX, Vector3 invViewY, ref ParticleList sorter) { // If you want, you can implement the base builder here and not call it. It should result in slight speed up base.PatchVertexBuffer(ref bufferState, invViewX, invViewY, ref sorter); // The UV Builder, if present, animates the basic (0, 0, 1, 1) uv coordinates of each billboard UVBuilder?.BuildUVCoordinates(ref bufferState, ref sorter, bufferState.DefaultTexCoords); bufferState.StartOver(); // If the particles have color field, the base class should have already passed the information if (HasColorField) { return; } // If the particles don't have color field but there is no color stream either we don't need to fill anything var colAttribute = bufferState.GetAccessor(VertexAttributes.Color); if (colAttribute.Size <= 0) { return; } // Since the particles don't have their own color field, set the default color to white var color = 0xFFFFFFFF; // TODO: for loop. Remove IEnumerable from sorter foreach (var particle in sorter) { bufferState.SetAttributePerParticle(colAttribute, (IntPtr)(&color)); bufferState.NextParticle(); } bufferState.StartOver(); }
public override unsafe void PatchVertexBuffer(ref ParticleBufferState bufferState, Vector3 invViewX, Vector3 invViewY, ref ParticleList sorter) { // If you want, you can integrate the base builder here and not call it. It should result in slight speed up base.PatchVertexBuffer(ref bufferState, invViewX, invViewY, ref sorter); // Update the non-default coordinates first, because they update off the default ones if (UVBuilder1 != null) UVBuilder1.BuildUVCoordinates(ref bufferState, ref sorter, texCoord1); // Update the default coordinates last if (UVBuilder0 != null) UVBuilder0.BuildUVCoordinates(ref bufferState, ref sorter, texCoord0); // If the particles have color field, the base class should have already passed the information if (HasColorField) return; // If there is no color stream we don't need to fill anything var colAttribute = bufferState.GetAccessor(VertexAttributes.Color); if (colAttribute.Size <= 0) return; // Since the particles don't have their own color field, set the default color to white var color = 0xFFFFFFFF; bufferState.StartOver(); foreach (var particle in sorter) { bufferState.SetAttributePerParticle(colAttribute, (IntPtr)(&color)); bufferState.NextParticle(); } bufferState.StartOver(); }
/// <inheritdoc /> public unsafe override void PatchVertexBuffer(ref ParticleBufferState bufferState, Vector3 invViewX, Vector3 invViewY, ref ParticleList sorter) { // If you want, you can implement the base builder here and not call it. It should result in slight speed up base.PatchVertexBuffer(ref bufferState, invViewX, invViewY, ref sorter); // The UV Builder, if present, animates the basic (0, 0, 1, 1) uv coordinates of each billboard UVBuilder?.BuildUVCoordinates(ref bufferState, ref sorter, bufferState.DefaultTexCoords); bufferState.StartOver(); // If the particles have color field, the base class should have already passed the information if (HasColorField) return; // If the particles don't have color field but there is no color stream either we don't need to fill anything var colAttribute = bufferState.GetAccessor(VertexAttributes.Color); if (colAttribute.Size <= 0) return; // Since the particles don't have their own color field, set the default color to white var color = 0xFFFFFFFF; // TODO: for loop. Remove IEnumerable from sorter foreach (var particle in sorter) { bufferState.SetAttributePerParticle(colAttribute, (IntPtr)(&color)); bufferState.NextParticle(); } bufferState.StartOver(); }