November 25, 2020, 07:56:33 AM

Author Topic: [bb] 3D Lens Flare by Spacechimp [ 1+ years ago ]  (Read 574 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] 3D Lens Flare by Spacechimp [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : 3D Lens Flare
Author : Spacechimp
Posted : 1+ years ago

Description : 1 light, 3 lens reflections, and distance adjustment

this will not take into account objects that come between the light and the camera


Code :
Code: BlitzBasic
  1. Type Make_Light
  2.         Field Light_Sprite
  3.         Field Flare_Sprite1
  4.         Field Flare_Sprite2
  5.         Field Flare_Sprite3
  6.         Field LF_pivot1
  7.         Field LF_pivot2
  8.                 Field Screen_Wash_Alpha1#
  9.                         Field light_bright#
  10.                                 Field Light_Bright_size#
  11.                                         Field Light1_Distance#
  12.                                         Field Flare1_Distance#
  13.                                         Field Flare2_Distance#
  14.                                         Field Flare3_Distance#
  15.                                                 Field FLareX_Ang#
  16.                                                 Field FLareY_Ang#
  17.                                         End Type
  18. ;###################
  19. MAIN LOOP
  20. ;###################
  21.  
  22.  
  23. ;************************************************
  24. Places then updates coordinates for placing
  25. ;************************************************
  26. If Light_Create = False And Place_light = 3 Then
  27. Make_Lens_Flare = True
  28. Light_Create = True
  29. EndIf
  30.  
  31. If Light_Create = False And Place_light = 2 Then
  32. LightX_Pos# = 100
  33. LightY_Pos# = 100
  34. LightZ_Pos# = 100
  35. Place_light =  3
  36. EndIf
  37.  
  38. If Light_Create = False And Place_light = 1 Then
  39. LightX_Pos# = 200
  40. LightY_Pos# = -100
  41. LightZ_Pos# = 100
  42. Place_light =  2
  43. EndIf
  44.  
  45. If Light_Create = False And Place_light = 0 Then
  46. LightX_Pos# = 0
  47. LightY_Pos# = 0
  48. LightZ_Pos# = 0
  49. Place_light =  1
  50. EndIf
  51.  
  52.  
  53.  
  54.  
  55. If Make_Lens_Flare = False Then
  56. New_Light.Make_Light = New Make_Light
  57.  
  58.         New_LightLight_Sprite = LoadSprite("sprites/LightA.png")
  59.                         PositionEntity
  60.  
  61. New_LightLight_Sprite,LightX_Pos#,LightY_Pos#,LightZ_Pos#
  62.                        
  63.                 New_LightFlare_Sprite1 =
  64.  
  65. LoadSprite("sprites/FlareA.png")
  66.                         EntityParent
  67.  
  68. New_LightFlare_Sprite1,New_LightLight_Sprite
  69.                        
  70.                         New_LightFlare_Sprite2 =
  71.  
  72. LoadSprite("sprites/FlareA.png")
  73.                                 EntityParent
  74.  
  75. New_LightFlare_Sprite2,New_LightLight_Sprite
  76.                        
  77.                                 New_LightFlare_Sprite3 =
  78.  
  79. LoadSprite("sprites/FlareA.png")
  80.                                         EntityParent
  81.  
  82. New_LightFlare_Sprite3,New_LightLight_Sprite
  83.                                
  84.         New_LightLF_pivot1 = CreatePivot()
  85.                 EntityParent New_LightLF_pivot1,camera
  86.                 New_LightLF_pivot2 = CreatePivot()
  87.                         EntityParent
  88.  
  89. New_LightLF_pivot2,New_LightLight_Sprite
  90.  
  91.        
  92. New_Lightlight_bright# =
  93.  
  94. EntityDistance(New_LightLF_pivot2,New_LightLight_Sprite)
  95.  
  96. New_LightScreen_Wash_Alpha1# = (-light_bright# + 30) / 60
  97. EndIf
  98.  
  99.        
  100.         For New_Light.Make_Light = Each Make_Light
  101.  
  102.  
  103.  
  104. PointEntity New_LightLF_pivot1,New_LightLight_Sprite
  105.  
  106.  
  107. New_LightLight_Bright_size# = (-light_bright# + 30) / 6
  108.         If New_LightLight_Bright_size# < 1 Then
  109.         New_LightLight_Bright_size# = 1
  110.         EndIf
  111.  
  112. New_LightLight1_Distance# =
  113.  
  114. EntityDistance(New_LightLight_Sprite,camera) / 5
  115. New_LightFlare1_Distance# =
  116.  
  117. EntityDistance(New_LightLight_Sprite,camera) / 6
  118.         New_LightFlare2_Distance# =
  119.  
  120. EntityDistance(New_LightLight_Sprite,camera) / 15
  121.                 New_LightFlare3_Distance# =
  122.  
  123. EntityDistance(New_LightLight_Sprite,camera) / 30
  124.  
  125. New_LightFLareX_Ang# = (EntityPitch(New_LightLF_pivot1) -
  126.  
  127. EntityPitch(camera)) *
  128.  
  129. EntityDistance(New_LightLight_Sprite,New_LightLF_pivot1) / 139
  130.         New_LightFLareY_Ang# = (EntityYaw(New_LightLF_pivot1) -
  131.  
  132. EntityYaw(camera)) *
  133.  
  134. EntityDistance(New_LightLight_Sprite,New_LightLF_pivot1) / 139
  135.  
  136.  
  137. ScaleSprite New_LightLight_Sprite,New_LightLight1_Distance#  *
  138.  
  139. New_LightLight_Bright_size# ,New_LightLight1_Distance# *
  140.  
  141. New_LightLight_Bright_size#
  142. ScaleSprite New_LightFlare_Sprite1,New_LightFlare1_Distance# /
  143.  
  144. 3,New_LightFlare1_Distance# / 3
  145.         ScaleSprite
  146.  
  147. New_LightFlare_Sprite2,New_LightFlare2_Distance# /
  148.  
  149. 3,New_LightFlare2_Distance# / 3
  150.                 ScaleSprite
  151.  
  152. New_LightFlare_Sprite3,New_LightFlare3_Distance# /
  153.  
  154. 2,New_LightFlare3_Distance# / 2
  155.  
  156.                
  157. PositionEntity New_LightFlare_Sprite3,New_LightFLareY_Ang# /
  158.  
  159. 2,New_LightFLareX_Ang# / 2,1
  160.         PositionEntity New_LightFlare_Sprite2,New_LightFLareY_Ang#
  161.  
  162. / 3,New_LightFLareX_Ang# / 3,2
  163.                 PositionEntity
  164.  
  165. New_LightFlare_Sprite1,New_LightFLareY_Ang# /
  166.  
  167. 6,New_LightFLareX_Ang# / 6,3
  168.                
  169. PositionEntity
  170.  
  171. New_LightLF_pivot2,EntityYaw(New_LightLF_pivot1),EntityPitch(New_L
  172.  
  173. ightLF_pivot1),0
  174.        
  175. Next


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal