January 26, 2021, 05:35:46 AM

### Author Topic: [bb] Motion blur FX by Matt Merkulov [ 1+ years ago ]  (Read 666 times)

#### BlitzBot

• Jr. Member
• Posts: 1
##### [bb] Motion blur FX by Matt Merkulov [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : Motion blur FX
Author : Matt Merkulov
Posted : 1+ years ago

Description : From article:<a href="http://blitzetcetera.org/index.php/Ð­Ñ„Ñ„ÐµÐºÑ‚Ñ‹_Ñ€Ð°Ð·Ð¼Ñ‹Ñ‚Ð¸Ñ_Ð²_Ñ€ÐµÐ°Ð»ÑŒÐ½Ð¾Ð¼_Ð²Ñ€ÐµÐ¼ÐµÐ½Ð¸" target="_blank"> Real-time motion blur FX[/url] (rus)

Code :
Code: BlitzBasic
1. ;14 real-time 3D motion blur FX presets by Matt Merkulov
2.
3. ; The size of a structure, number of effect, the order of a portrayal(-1 or 1)
4. Const texsize=1024, fx=7, o =-1
5.
6. Graphics3D 800,600,32
7.
8. cam=CreateCamera()
9. PositionEntity cam, 0,0,-6
10. RotateEntity CreateLight(), 45,0,0
11.
12. ; Creation of a stage
13. cube=CreateCube()
14. EntityColor cube, 255,128,0
15. cone1=CreateCone(20)
16. EntityColor cone1,0,255,255
17. PositionEntity cone1,-4,0,0
18. cone2=CreateCone(20)
19. EntityColor cone2,0,255,0
20. PositionEntity cone2,4,0,0
21. p=CreatePivot()
22. sph=CreateSphere(20, p)
23. PositionEntity sph, 0,0,-4
24.
25. Select fx
26.  Case 1:bl=createblurlayer(cam, 1,0,1,1, .95,1, o)
27.  Case 2:bl=createblurlayer(cam, 1,0,1, .97,1,3, o)
28.  Case 3:bl=createblurlayer(cam, 1, .2,1.02, .97,1,3, o)
29.  Case 4:bl=createblurlayer(cam, 1,0,1.01,1, .95,1, o)
30.  Case 5
31.  bl=createblurlayer(cam, 1,0,1.01,1, .9,1, o)
32.  EntityColor bl, 240,255,225
33.  Case 6
34.  bl=createblurlayer(cam, 1.1,0,1,1, .95,1, o)
35.  RotateEntity bl, 1,1,0
36.  Case 7
37.  bl=createblurlayer(cam, 1.01,1,1,1, .9,1, o)
38.  bl2=createblurlayer(cam, 1.02,-1,1,1, .8,1, o)
39. End Select
40.
41. SetBuffer BackBuffer()
42. While Not KeyHit(1)
43.  TurnEntity cube, .1, .2, .3
44.  TurnEntity p, .55, .35, .2
45.  RenderWorld
46.  bltex=updateblurlayer(bl, bltex)
47.  If bl2 Then EntityTexture bl2, bltex
48.  If fx=4 Then PositionEntity bl, Rnd(-.01, .01), Rnd(-.01, .01), 1
49.  Flip
50. Wend
51.
52. ; Function of creation of a layer of the degradation adhered to the chamber - returns the address of a layer
53. Function createblurlayer(cam, z#, ang#, mgn#, bright#, alpha#, bmode, ord)
54. Local xres=GraphicsWidth()
55. Local yres=GraphicsHeight()
56. layer=CreateMesh(cam)
57. s=CreateSurface(layer)
58. ; Calculation of coordinates of a structure
59. vx#= 1.0*xres/texsize
60. vy#= 1.0*yres/texsize
62. AddVertex s, 1,-1,0, vx#, 0
64. AddVertex s, 1,1,0, vx#, vy#
67. ; Definition of sizes for installation of a rectangular directly in front of the chamber by
68. ; Calculations of screen coordinates of a point of the three-dimensional world
69. PositionEntity layer, 1,1, z#
70. CameraProject cam, EntityX(layer, True), EntityY(layer, True), EntityZ(layer, True)
71. rx#= ProjectedX#()-.5*xres
72. ry#= ProjectedY#()-.5*yres
73. ; Scaling a layer
74. ScaleMesh layer, .5*xres/rx#,.5*yres/ry#, 1
75. ; Sdlvig a rectangular on polpiksela to the left-upwards that it(he) was in the center of the screen
76. PositionEntity layer,-.5/rx#,-.5/ry#, z#
77. RotateEntity layer, 0,0, ang#
78. ; The task of effects of a layer
79. ScaleEntity layer, mgn#, mgn#, mgn#
80. EntityAlpha layer, alpha#
81. EntityBlend layer, bmode
82. col=255*bright#
83. EntityColor layer, col, col, col
84. EntityFX layer, 1
85. EntityOrder layer, ord
86. Return layer
87. End Function
88.
89. ; Function of updating of a layer(returns the address of a structure)
90. ; It is necessary to cause each time after RenderWorld
91. Function updateblurlayer(layer, tex)
92. If tex=0 Then tex=CreateTexture(texsize, texsize)
93. EntityTexture layer, tex
94. CopyRect 0,0, GraphicsWidth(), GraphicsHeight(), 0,0, BackBuffer(), TextureBuffer(tex)
95. Return tex
96. End Function

ingenium(Posted 1+ years ago)

Nvm

puki(Posted 1+ years ago)

For any beginners confused by this - you select the number of the effect each time you run the program - ie change the value of the Const variable 'fx' at the beginning of the code - then run the program.EDIT:However, that value has a range of 1 to 7.

Matt Merkulov(Posted 1+ years ago)

Thanks, this is useful addition, maybe somebody really can be confused.

chwaga(Posted 1+ years ago)

How could I put the code necesarry into an include function, so I could call it in easily as if it were a command later?  (I'm a nub at this )