同人星球BBS -> 游戏制作 -> [Blitz3D]動態模糊效果:Motion Blur [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

djgcn 07-01-19 14:22

你需要Blitz3D(1.80以上版本)編譯運行,請關閉DEBUG
範例與源碼見附件,請用+/-調整視覺效果。

原理:生成新的Entity,造成疊加效果,此功能增加運算&顯卡負擔
作者:Bliz Code Archive
授權:Public Domain

Copy code
Function CreateBlurImage()
   ;Create blur camera
   Local cam = CreateCamera()
   CameraClsMode cam, 0, 0
   CameraRange cam, 0.1, 1.5
   MoveEntity cam, 0, 0, 10000

   ark_sw = GraphicsWidth()
   ark_sh = GraphicsHeight()
   
   
   ;Create sprite
   Local spr = CreateMesh(cam)
   Local sf = CreateSurface(spr)
   AddVertex sf, -1, 1, 0, 0, 0
   AddVertex sf, 1, 1, 0, 1, 0
   AddVertex sf, -1, -1, 0, 0, 1
   AddVertex sf, 1, -1, 0, 1, 1
   AddTriangle sf, 0, 1, 2
   AddTriangle sf, 3, 2, 1
   EntityFX spr, 17
   ScaleEntity spr, 1024.0 / Float(ark_sw), 1024.0 / Float(ark_sw), 1
   PositionEntity spr, 0, 0, 1.0001
   EntityOrder spr, -100000
   EntityBlend spr, 1
   ark_blur_image = spr
   
   ;Create blur texture
   ark_blur_texture = CreateTexture(1024, 1024, 256)
   EntityTexture spr, ark_blur_texture
End Function

Function UpdateBlur(power#)
   EntityAlpha ark_blur_image, power#
   CopyRect ark_sw / 2 - 512, ark_sh / 2 - 512, 1024, 1024, 0, 0, BackBuffer(), TextureBuffer(ark_blur_texture)    
End Function

littlewater 07-01-28 10:27
仔细看了一下,有一些地方还不是很懂:
(1)为什么要创建两个CAM?全局的可以解释,local的那个……
(2)blur_power# + (1.0 / (dt# * 120.0)) 其中后面的那个是什么意思,为什么要追加这个值1.0 / (dt# * 120.0) 呢?

大致理解似乎是预先做一个和BACKBUFFER那么大的表面(不知道里面用的MESH是不是这么等价:SURFACE当作MESH么?)当渲染的时候根据需要的值设置ALPHA和进行COPYrect,同时FLIP中不擦去后备缓冲即可……

不过还有不少地方不明白,既然一直FLIP FALSE那么为什么0.5的时候没有看到SURFACE的效果呢……再看看……

littlewater 07-01-28 13:30
试了好久终于…………
不过偶想问问这些效果是从哪里来的啊?
觉得很不错的说……好像没有附带这些范例……


查看完整版本: [-- [Blitz3D]動態模糊效果:Motion Blur --] [-- top --]

Powered by PHPWind v5.3 Code © 2003-05 PHPWind
Time 0.051323 second(s),query:4 Gzip enabled

You can contact us