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

vaporware makes baby jesus cry


WWW
« on: July 18, 2004, 10:29:20 PM »

I'd like to post some screenshots of the work I'm doing to emulate High Dynamic Range lighting in tv3d... I'd like to thank Sylvain and the members of #tviug for their help in solving this problem..... (I will post source as soon as I clean it up a bit..)

Before...notice the dull lighting... bleh... :


After... notice the bright colors and most importantly, the glow around the white areas... this is meant to represent very bright areas...:
Logged

Beers
Community Member
*
Posts: 38


« Reply #1 on: July 18, 2004, 10:32:34 PM »

That looks simply amazing. I love the way it makes the room look warm and fuzzy. Use this and a little bit of slow motion, and you got yourself a nice in-game effect.

-Beers
Logged
GoodVillain
Community Member
*
Posts: 1631


« Reply #2 on: July 18, 2004, 10:34:46 PM »

Thanks for blinding me. Looks great. Smiley
Logged
Zaknafein
Customers
Community Member
*****
Posts: 2940


WWW
« Reply #3 on: July 18, 2004, 11:10:03 PM »

That looks 6.5-ish and Pixel Shader-ish... am I right? Smiley
I know HDR is an effect shown in ATi 9X00 series demos, and done with pixel shaders... dunno about your method, but it sure looks sweet Smiley
Logged

tweakbox
Customers
Community Member
*****
Posts: 1194


« Reply #4 on: July 18, 2004, 11:21:38 PM »

yea, all I could really think of is the graphical difference between DX 8 and DX 9 when I saw those, but they're both DX 8.  Simply amazing
Logged

I want to make a puzzle with like 40,000 pieces, and when it's done, it says "Go Outside"
polygone
Community Member
*
Posts: 23


« Reply #5 on: July 19, 2004, 01:37:32 AM »

woah


I'm really loving tv3d ouputs...

but to me its clear here's also quite cqualified coders...

Smiley
Logged
potato
Customers
Community Member
*****
Posts: 800


WWW
« Reply #6 on: July 19, 2004, 02:27:55 AM »

Flippin' amazing Cheesy Of all the graphical things being done to modern games, I think lighting is the one getting the least love. Good work  Cheesy
Logged
Slider
Community Member
*
Posts: 1135


« Reply #7 on: July 19, 2004, 05:11:15 AM »

hehe, I've done this some time ago with the same temple demo. It's done by rendering the scene to a small rendersurface, after that, you rescale the rendersurface to the original size. After rescaling, you have to multiply it with the original scene. There are some tricks involved but the output is amazing  Smiley
Logged

Slider is the name, and logic is my game...
Helping retards through life since 1981
BlindSide
Customers
Community Member
*****
Posts: 760


« Reply #8 on: July 19, 2004, 10:40:51 AM »

the light hot-spots are like emulated light-blooms, all Halo-2ish  :wink:
nice job, can't wait to see how you managed that.
Logged
Davidson
Community Member
*
Posts: 16


« Reply #9 on: July 19, 2004, 11:33:26 AM »

WOW that is amazing, great job. now this reminds me a lot about Guild Wars when I was at E3 and played it. the lighting in that game was amazing and this just might match the lighting done in GW great job Smiley
Logged
e!chhoernchen
Community Member
*
Posts: 327


WWW
« Reply #10 on: July 19, 2004, 01:42:03 PM »

hell yeah that is n1!  :wink:
Logged

BYTE-Smasher
Community Member
*
Posts: 956

vaporware makes baby jesus cry


WWW
« Reply #11 on: July 19, 2004, 02:15:03 PM »

wow... i feel all warm inside... thx for all the compliments Smiley

Another shot, while you guys patiently wait for some code...
Logged

Pavel
Customers
Community Member
*****
Posts: 850


WWW
« Reply #12 on: July 19, 2004, 02:37:30 PM »

soo much light, my eyes will burn
Logged

BYTE-Smasher
Community Member
*
Posts: 956

vaporware makes baby jesus cry


WWW
« Reply #13 on: July 19, 2004, 03:00:15 PM »

ok... so many people have been buggin me for this source, I'm going to post it... but I'm not giving you the clean version, cause ppl just won't be quiet!!

I'm still planning on cleaning it up... this includes all my crappy collision, etc...
controls:
arrows move...
"a" jumps...
"1" disables glow...
"2" enables glow...

have fun Tongue

Code:

Dim bsp As TVBSPTree
Dim Engine As TVEngine
Dim scene As New TVScene
Dim screen2d As New TVScreen2DImmediate
Dim alphabet As New TVScreen2DText
Dim doloop As Boolean
Dim bill2d As TVMesh
Dim DudePosition As D3DVECTOR
Dim DudeHeadPosition As D3DVECTOR
Dim DudeOldPosition As D3DVECTOR
Dim DudeNewPosition As D3DVECTOR
Dim CamPosition As D3DVECTOR
Dim DudeAngle As D3DVECTOR
Dim Eye As TVCamera
Dim colres As TV_COLLISIONRESULT
Dim RS1 As New TVRenderSurface
Dim RS2 As New TVRenderSurface
Dim RS3 As New TVRenderSurface
Dim RS4 As New TVRenderSurface
Dim TwoDee1 As New TVScreen2DImmediate
Dim TwoDee2 As New TVScreen2DImmediate
Const pi As Double = 3.14159265358979



Private Sub Form_Load()
doloop = True
Set Engine = New TVEngine
Engine.Init3DFullscreen 640, 480, 32, True, False, TV_DEPTHBUFFER_BESTBUFFER, , Me.hWnd
Engine.SetSearchDirectory App.Path
Engine.DisplayFPS = True
Engine.SetAngleSystem TV_ANGLE_DEGREE
Dim screenwidth As Long, screenheight As Long, screenbits As Long
Engine.GetVideoMode screenwidth, screenheight, screenbits

scene.SetSceneBackGround 0, 0, 0
Me.Show
scene.SetTextureFilter TV_FILTER_GAUSSIANCUBIC
scene.SetViewFrustum 65, 5000
scene.SetSpecularLightning True
scene.SetDithering False
Dim iosys As New TVInputEngine
Set bsp = New TVBSPTree
Engine.SetSearchDirectory "C:\tv3dsdk\media"

bsp.Load "C:\tv3dsdk\media\temple.bsp", True, True ', True
scene.SetCollisionPrecision 20
bsp.SetCurvePrecision TV_CURVE_HIGH
bsp.SetParameters True, True, TV_DOUBLESIDED, True
DudePosition.x = bsp.GetStartPlayerPosition.x
DudePosition.Y = bsp.GetStartPlayerPosition.Y + 10
DudePosition.Z = bsp.GetStartPlayerPosition.Z
Set Eye = New TVCamera
Set RS1 = scene.CreateRenderSurface(screenwidth, screenheight, True)
Set RS2 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
Set RS3 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
Set RS4 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_ONE
TwoDee1.SETTINGS_SetTextureFilter TV_FILTER_GAUSSIANCUBIC
iosys.EnableEvents True

Set bill2d = scene.CreateMeshBuilder
bill2d.CreateBox 3000, 2000, 2000
bill2d.SetPosition 0, 0, 300
Dim teapot As TVMesh
Set teapot = scene.CreateMeshBuilder
teapot.CreateTeapot
teapot.SetPosition -400, -200, 300
teapot.ScaleMesh 50, 50, 50
teapot.SetTexture RS4.GetTexture
teapot.EnableSphereMapping True
Do
    teapot.RotateY Engine.AccurateTimeElapsed / 10
        If iosys.IsKeyPressed(TV_KEY_1) Then
            glow = 0
        End If
        If iosys.IsKeyPressed(TV_KEY_2) Then
            glow = 1
        End If
        If iosys.IsKeyPressed(TV_KEY_3) Then
            glow = 2
        End If
       
       
        If iosys.IsKeyPressed(TV_KEY_UP) Then
            walk = 4
        ElseIf iosys.IsKeyPressed(TV_KEY_DOWN) Then
            walk = -4
        Else
            walk = 0
        End If
        If iosys.IsKeyPressed(TV_KEY_LEFTSHIFT) Or iosys.IsKeyPressed(TV_KEY_RIGHTSHIFT) Then
            walk = walk * 3
        End If
        If iosys.IsKeyPressed(TV_KEY_LEFT) Then
            DudeAngle.Y = DudeAngle.Y - 10
        ElseIf iosys.IsKeyPressed(TV_KEY_RIGHT) Then
            DudeAngle.Y = DudeAngle.Y + 10
        End If
        If iosys.IsKeyPressed(TV_KEY_PAGEUP) Then
            If lookangle > -90 Then
                lookangle = lookangle - 10
            End If
        ElseIf iosys.IsKeyPressed(TV_KEY_PAGEDOWN) Then
            If lookangle < 90 Then
                lookangle = lookangle + 10
            End If
        Else
            If Abs(lookangle) < 3 Then
                lookangle = 0
            End If
            If lookangle <> 0 Then
                lookangle = lookangle - (lookangle / Abs(lookangle)) * 5
            End If
        End If
        If iosys.IsKeyPressed(TV_KEY_A) Then
            If canjump = True Then jump = 400
        End If
        DudeOldPosition = DudePosition
        If jump > 0 Then
            jump = jump - 1
            DudePosition.Y = DudePosition.Y + 40
            DudeHeadPosition = DudePosition
            DudeHeadPosition.Y = DudeHeadPosition.Y + 90
           
            If bsp.DetectSphereCollision(DudeHeadPosition, 5) Then
                DudePosition = DudeOldPosition
                jump = 0
            End If
        End If
       
        distancefromwall = 20
       
        DudeOldPosition = DudePosition
        DudePosition.x = DudePosition.x + (Sin((DudeAngle.Y / 360) * pi * 2) * walk / 5 * Engine.TimeElapsed)
        DudePosition.Z = DudePosition.Z + (Cos((DudeAngle.Y / 360) * pi * 2) * walk / 5 * Engine.TimeElapsed)
        af = 20
        If bsp.SlidingCollision(Vector3(DudeOldPosition.x, DudeOldPosition.Y + af, DudeOldPosition.Z), Vector3(DudePosition.x, DudePosition.Y + af, DudePosition.Z), DudeNewPosition, 5) Then
            DudePosition = Vector3(DudeNewPosition.x, DudeNewPosition.Y - af, DudeNewPosition.Z)
        End If
        DudeOldPosition = DudePosition
       
        If DudePosition.Y <> bsp.StayOnFloor(DudePosition, , , 5) Then
            DudePosition.Y = DudePosition.Y - 20
            canjump = False
        Else
            canjump = True
        End If
        DudeHeadPosition = DudePosition
        DudeHeadPosition.Y = DudePosition.Y + 5
        If bsp.DetectSphereCollision(DudeHeadPosition, 5) Then
            DudePosition.Y = bsp.StayOnFloor(DudePosition, , , 5)
        End If
        DudeOldPosition = DudePosition
               
        Dim zoom As Integer
        zoom = 1
        Eye.SetPosition DudePosition.x, DudePosition.Y + 100, DudePosition.Z
        Eye.SetRotation lookangle, DudeAngle.Y, 0
       
        RS1.SetCamera Eye.GetPosition.x, Eye.GetPosition.Y, Eye.GetPosition.Z, Eye.GetLookAt.x, Eye.GetLookAt.Y, Eye.GetLookAt.Z
        RS1.StartRender True
            bsp.Render
            bill2d.Render
            teapot.Render
        RS1.EndRender
       
        TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_DESTALPHA, D3DBLEND_SRCALPHA
        RS2.StartRender True
            For cx = -10 To 10 Step 4
                TwoDee1.DRAW_Texture RS1.GetTexture, cx, -Rnd * 5, num2rs(screenwidth / 4) + cx, num2rs(screenwidth / 4) - (Rnd * 5), RGBA(1, 1, 1, 0.2)
            Next
        RS2.EndRender
        RS3.StartRender True
            For cy = -10 To 10 Step 4
                TwoDee1.DRAW_Texture RS2.GetTexture, -Rnd * 5, cy, num2rs(screenwidth / 4) - (Rnd * 5), num2rs(screenwidth / 4) + cy, RGBA(1, 1, 1, 0.2)
            Next
        RS3.EndRender
        RS4.SetViewFrustum 90, 4000
        RS4.SetCamera teapot.GetPosition.x, teapot.GetPosition.Y, teapot.GetPosition.Z, DudePosition.x, DudePosition.Y, DudePosition.Z
        RS4.StartRender
            bsp.Render
            bill2d.Render
        RS4.EndRender
       
        TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_ONE
       
        Engine.Clear
       
        i = 0.25
        coler = RGBA(0.8 * i, 0.5 * i, 0.4 * i, 1)
       
        TwoDee1.DRAW_Texture RS1.GetTexture, 0, 0, screenwidth, screenheight
       
        If glow = 1 Then
            TwoDee1.DRAW_Texture RS3.GetTexture, -20, -20, screenwidth + 20, screenheight + 30, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, 0, -20, screenwidth, screenheight + 30, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, -20, 0, screenwidth + 20, screenheight + 10, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, 0, 0, screenwidth, screenheight + 10, coler
        End If
       
        alphabet.NormalFont_DrawText "Coded by Shaun Winters", screenwidth - 179, screenheight - 56, RGBA(0, 0, 0, 100)
        alphabet.NormalFont_DrawText "Engine Powered by", screenwidth - 179, screenheight - 44, RGBA(0, 0, 0, 100)
        alphabet.NormalFont_DrawText "Coded by Shaun Winters", screenwidth - 180, screenheight - 57, RGBA(50, 50, 50, 100)
        alphabet.NormalFont_DrawText "Engine Powered by", screenwidth - 180, screenheight - 45, RGBA(50, 50, 50, 100)
        Engine.RenderToScreen
        DoEvents
Loop Until (doloop = False) Or iosys.IsKeyPressed(TV_KEY_ESCAPE)
Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
doloop = False
Engine.ReleaseAll
Set Engine = Nothing
End Sub
Function num2rs(ByVal sizeof As Long) As Long
Dim a
Do
    a = a + 1
    sizeof = sizeof \ 2
Loop Until sizeof = 0
If 2 ^ a = sizeof Then a = a - 1
num2rs = 2 ^ a
End Function
Logged

Slider
Community Member
*
Posts: 1135


« Reply #14 on: July 19, 2004, 03:45:15 PM »

Good job. With some optimizations this is a cool new sample for the TVSDK.
I made a slight modification on this. I removed the noticable lines to make it all a bit smoother:


Code:
Dim bsp As TVBSPTree
Dim Engine As TVEngine
Dim scene As New TVScene
Dim screen2d As New TVScreen2DImmediate
Dim alphabet As New TVScreen2DText
Dim doloop As Boolean
Dim bill2d As TVMesh
Dim DudePosition As D3DVECTOR
Dim DudeHeadPosition As D3DVECTOR
Dim DudeOldPosition As D3DVECTOR
Dim DudeNewPosition As D3DVECTOR
Dim CamPosition As D3DVECTOR
Dim DudeAngle As D3DVECTOR
Dim Eye As TVCamera
Dim colres As TV_COLLISIONRESULT
Dim RS1 As New TVRenderSurface
Dim RS2 As New TVRenderSurface
Dim RS3 As New TVRenderSurface
Dim RS4 As New TVRenderSurface
Dim TwoDee1 As New TVScreen2DImmediate
Dim TwoDee2 As New TVScreen2DImmediate
Const pi As Double = 3.14159265358979



Private Sub Form_Load()
doloop = True
Set Engine = New TVEngine
Engine.Init3DFullscreen 640, 480, 32, True, False, TV_DEPTHBUFFER_BESTBUFFER, , Me.hWnd
Engine.SetSearchDirectory App.Path
Engine.DisplayFPS = True
Engine.SetAngleSystem TV_ANGLE_DEGREE
Dim screenwidth As Long, screenheight As Long, screenbits As Long
Engine.GetVideoMode screenwidth, screenheight, screenbits

scene.SetSceneBackGround 0, 0, 0
Me.Show
scene.SetTextureFilter TV_FILTER_GAUSSIANCUBIC
scene.SetViewFrustum 65, 5000
scene.SetSpecularLightning True
scene.SetDithering False
Dim iosys As New TVInputEngine
Set bsp = New TVBSPTree
Engine.SetSearchDirectory App.Path + "\..\..\..\Media"

bsp.Load "Temple.bsp", True, True ', True
scene.SetCollisionPrecision 20
bsp.SetCurvePrecision TV_CURVE_HIGH
bsp.SetParameters True, True, TV_DOUBLESIDED, True
DudePosition.x = bsp.GetStartPlayerPosition.x
DudePosition.y = bsp.GetStartPlayerPosition.y + 10
DudePosition.z = bsp.GetStartPlayerPosition.z
Set Eye = New TVCamera
Set RS1 = scene.CreateRenderSurface(screenwidth, screenheight, True)
Set RS2 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
Set RS3 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
Set RS4 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_ONE
TwoDee1.SETTINGS_SetTextureFilter TV_FILTER_GAUSSIANCUBIC
iosys.EnableEvents True

Set bill2d = scene.CreateMeshBuilder
bill2d.CreateBox 3000, 2000, 2000
bill2d.SetPosition 0, 0, 300
Dim teapot As TVMesh
Set teapot = scene.CreateMeshBuilder
teapot.CreateTeapot
teapot.SetPosition -400, -200, 300
teapot.ScaleMesh 50, 50, 50
teapot.SetTexture RS4.GetTexture
teapot.EnableSphereMapping True
Do
    teapot.RotateY Engine.AccurateTimeElapsed / 10
        If iosys.IsKeyPressed(TV_KEY_1) Then
            glow = 0
        End If
        If iosys.IsKeyPressed(TV_KEY_2) Then
            glow = 1
        End If
        If iosys.IsKeyPressed(TV_KEY_3) Then
            glow = 2
        End If
       
       
        If iosys.IsKeyPressed(TV_KEY_UP) Then
            walk = 4
        ElseIf iosys.IsKeyPressed(TV_KEY_DOWN) Then
            walk = -4
        Else
            walk = 0
        End If
        If iosys.IsKeyPressed(TV_KEY_LEFTSHIFT) Or iosys.IsKeyPressed(TV_KEY_RIGHTSHIFT) Then
            walk = walk * 3
        End If
        If iosys.IsKeyPressed(TV_KEY_LEFT) Then
            DudeAngle.y = DudeAngle.y - 10
        ElseIf iosys.IsKeyPressed(TV_KEY_RIGHT) Then
            DudeAngle.y = DudeAngle.y + 10
        End If
        If iosys.IsKeyPressed(TV_KEY_PAGEUP) Then
            If lookangle > -90 Then
                lookangle = lookangle - 10
            End If
        ElseIf iosys.IsKeyPressed(TV_KEY_PAGEDOWN) Then
            If lookangle < 90 Then
                lookangle = lookangle + 10
            End If
        Else
            If Abs(lookangle) < 3 Then
                lookangle = 0
            End If
            If lookangle <> 0 Then
                lookangle = lookangle - (lookangle / Abs(lookangle)) * 5
            End If
        End If
        If iosys.IsKeyPressed(TV_KEY_A) Then
            If canjump = True Then jump = 400
        End If
        DudeOldPosition = DudePosition
        If jump > 0 Then
            jump = jump - 1
            DudePosition.y = DudePosition.y + 40
            DudeHeadPosition = DudePosition
            DudeHeadPosition.y = DudeHeadPosition.y + 90
           
            If bsp.DetectSphereCollision(DudeHeadPosition, 5) Then
                DudePosition = DudeOldPosition
                jump = 0
            End If
        End If
       
        distancefromwall = 20
       
        DudeOldPosition = DudePosition
        DudePosition.x = DudePosition.x + (Sin((DudeAngle.y / 360) * pi * 2) * walk / 5 * Engine.TimeElapsed)
        DudePosition.z = DudePosition.z + (Cos((DudeAngle.y / 360) * pi * 2) * walk / 5 * Engine.TimeElapsed)
        af = 20
        If bsp.SlidingCollision(Vector3(DudeOldPosition.x, DudeOldPosition.y + af, DudeOldPosition.z), Vector3(DudePosition.x, DudePosition.y + af, DudePosition.z), DudeNewPosition, 5) Then
            DudePosition = Vector3(DudeNewPosition.x, DudeNewPosition.y - af, DudeNewPosition.z)
        End If
        DudeOldPosition = DudePosition
       
        If DudePosition.y <> bsp.StayOnFloor(DudePosition, , , 5) Then
            DudePosition.y = DudePosition.y - 20
            canjump = False
        Else
            canjump = True
        End If
        DudeHeadPosition = DudePosition
        DudeHeadPosition.y = DudePosition.y + 5
        If bsp.DetectSphereCollision(DudeHeadPosition, 5) Then
            DudePosition.y = bsp.StayOnFloor(DudePosition, , , 5)
        End If
        DudeOldPosition = DudePosition
               
        Dim zoom As Integer
        zoom = 1
        Eye.SetPosition DudePosition.x, DudePosition.y + 100, DudePosition.z
        Eye.SetRotation lookangle, DudeAngle.y, 0
       
        RS1.SetCamera Eye.GetPosition.x, Eye.GetPosition.y, Eye.GetPosition.z, Eye.GetLookAt.x, Eye.GetLookAt.y, Eye.GetLookAt.z
        RS1.StartRender True
            bsp.Render
            bill2d.Render
            teapot.Render
        RS1.EndRender
       
        TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_DESTALPHA, D3DBLEND_SRCALPHA
       
        RS2.StartRender True
            Dim PosX As Integer
            PosX = 0
            For cx = -10 To 10 Step 4
                TwoDee1.DRAW_Texture RS1.GetTexture, PosX, -1, num2rs(screenwidth / 4) + PosX, num2rs(screenwidth / 4) - 1, RGBA(1, 1, 1, 0.2)
                PosX = PosX + 1
            Next
        RS2.EndRender
        RS3.StartRender True
            Dim PosY As Integer
            PosY = 0
            For cy = -10 To 10 Step 4
                TwoDee1.DRAW_Texture RS2.GetTexture, -1, PosY, num2rs(screenwidth / 4) - 1, num2rs(screenwidth / 4) + PosY, RGBA(1, 1, 1, 0.2)
                PosY = PosY + 1
            Next
        RS3.EndRender
        RS4.SetViewFrustum 90, 4000
        RS4.SetCamera teapot.GetPosition.x, teapot.GetPosition.y, teapot.GetPosition.z, DudePosition.x, DudePosition.y, DudePosition.z
        RS4.StartRender
            bsp.Render
            bill2d.Render
        RS4.EndRender
       
        TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_ONE
       
        Engine.Clear
       
        i = 0.25
        coler = RGBA(0.8 * i, 0.5 * i, 0.4 * i, 1)
       
        TwoDee1.DRAW_Texture RS1.GetTexture, 0, 0, screenwidth, screenheight
       
        If glow = 1 Then
                 
            TwoDee1.DRAW_Texture RS3.GetTexture, -1, -1, screenwidth - 1, screenheight - 1, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, -1, 0, screenwidth - 1, screenheight, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, -1, 1, screenwidth - 1, screenheight + 1, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, 0, -1, screenwidth, screenheight - 1, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, 0, 1, screenwidth, screenheight + 1, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, 1, -1, screenwidth + 1, screenheight - 1, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, 1, 0, screenwidth, screenheight, coler
            TwoDee1.DRAW_Texture RS3.GetTexture, 1, 1, screenwidth, screenheight, coler
        End If
       
        alphabet.NormalFont_DrawText "Coded by Shaun Winters", screenwidth - 179, screenheight - 56, RGBA(0, 0, 0, 100)
        alphabet.NormalFont_DrawText "Engine Powered by", screenwidth - 179, screenheight - 44, RGBA(0, 0, 0, 100)
        alphabet.NormalFont_DrawText "Coded by Shaun Winters", screenwidth - 180, screenheight - 57, RGBA(50, 50, 50, 100)
        alphabet.NormalFont_DrawText "Engine Powered by", screenwidth - 180, screenheight - 45, RGBA(50, 50, 50, 100)
        Engine.RenderToScreen
        DoEvents
Loop Until (doloop = False) Or iosys.IsKeyPressed(TV_KEY_ESCAPE)
Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
doloop = False
Engine.ReleaseAll
Set Engine = Nothing
End Sub
Function num2rs(ByVal sizeof As Long) As Long
Dim a
Do
    a = a + 1
    sizeof = sizeof \ 2
Loop Until sizeof = 0
If 2 ^ a = sizeof Then a = a - 1
num2rs = 2 ^ a
End Function
Logged

Slider is the name, and logic is my game...
Helping retards through life since 1981
GoodVillain
Community Member
*
Posts: 1631


« Reply #15 on: July 19, 2004, 04:09:54 PM »

A little slow but thats some good stuff. Smiley
Logged
BYTE-Smasher
Community Member
*
Posts: 956

vaporware makes baby jesus cry


WWW
« Reply #16 on: July 19, 2004, 04:46:51 PM »

slider: don't quite know what optimizations you made, but all I see is white... until i fall thought the floor... though, when I stole the inside of the loop, I noticed a little difference, mostly the glow looked different... brighter... not as blurred... and the framerate was identical...
Logged

Slider
Community Member
*
Posts: 1135


« Reply #17 on: July 19, 2004, 06:14:27 PM »

Quote from: "BYTE-Smasher"
slider: don't quite know what optimizations you made, but all I see is white... until i fall thought the floor... though, when I stole the inside of the loop, I noticed a little difference, mostly the glow looked different... brighter... not as blurred... and the framerate was identical...


Well, you probably see white because I changed the Media directory path.  :wink:
I changed the offset of the rendersurfaces, because you had a quiet large offset, there were stripes noticable.
Logged

Slider is the name, and logic is my game...
Helping retards through life since 1981
BYTE-Smasher
Community Member
*
Posts: 956

vaporware makes baby jesus cry


WWW
« Reply #18 on: July 19, 2004, 08:48:27 PM »

aah... ok... actually i know the offset was large.... I liked it that way Tongue ... I thought the chaos it caused made the scene look a bit more natural.... and I liked the wideness of the glow... so I hope you won't be offended if I keep my source that way :wink:.... I'm glad you like the effect though... and I hope you find it useful...
Logged

Slider
Community Member
*
Posts: 1135


« Reply #19 on: July 20, 2004, 10:47:45 AM »

Here's a new version with which you can control the size and alpha of the glow.
Use +/- and PAGEUP/PAGEDOWN to change.


Code:
Dim bsp As TVBSPTree
Dim Engine As TVEngine
Dim scene As New TVScene
Dim screen2d As New TVScreen2DImmediate
Dim alphabet As New TVScreen2DText
Dim doloop As Boolean
Dim bill2d As TVMesh
Dim DudePosition As D3DVECTOR
Dim DudeHeadPosition As D3DVECTOR
Dim DudeOldPosition As D3DVECTOR
Dim DudeNewPosition As D3DVECTOR
Dim CamPosition As D3DVECTOR
Dim DudeAngle As D3DVECTOR
Dim Eye As TVCamera
Dim colres As TV_COLLISIONRESULT
Dim RS1 As New TVRenderSurface
Dim RS2 As New TVRenderSurface
Dim RS3 As New TVRenderSurface
Dim RS4 As New TVRenderSurface
Dim TwoDee1 As New TVScreen2DImmediate
Dim TwoDee2 As New TVScreen2DImmediate
Const pi As Double = 3.14159265358979

Dim LightSize As Single
Dim LightAlpha As Single


Private Sub Form_Load()
doloop = True
Set Engine = New TVEngine
Engine.Init3DFullscreen 1024, 768, 32, True, False, TV_DEPTHBUFFER_BESTBUFFER, , Me.hWnd
Engine.SetSearchDirectory App.Path
Engine.DisplayFPS = True
Engine.SetAngleSystem TV_ANGLE_DEGREE
Dim screenwidth As Long, screenheight As Long, screenbits As Long
Engine.GetVideoMode screenwidth, screenheight, screenbits

scene.SetSceneBackGround 0, 0, 0
Me.Show
scene.SetTextureFilter TV_FILTER_GAUSSIANCUBIC
scene.SetViewFrustum 65, 5000
scene.SetSpecularLightning True
scene.SetDithering False
Dim iosys As New TVInputEngine
Set bsp = New TVBSPTree
Engine.SetSearchDirectory App.Path + "\..\..\..\Media"

bsp.Load "Temple.bsp", True, True ', True
scene.SetCollisionPrecision 20
bsp.SetCurvePrecision TV_CURVE_HIGH
bsp.SetParameters True, True, TV_DOUBLESIDED, True
DudePosition.x = bsp.GetStartPlayerPosition.x
DudePosition.y = bsp.GetStartPlayerPosition.y + 10
DudePosition.z = bsp.GetStartPlayerPosition.z
Set Eye = New TVCamera
Set RS1 = scene.CreateRenderSurface(screenwidth, screenheight, True)
Set RS2 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
Set RS3 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)
Set RS4 = scene.CreateRenderSurface(screenwidth / 4, screenwidth / 4, True)

TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_ONE
TwoDee1.SETTINGS_SetTextureFilter TV_FILTER_GAUSSIANCUBIC
iosys.EnableEvents True

Set bill2d = scene.CreateMeshBuilder
bill2d.CreateBox 3000, 2000, 2000
bill2d.SetPosition 0, 0, 300
Dim teapot As TVMesh
Set teapot = scene.CreateMeshBuilder
teapot.CreateTeapot
teapot.SetPosition -400, -200, 300
teapot.ScaleMesh 50, 50, 50
teapot.SetTexture RS4.GetTexture
teapot.EnableSphereMapping True
LightSize = 5
LightAlpha = 1

Do
    teapot.RotateY Engine.AccurateTimeElapsed / 10
        If iosys.IsKeyPressed(TV_KEY_1) Then
            glow = 0
        End If
        If iosys.IsKeyPressed(TV_KEY_2) Then
            glow = 1
        End If
       
       
        If iosys.IsKeyPressed(TV_KEY_UP) Then
            walk = 4
        ElseIf iosys.IsKeyPressed(TV_KEY_DOWN) Then
            walk = -4
        Else
            walk = 0
        End If
        If iosys.IsKeyPressed(TV_KEY_ADD) Then
            LightSize = LightSize + 1
        End If
        If iosys.IsKeyPressed(TV_KEY_SUBTRACT) Then
            LightSize = LightSize - 1
        End If

        If iosys.IsKeyPressed(TV_KEY_LEFTSHIFT) Or iosys.IsKeyPressed(TV_KEY_RIGHTSHIFT) Then
            walk = walk * 3
        End If
        If iosys.IsKeyPressed(TV_KEY_LEFT) Then
            DudeAngle.y = DudeAngle.y - 10
        ElseIf iosys.IsKeyPressed(TV_KEY_RIGHT) Then
            DudeAngle.y = DudeAngle.y + 10
        End If
        If iosys.IsKeyPressed(TV_KEY_PAGEUP) Then
            LightAlpha = LightAlpha + 0.01
            If LightAlpha > 1 Then LightAlpha = 1
        ElseIf iosys.IsKeyPressed(TV_KEY_PAGEDOWN) Then
            LightAlpha = LightAlpha - 0.01
            If LightAlpha < 0 Then LightAlpha = 0
        Else
            If Abs(lookangle) < 3 Then
                lookangle = 0
            End If
            If lookangle <> 0 Then
                lookangle = lookangle - (lookangle / Abs(lookangle)) * 5
            End If
        End If
        If iosys.IsKeyPressed(TV_KEY_A) Then
            If canjump = True Then jump = 400
        End If
        DudeOldPosition = DudePosition
        If jump > 0 Then
            jump = jump - 1
            DudePosition.y = DudePosition.y + 40
            DudeHeadPosition = DudePosition
            DudeHeadPosition.y = DudeHeadPosition.y + 90
           
            If bsp.DetectSphereCollision(DudeHeadPosition, 5) Then
                DudePosition = DudeOldPosition
                jump = 0
            End If
        End If
       
        distancefromwall = 20
       
        DudeOldPosition = DudePosition
        DudePosition.x = DudePosition.x + (Sin((DudeAngle.y / 360) * pi * 2) * walk / 5 * Engine.TimeElapsed)
        DudePosition.z = DudePosition.z + (Cos((DudeAngle.y / 360) * pi * 2) * walk / 5 * Engine.TimeElapsed)
        af = 20
        If bsp.SlidingCollision(Vector3(DudeOldPosition.x, DudeOldPosition.y + af, DudeOldPosition.z), Vector3(DudePosition.x, DudePosition.y + af, DudePosition.z), DudeNewPosition, 5) Then
            DudePosition = Vector3(DudeNewPosition.x, DudeNewPosition.y - af, DudeNewPosition.z)
        End If
        DudeOldPosition = DudePosition
       
        If DudePosition.y <> bsp.StayOnFloor(DudePosition, , , 5) Then
            DudePosition.y = DudePosition.y - 20
            canjump = False
        Else
            canjump = True
        End If
        DudeHeadPosition = DudePosition
        DudeHeadPosition.y = DudePosition.y + 5
        If bsp.DetectSphereCollision(DudeHeadPosition, 5) Then
            DudePosition.y = bsp.StayOnFloor(DudePosition, , , 5)
        End If
        DudeOldPosition = DudePosition
               
        Dim zoom As Integer
        zoom = 1
        Eye.SetPosition DudePosition.x, DudePosition.y + 100, DudePosition.z
        Eye.SetRotation lookangle, DudeAngle.y, 0
       
        'render the scene to a rendersurface.
        RS1.SetCamera Eye.GetPosition.x, Eye.GetPosition.y, Eye.GetPosition.z, Eye.GetLookAt.x, Eye.GetLookAt.y, Eye.GetLookAt.z
        RS1.StartRender True
            bsp.Render
            bill2d.Render
            teapot.Render
        RS1.EndRender
       
        TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ZERO, D3DBLEND_SRCCOLOR
        'do the "dark pass / multiply pass"
        RS4.StartRender True
            TwoDee1.DRAW_Texture RS1.GetTexture, 0, 0, num2rs(screenwidth / 8), num2rs(screenwidth / 8), RGBA(1, 1, 1, 1)
        RS4.EndRender
       
        'blur x
        TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_SRCALPHA
        RS2.StartRender True
            Dim PosX As Integer
            PosX = -4
            For cx = 0 To LightSize Step 1
                TwoDee1.DRAW_Texture RS4.GetTexture, PosX, 0, num2rs(screenwidth / 8) + PosX, num2rs(screenwidth / 8), RGBA(1, 1, 1, 0.2)
                PosX = PosX + 1
            Next
        RS2.EndRender
       
        'blur y
        RS3.StartRender True
            Dim PosY As Integer
            PosY = -4
            For cy = 0 To LightSize Step 1
                TwoDee1.DRAW_Texture RS2.GetTexture, 0, PosY, num2rs(screenwidth / 8), num2rs(screenwidth / 8) + PosY, RGBA(0.5, 0.5, 0.5, 0.2)
                PosY = PosY + 1
            Next
        RS3.EndRender

       
       
        Engine.Clear
       
        i = 1
        'light alpha color.
        coler = RGBA(LightAlpha, LightAlpha, LightAlpha, 1)
       
        'draw normal scene to screen.
        TwoDee1.DRAW_Texture RS1.GetTexture, 0, 0, screenwidth, screenheight
        TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_SRCALPHA, D3DBLEND_SRCALPHA
       
        'additive blend the glowed scene to screen.
        If glow = 1 Then
            TwoDee1.SETTINGS_SetBlendingMode D3DBLEND_ONE, D3DBLEND_ONE
            TwoDee1.DRAW_Texture RS3.GetTexture, 0, 0, screenwidth, screenheight, coler
        End If
       
        'some information we want to know.
        alphabet.NormalFont_DrawText "Size: " & CStr(LightSize), 10, 50, RGBA(1, 0, 0, 100)
        alphabet.NormalFont_DrawText "Alpha: " & CStr(LightAlpha), 10, 60, RGBA(1, 0, 0, 100)
       

        Engine.RenderToScreen
        DoEvents
Loop Until (doloop = False) Or iosys.IsKeyPressed(TV_KEY_ESCAPE)
Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
doloop = False
Engine.ReleaseAll
Set Engine = Nothing
End Sub
Function num2rs(ByVal sizeof As Long) As Long
Dim a
Do
    a = a + 1
    sizeof = sizeof \ 2
Loop Until sizeof = 0
If 2 ^ a = sizeof Then a = a - 1
num2rs = 2 ^ a
End Function
Logged

Slider is the name, and logic is my game...
Helping retards through life since 1981
Pages: [1] 2
  Print  
 
Jump to:  

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