Jump to content
  • Advertisement
Sign in to follow this  

[SlimDX] Particle Effect Alpha FadeOut

This topic is 3473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 !

Share this post

Link to post
Share on other sites
First i create the VertexStructure

#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
Return System.Runtime.InteropServices.Marshal.SizeOf(GetType(PositionColored))
End Get
End Property
Public Shared ReadOnly Property Format() As Direct3D9.VertexFormat
Return (VertexFormat.Position Or VertexFormat.Diffuse)
End Get
End Property
End Structure
#End Region

Then i create a particle list

Private _vertex() As PositionColored
Private _listOfParticle As New List(Of Particle)

Private Sub createListOfParticle()
For i As Integer = 0 To _particleCount
_listOfParticle.Add(New Particle)
End Sub

Private Sub update()
For Each p As Particle In _listOfParticle
If p.Lifetime <= 0 Then
End If
Dim i As Integer
For Each p As Particle In _listOfParticle
_vertex(i).position = p.Position
_vertex(i).color = p.Color
i += 1
End Sub

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!