bloom
BlitzMax Forums/MiniB3D Module/bloom
| ||
hey folks, does anybody know how to create the bloom-effect with minib3d? does anyone have the code? |
| ||
I don't have any code for you, but here's how you would do it. :) 1. Create a fullscreen quad (I have the code somewhere on this forum) 2. Set EntityFX to (I think) 3, and EntityAlpha to about 0.75. 2. Every loop grab the backbuffer to a texture of about half the screen dimensions (640x480 -> 320x240) 3. Texture the fullscreen quad with the grabbed texture. Should work like you want. :) |
| ||
thanks for the tutorial, ked! so this is the basic code(work in progress): 'paste this after graphics3d: Global itexblend:Int = 1 Global fsqblend:Int = 1 Global fsqblend2:Int = 1 Global FSTex:TTexture = CreateTexture(800,800) Global FSQuad:Tmesh = CreateFullScreenQuad(Camera) 'paste this into the loop: hideentity fsquad CameraViewport camera,0,0,1280/10,800/10 Renderworld BackBufferToTex(FStex) CameraViewport camera,0,0,1280,800 scaletexture fstex,1.635*4.75,-1.6354*4.75 EntityTexture FSQuad,fstex,0,0 showentity fsquad cameraclsmode(camera,True,True) renderworld If KeyHit(key_q) Then textureblend fstex,itexblend + 1 If itexblend >= 6 Then itexblend = 0 Else itexblend = itexblend + 1 End If End If If KeyHit(key_e) Then EntityFX fsquad,fsqblend + 1 If fsqblend >= 6 Then fsqblend = 0 Else fsqblend = fsqblend + 1 End If End If If KeyHit(key_w) Then entityblend fsquad,fsqblend2 + 1 If fsqblend2 >= 6 Then fsqblend2 = 0 Else fsqblend2 = fsqblend2 + 1 End If End If BeginMax2D() SetColor(255,255,255) DrawText "itexblend: "+ itexblend,screenwidth - 200,0 DrawText "fsqfx: "+ fsqblend,screenwidth - 200,30 DrawText "fsqblend2"+fsqblend2,screenwidth - 200, 60 EndMax2D() 'paste this after wend: Function CreateFullScreenQuad:TMesh(parent:TCamera) Local gwidth:Int=1280,gheight:Int=800 Local mesh:TMesh=CreateMesh(parent) Local surf:TSurface=CreateSurface(mesh) AddVertex(surf,-1,1,0,0,0) AddVertex(surf,3.2,1,0,1,0) AddVertex(surf,-1,-3.2,0,0,1) AddVertex(surf,3.2,-3.2,0,1,1) AddTriangle(surf,0,1,2) AddTriangle(surf,3,2,1) PositionEntity mesh,-0.518,0.137,1.009 scaleentity mesh,0.5,0.5,1 'ScaleEntity mesh,1.0,(gwidth/gheight)*1.0,1.0 EntityOrder mesh,-10000 EntityAlpha mesh,0.2 Return mesh EndFunction |
| ||
I think you are scaling your mesh wrong. It should be... ScaleEntity mesh,1.0,(gheight*1.0/gwidth),1.0 Off-Topic: boy if that is really functional MiniBlitz3D code (even if the results are undesired), than the thing is simpler than I thought, huh? I mean, most of the B3D functionality is kept; the biggest difference is the Object Orientation. |
| ||
ok. i think i'm pretty close. I updated the code above. I spent most of the time adjusting the entity and it's texture. I know it's not perfect but it does the job. this is optimized for my screenresolution: 1280x800. I also added some keyshots(q, w and e) in order to give you the opportunity to play around with the texturesettings. it looks like this. bloom activated on the left side. ![]() |
| ||
Haven't gotten a chance to play with this, but it looks like fun. One thought I had CameraViewport camera,0,0,1280/10,800/10 could be CameraViewport camera,0,0,GraphicsWidth()/10,GraphicsHeight()/10 and similarly with the other viewport call would be resolution independent then I think... might need some more touches to the FSQuad position or something, haven't really dug into it yet. |
| ||
yeah and it would be nice to have a "real" blur algorythm for the texture. |
| ||
bleh Last edited 2010 |