Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: 1 [2]
  Print  
Author Topic: High Dynamic Range Lighting  (Read 9323 times)
rocky
Customers
Community Member
*****
Posts: 955


« Reply #20 on: July 20, 2004, 08:40:22 PM »

Excellent Byte!

Question, have you tried this with different colors?

I can see this being used in many different ways for a really cool effect.

i.e. after glow on engines such as a jet engine, possibly alien being (Arius) auras, weapon barrel glow RED after being fired continously, lighting as you are using it etc...

Thanks for the code  Cool

Rocky
Logged
Zaknafein
Customers
Community Member
*****
Posts: 2940


WWW
« Reply #21 on: July 20, 2004, 09:12:19 PM »

This is very cool! I just tried it and it reminds me of the effect in Prince of Persia : The Sands of Time... softening and all..
It's cool because this way you don't have to draw a "glow" billboard around each light..!
Logged

BYTE-Smasher
Community Member
*
Posts: 956

vaporware makes baby jesus cry


WWW
« Reply #22 on: July 21, 2004, 06:12:07 AM »

Rocky: yes, I have... in fact, in my source, I've got a color variable... either way, I'm going to be releasing the class for this soon (it's pretty much done... just need to test some more)... it's a little unconventional (hard to implement properly), but it'll work... I've got alot of properties in it... so it'll give you complete control over the effect... just in case you don't like my presets... so you may be pleasantly surprised...
Logged

BYTE-Smasher
Community Member
*
Posts: 956

vaporware makes baby jesus cry


WWW
« Reply #23 on: July 21, 2004, 05:05:28 PM »

Ok... I'm done the class... I've posted the source here:

http://bytesmasher.ath.cx/stuff/tv3dstuff/vb_TVBloomEffect_Class.zip

The demo makes it pretty self explanitory... if you have any questions, post them here...
Logged

BYTE-Smasher
Community Member
*
Posts: 956

vaporware makes baby jesus cry


WWW
« Reply #24 on: July 21, 2004, 07:10:25 PM »

For those of you that don't have vb, I've also compiled a dll with all the same functionality:

http://bytesmasher.ath.cx/stuff/tv3dstuff/TVBloom.dll

feel free to port the vb source if you like though...
Logged

Ander
Customers
Community Member
*****
Posts: 54


« Reply #25 on: August 04, 2004, 09:35:50 PM »

That is well cool man!!

Just a suggestion to make your life easier, use Option Explicit. It is your friend. It is our friend.

Cheers,

Ander
Logged
EzikialX
Customers
Community Member
*****
Posts: 107


« Reply #26 on: August 08, 2004, 06:13:32 PM »

I tried converting this into VB.NET, but I'm not sure if I made a mistake or not.  I got rid of the properties and just went with private vars.  Tell me if you can get it to work Undecided  It just shows up all garbled to me..

Code:

Imports Clean_FuryEngine.FCommon
Imports TrueVision3D

Public Class FBloom

    Private mvarEnabled As Boolean 'local copy
    Private mvarBrightness As Double 'local copy
    Private mvarColor As Long 'local copy
    Private mvarGlitter As Long 'local copy
    Private mvarBlurRadius As Long 'local copy
    Private mvarBlurStep As Long 'local copy
    Private mvarBlurStrength As Long 'local copy
    Private RunAlready As Boolean
    Public RS1 As New TVRenderSurface
    Public RS2 As New TVRenderSurface
    Public RS3 As New TVRenderSurface
    Public screenwidth As Long, screenheight As Long, screenbits As Long
    Public mvarQuality As Integer

    Public Sub New()
        mvarEnabled = True
        mvarBrightness = 0.5
        mvarColor = FInternal.g_oGLO.RGBA(0.8, 0.5, 0.4, 1)
        mvarGlitter = 0
        mvarBlurRadius = 5
        mvarBlurStep = 2
        mvarBlurStrength = 2
    End Sub
    Public Sub Init(ByVal Engine As TVEngine, ByVal Scene As TVScene, Optional ByVal Quality As Integer = 0)
        Engine.GetVideoMode(screenwidth, screenheight, screenbits)
        mvarQuality = Quality
        If mvarQuality = 0 Then mvarQuality = 2
        RS1 = Scene.CreateRenderSurface(screenwidth, screenheight, True)
        RS2 = Scene.CreateRenderSurface(screenwidth / mvarQuality, screenwidth / mvarQuality, True)
        RS3 = Scene.CreateRenderSurface(screenwidth / mvarQuality, screenwidth / mvarQuality, True)
        FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_ONE, DxVBLibA.CONST_D3DBLEND.D3DBLEND_ONE)
        FInternal.g_o2DI.SETTINGS_SetTextureFilter(CONST_TV_TEXTUREFILTER.TV_FILTER_GAUSSIANCUBIC)
    End Sub
    Public Sub EndRender()
        RS1.EndRender()
        Dim cx As Long
        Dim cy As Long
        Dim randlev As Long = mvarGlitter

        FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_DESTALPHA, DxVBLibA.CONST_D3DBLEND.D3DBLEND_SRCALPHA)
        If mvarEnabled = True Then
            RS2.StartRender(True)
            FInternal.g_o2DI.ACTION_Begin2D()
            FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_SRCALPHA, DxVBLibA.CONST_D3DBLEND.D3DBLEND_INVSRCALPHA)
            For cx = -mvarBlurRadius To mvarBlurRadius Step mvarBlurStep
                If cx <> -mvarBlurRadius Then FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_DESTALPHA, DxVBLibA.CONST_D3DBLEND.D3DBLEND_SRCALPHA)
                FInternal.g_o2DI.DRAW_Texture(RS1.GetTexture, cx, -Rnd() * randlev, num2rs(screenwidth / mvarQuality) + cx, num2rs(screenwidth / mvarQuality) - (Rnd() * randlev), FInternal.g_oGLO.RGBA(1, 1, 1, 0.05 * mvarBlurStrength * (mvarBlurRadius - Math.Abs(cx))))
            Next
            FInternal.g_o2DI.ACTION_End2D()
            RS2.EndRender()
            RS3.StartRender(True)
            FInternal.g_o2DI.ACTION_Begin2D()
            FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_SRCALPHA, DxVBLibA.CONST_D3DBLEND.D3DBLEND_INVSRCALPHA)
            For cy = -mvarBlurRadius To mvarBlurRadius Step mvarBlurStep
                If cy <> -mvarBlurRadius Then FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_DESTALPHA, DxVBLibA.CONST_D3DBLEND.D3DBLEND_SRCALPHA)
                FInternal.g_o2DI.DRAW_Texture(RS2.GetTexture, -Rnd() * randlev, cy, num2rs(screenwidth / mvarQuality) - (Rnd() * randlev), num2rs(screenwidth / mvarQuality) + cy, FInternal.g_oGLO.RGBA(1, 1, 1, 0.05 * mvarBlurStrength * (mvarBlurRadius - Math.Abs(cy))))
            Next
            FInternal.g_o2DI.ACTION_End2D()
            RS3.EndRender()
        End If
    End Sub

    Public Sub DrawBloom()
        Dim coler As Long

        coler = FInternal.g_oGLO.RGBA(rgbadecode(mvarColor, 1) * mvarBrightness, rgbadecode(mvarColor, 2) * mvarBrightness, rgbadecode(mvarColor, 3) * mvarBrightness, rgbadecode(mvarColor, 4))
        FInternal.g_o2DI.ACTION_Begin2D()
        FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_SRCALPHA, DxVBLibA.CONST_D3DBLEND.D3DBLEND_INVSRCALPHA)
        FInternal.g_o2DI.DRAW_Texture(RS1.GetTexture, 0, 0, screenwidth, screenheight)
        If mvarEnabled = True Then
            FInternal.g_o2DI.SETTINGS_SetBlendingMode(DxVBLibA.CONST_D3DBLEND.D3DBLEND_ONE, DxVBLibA.CONST_D3DBLEND.D3DBLEND_ONE)
            FInternal.g_o2DI.DRAW_Texture(RS1.GetTexture, 0, 0, screenwidth, screenheight + 10, coler)
            'TwoDee1.DRAW_Texture RS3.GetTexture, 0, 0, screenwidth, screenheight + 10, coler
        End If
        FInternal.g_o2DI.ACTION_End2D()
    End Sub

    Public Sub StartRender(ByVal Eye As TVCamera)
        RS1.SetCamera(Eye.GetPosition.x, Eye.GetPosition.y, Eye.GetPosition.z, Eye.GetLookAt.x, Eye.GetLookAt.y, Eye.GetLookAt.z)
        RS1.StartRender(True)
    End Sub

    Public Function rgbadecode(ByVal rgbacolor As Long, ByVal element As Long) As Long
        Dim rgb2 As Long, blu As Long, grn As Long, red As Long, alpha As Long
        rgb2 = rgbacolor
        If rgbacolor < 0 Then rgb2 = 256 ^ 4 + rgbacolor

        blu = ((rgb2 / 256) - Int(rgb2 / 256)) * 256
        rgb2 = Int(rgb2 / 256)
        grn = rgb2 Mod 256
        red = (rgb2 \ 256) Mod 256
        alpha = ((rgb2 \ 256) \ 256) Mod 256
        Select Case element
            Case 1
                rgbadecode = red / 255
            Case 2
                rgbadecode = grn / 255
            Case 3
                rgbadecode = blu / 255
            Case 4
                rgbadecode = alpha / 255
        End Select
    End Function

    Public Function num2rs(ByVal sizeof As Long) As Long
        Dim a As Long
        For a = 1 To 80
            If 2 ^ a >= sizeof Then Exit For
        Next
        num2rs = 2 ^ a
    End Function

    Protected Overrides Sub Finalize()
        RS1 = Nothing
        RS2 = Nothing
        RS3 = Nothing

        MyBase.Finalize()
    End Sub
End Class
Logged

---------------------------------

---------------------------------
EzikialX
Customers
Community Member
*****
Posts: 107


« Reply #27 on: August 08, 2004, 10:50:19 PM »

nevermind, was incorrect render order..
Logged

---------------------------------

---------------------------------
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks