[SlimDX] Particle Effect Alpha FadeOut
I'm drawing a pointlist as sprite (renderstate Setup) with a Texture. In the VB6 Tutorial, the Texture fades out by changing the Colors Alpha.
I'm doing the same thing, but changing Alpha takes no Effect. I'm using then System.color, not SlimDX.Color4.
How can i easy change the Transparenz, to fade out the particle ?
Thanx for Help !
You should be able to construct a color using an alpha value. Post your code that you think is incorrect.
First i create the VertexStructure
Then i create a particle list
Update:
if liftime <= 0 the particle is dead
else update particle position and color
The next for each:
get new positions and
get new colors for all particle
Thats the Updatepart from the Particle Class
Here is the render part
That's it. Lights are turned off.
I've tried this
with no change...
I've changed all System.color to SlimDX.Color4. With same Code only the red channel works.
Thanx for Help
#Region "Custom Vertexformat Structure" Private Structure PositionColored Public position As Vector3 Public color As Color Public Sub New(ByVal pos As Vector3, ByVal col As Color) Me.position = New Vector3(pos.X, pos.Y, pos.Z) Me.color = col End Sub Public Shared ReadOnly Property SizeBytes() As Integer Get Return System.Runtime.InteropServices.Marshal.SizeOf(GetType(PositionColored)) End Get End Property Public Shared ReadOnly Property Format() As Direct3D9.VertexFormat Get Return (VertexFormat.Position Or VertexFormat.Diffuse) End Get End Property End Structure#End Region
Then i create a particle list
Private _vertex() As PositionColoredPrivate _listOfParticle As New List(Of Particle) Private Sub createListOfParticle() For i As Integer = 0 To _particleCount _listOfParticle.Add(New Particle) Next End Sub Private Sub update() For Each p As Particle In _listOfParticle If p.Lifetime <= 0 Then p.generateNewValues(0.01) Else p.update() End If Next Dim i As Integer For Each p As Particle In _listOfParticle _vertex(i).position = p.Position _vertex(i).color = p.Color i += 1 Next End Sub
Update:
if liftime <= 0 the particle is dead
else update particle position and color
The next for each:
get new positions and
get new colors for all particle
Thats the Updatepart from the Particle Class
Public Sub update() '#update position _position.X += CSng(_speed.X * dxGametime.GameRendertime(400)) _position.Y += CSng(_speed.Y * dxGametime.GameRendertime(400)) _position.Z += CSng(_speed.Z * dxGametime.GameRendertime(400)) '#update speed '_speed += _acceleration '#update lifetime _lifetime -= CSng(_decreasLifetime * dxGametime.GameRendertime(400)) If _lifetime < 0 Then _lifetime = 0 '#color Update red = _color.R green = _color.G blue = _color.B alpha = CInt(_lifetime * 255) '#new Alpha Color _color = Color.FromArgb(alpha, red, green, blue) End Sub
Here is the render part
dxTextures.AlphaBlending3 = True '#for AlphaBlending dxDevice.SetRenderState(RenderState.PointSpriteEnable, True) dxDevice.SetRenderState(RenderState.PointScaleEnable, True) dxDevice.SetRenderState(RenderState.PointSize, 0.04F) dxDevice.SetTexture(0, _tex) dxDevice.VertexFormat = PositionColored.Format dxDevice.DrawUserPrimitives(PrimitiveType.PointList, _vertex.Length - 1, _vertex)
That's it. Lights are turned off.
I've tried this
dxDevice.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Diffuse)
with no change...
I've changed all System.color to SlimDX.Color4. With same Code only the red channel works.
Thanx for Help
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement