Foolish Posted April 11, 2010 Share Posted April 11, 2010 I am in the process of trying to add a bloom or glow effect to a laser. Could someone comment on the following if they see something obviously wrong? I am an SDK 2.3 owner by the way. Thanks Here is my simple test program: Framework leadwerks.engine 'Create an OpenGL graphics window Graphics 800, 600 'Allows the engine to find files and load files from zip packages RegisterAbstractPath AppDir 'Create a world If Not CreateWorld() RuntimeError "Failed to create world." 'Create a camera cam:TCamera = CreateCamera() CameraClearColor(cam, Vec4(0, 0, 0, 1)) RotateEntity(cam, Vec3(35, 0, 0)) MoveEntity cam, Vec3(0, 0, - 2) 'add a light light:TLight = CreateDirectionalLight() RotateEntity light, Vec3(45, 45, 0) buffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR | BUFFER_DEPTH | BUFFER_NORMAL | BUFFER_COLOR1) 'Create a render buffer For post - processing effects postbuffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR) TextureFilter(GetColorBuffer(postbuffer), TEXFILTER_SMOOTH) postfilter:TShader = LoadShader("abstract::postfilter.vert", "abstract::postfilter_bloom.frag") DebugLights(True) mesh1:TMesh = LoadMesh("laser_laser.gmf") If Not mesh1 RuntimeError "Failed to laser mesh" PositionEntity mesh1, Vec3(0, 0, 0) 'Main loop While Not KeyHit(KEY_ESCAPE) TurnEntity mesh1, Vec3(0, 0.5, 0) 'Update timing, physics, and other miscellaneous updates UpdateWorld 'Draw the world SetBuffer(buffer) RenderWorld SetBuffer(postbuffer) RenderLights(buffer) SetBuffer(BackBuffer()) SetShader(postfilter) BindTexture(GetDepthBuffer(buffer), 1) BindTexture(GetColorBuffer(postbuffer, 1), 0) DrawImage(GetColorBuffer(postbuffer), 0, GraphicsHeight(), GraphicsWidth(), - GraphicsHeight()) Flip Wend And my mat file for the laser appears as follows: texture0="abstract::laserred.dds" clamp0=0,0,0 blend=0 depthmask=1 depthtest=1 overlay=0 zsort=0 cullface=1 castshadows=1 specular=0.000000000 bumpscale=0.300000012 gloss=0.250000000 shader="abstract::mesh_diffuse.vert","abstract::postfilter_bloom.frag" shadowshader="abstract::mesh_diffuse.vert","" Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Marleys Ghost Posted April 11, 2010 Share Posted April 11, 2010 TBH you are better off using Framework to enable the post processing FX, plus you're trying to use a post effect on a mesh in the .mat, if you look in the mesh folder of the shaders theres a couple you could use such as mesh_diffuse_glow.frag ... Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Foolish Posted April 11, 2010 Author Share Posted April 11, 2010 TBH you are better off using Framework to enable the post processing FX, plus you're trying to use a post effect on a mesh in the .mat, if you look in the mesh folder of the shaders theres a couple you could use such as mesh_diffuse_glow.frag ... Okay. Framework got the effects I was looking for. However, it seems to have screwed up my 3rd person camera I was using. Going through the forums, it looked like you might have run into something similiar in January. I am using the same technique as described in that thread which is as follows: 'Position Camera PositionEntity(fw.Main.camera, EntityPosition(thismodel.model)) RotateEntity(fw.Main.camera, EntityRotation(thismodel.model)) MoveEntity(fw.Main.camera, Vec3(0, 1, - 2.5)) However, my model looks like it is shaking. In reality, it appears to be due to the camera positioning. Any thoughts? Thanks Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Marleys Ghost Posted April 12, 2010 Share Posted April 12, 2010 which thread? Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Foolish Posted April 13, 2010 Author Share Posted April 13, 2010 Link to the post I was referencing I solved it by creating a pivot to parent the camera to. The camera movement is smooth now, but it is not as visually interesting. Using the pivot keeps the camera rigidly in place where using rotate and move entity makes it feel more fluid. which thread? Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Marleys Ghost Posted April 13, 2010 Share Posted April 13, 2010 I solved it by creating a pivot to parent the camera to. Actually the thread you are referencing is all about the problems that arose from that approach. In the end I went for this approach for a basic third person camera: http://leadwerks.com/werkspace/index.php?/topic/800-basic-3rd-person-camera/ And then to this: http://leadwerks.com/werkspace/index.php?/topic/832-updated-basic-3rd-person-camera/ Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Foolish Posted April 24, 2010 Author Share Posted April 24, 2010 Actually the thread you are referencing is all about the problems that arose from that approach. In the end I went for this approach for a basic third person camera: http://leadwerks.com/werkspace/index.php?/topic/800-basic-3rd-person-camera/ And then to this: http://leadwerks.com/werkspace/index.php?/topic/832-updated-basic-3rd-person-camera/ Its funny. Using Framework, the camera's movements are jerky and it makes my ship look like it is vibrating violently. When I don't use framework, its fine, but getting the advanced effects are ten times harder. In your example, you use a cube. Have you used a model with it yet? I am wondering if the physics body is messing me up. When I comment out the camera positioning, the TIE moves fine as does when I use the pivot. Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Foolish Posted April 25, 2010 Author Share Posted April 25, 2010 Its funny. Using Framework, the camera's movements are jerky and it makes my ship look like it is vibrating violently. When I don't use framework, its fine, but getting the advanced effects are ten times harder. In your example, you use a cube. Have you used a model with it yet? I am wondering if the physics body is messing me up. When I comment out the camera positioning, the TIE moves fine as does when I use the pivot. I am still stuck trying to reproduce a simple use of the GLOW shader working such as the cagelight in the tunnels example. Any BMAXers out there have a working example of something like this? Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Marleys Ghost Posted April 26, 2010 Share Posted April 26, 2010 In your example, you use a cube. Have you used a model with it yet? I just swapped the cube for a model and did not notice any problems. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Joh Posted April 26, 2010 Share Posted April 26, 2010 Could you show us the whole code so we can try to help you? Quote Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10. Link to comment Share on other sites More sharing options...
Foolish Posted April 27, 2010 Author Share Posted April 27, 2010 Could you show us the whole code so we can try to help you? Thanks for your time. Framework leadwerks.engine 'Create an OpenGL graphics window Graphics 800, 600 'Allows the engine to find files and load files from zip packages RegisterAbstractPath AppDir 'Create a world If Not CreateWorld() RuntimeError "Failed to create world." 'Create a camera cam:TCamera = CreateCamera() CameraClearColor(cam, Vec4(0, 0, 0, 1)) RotateEntity(cam, Vec3(35, 0, 0)) MoveEntity cam, Vec3(0, 2, - 2) buffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR0 | BUFFER_DEPTH | BUFFER_NORMAL) DebugLights(True) model:TModel = LoadModel("abstract::fixture_cagelight.gmf") If Not model RuntimeError "Failed to load cagelight" 'add a pointlight plight:TLight = CreatePointLight(4, model) SetShadowSoftness(plight, 2) SetShadowmapSize(plight, 512) SetLightRange(plight, 2) plight_material:TMaterial = CreateMaterial() SetMaterialTexture(plight_material, LoadTexture("abstract::cagebulb.dds")) PaintEntity(plight, plight_material) AmbientLight Vec3(1) PositionEntity model, Vec3(0, 2, 0) 'Main loop While Not KeyHit(KEY_ESCAPE) TurnEntity model, Vec3(0, 0.5, 0) 'Update timing, physics, and other miscellaneous updates UpdateWorld 'Draw the world SetBuffer(buffer) RenderWorld 'Swap the graphics buffers so we can see what we drew SetBuffer(BackBuffer()) RenderLights(buffer) Flip Wend The screenshot shows what I'm getting. Not quite the bright light of the tunnel demo. Thanks again. Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Foolish Posted April 29, 2010 Author Share Posted April 29, 2010 Could you show us the whole code so we can try to help you? Joh, do you think you might have a chance to look at this? Thanks. Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Josh Posted April 29, 2010 Share Posted April 29, 2010 The framework command set is used to create a "framework" that handles bloom and other effects, so you can just switch them on and off. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Joh Posted April 29, 2010 Share Posted April 29, 2010 I am sorry i completely forgot of this post Yeah Josh already told you how to do it, also there is a glow/bloom shader for mesh wich i never understood how it's working, i saw it use another texture but i didn't understood wich material we shall use.. Josh could you explain it? Quote Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10. Link to comment Share on other sites More sharing options...
Flexman Posted April 29, 2010 Share Posted April 29, 2010 Just to chime in. If you use the LE shaders for glow such as "mesh_diffuse_glow.frag" then you need to provide a glowmap in texture stage 2 and use the glow post-filter. The glowmap can be the same texture as your colourmap if you want. Look at the example "cagebulb" which is part of the cagelight in the underground level... texture0="abstract::cagebulb.dds" texture2="abstract::cagebulb.dds" castshadows=0 collisiontype=0 color=1.0,0.9,0.6,1.0 shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse_glow.frag" Glow is rendered as a post-process, so unless you're using a glow post-process effect that you won't see any glow effects from these materials. Just try it in the editor, turn the glow option on and off with the object in front of you. If you don't want to do that for whatever reason you might have to fake it the old fashioned way using a corona or an additive blended version of your laserbolt. 1 Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
Joh Posted April 29, 2010 Share Posted April 29, 2010 So i could just use the same diffuse.. Ok i'll try. Thx. Quote Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10. Link to comment Share on other sites More sharing options...
Foolish Posted April 29, 2010 Author Share Posted April 29, 2010 Thanks guys. Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Naughty Alien Posted April 29, 2010 Share Posted April 29, 2010 ..i dont know have you succeeded, and guys previously already did proper explanation, so ill just post some code, how it should look like..so..material file should be as it was already exposed : texture0="abstract::cagebulb.dds" texture2="abstract::cagebulb.dds" castshadows=0 collisiontype=0 color=1.0,0.9,0.6,1.0 shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse_glow.frag" and then, here is example with use if framewerk so it will be very easy to set up and try.. SuperStrict Framework leadwerks.framewerk RegisterAbstractPath(AppDir) Graphics(800, 600) LogStreamEnabled = False'AppLogMode equivalent Local fw:TFramewerk fw = TFramewerk.Create() If Not fw RuntimeError "Failed to initialize engine." fw.renderer.SetBloom(True)'here your cagebulb glow will be turned on/off fw.renderer.setHDR(True)'here your glow effect can be more exposed if HDR is enabled (only SM4 cards)..glow will work just fine without it, but less intense.. 'load a scene LoadMesh("abstract::myScene.gmf") 'just set up your camera to face glowsphere so you can see it MoveEntity(fw.main.camera,vec3(0,3,-3) Local glowSphere:TMesh = createsphere() ;moveentity (glowsphere, vec3(0, 3, 0)) Local glowMaterial:TMaterial = LoadMaterial("abstract::cagebulb.mat") PaintEntity(glowSphere, glowMaterial) Repeat fw.Update() fw.Render() Flip(0) Until KeyHit(KEY_ESCAPE) End ..and that should be pretty much all...i hope it helps.. Quote Link to comment Share on other sites More sharing options...
Foolish Posted May 2, 2010 Author Share Posted May 2, 2010 ..i dont know have you succeeded, and guys previously already did proper explanation, so ill just post some code, how it should look like..so..material file should be as it was already exposed : texture0="abstract::cagebulb.dds" texture2="abstract::cagebulb.dds" castshadows=0 collisiontype=0 color=1.0,0.9,0.6,1.0 shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse_glow.frag" and then, here is example with use if framewerk so it will be very easy to set up and try.. SuperStrict Framework leadwerks.framewerk RegisterAbstractPath(AppDir) Graphics(800, 600) LogStreamEnabled = False'AppLogMode equivalent Local fw:TFramewerk fw = TFramewerk.Create() If Not fw RuntimeError "Failed to initialize engine." fw.renderer.SetBloom(True)'here your cagebulb glow will be turned on/off fw.renderer.setHDR(True)'here your glow effect can be more exposed if HDR is enabled (only SM4 cards)..glow will work just fine without it, but less intense.. 'load a scene LoadMesh("abstract::myScene.gmf") 'just set up your camera to face glowsphere so you can see it MoveEntity(fw.main.camera,vec3(0,3,-3) Local glowSphere:TMesh = createsphere() ;moveentity (glowsphere, vec3(0, 3, 0)) Local glowMaterial:TMaterial = LoadMaterial("abstract::cagebulb.mat") PaintEntity(glowSphere, glowMaterial) Repeat fw.Update() fw.Render() Flip(0) Until KeyHit(KEY_ESCAPE) End ..and that should be pretty much all...i hope it helps.. I can make this example work. Thanks. My problem with Framework now goes back to an earlier post related to camera movement. Moving the camera is code creates very jerky movement unless I use a pivot. I made a brief video showing the problem here: Jerky Camera Using Framework I only get this using framework. My relevant code is as follows: Framework leadwerks.engine 'Create an OpenGL graphics window Import "Framework.bmx" AppTitle = "Working Title" Const WIDTH = 1024 Const HEIGHT = 768 Graphics WIDTH, HEIGHT Const FPSVIEW = 1 Const CHASEVIEW = 2 Global ViewType:Int = CHASEVIEW 'Allows the engine to find files and load files from zip packages RegisterAbstractPath AppDir fw:TFramework = TFramework.Create() If Not fw RuntimeError "Failed to initialize engine" End If PositionEntity fw.Main.camera, Vec3(0, 10, - 4) CameraClearColor(fw.Main.camera, Vec4(0, 0, 0, 1)) CameraRange(fw.Main.camera, 0.1, 3000) CameraClearMode(fw.Main.camera, BUFFER_DEPTH) 'add a light light:TLight = CreateDirectionalLight() RotateEntity light, Vec3(45, 45, 0) 'load the scene scene:TEntity = LoadScene("abstract::scene.sbx") If Not scene RuntimeError "Failed to load scene" 'set collisions Collisions(1, 1, True) Global player:TTIEF player = New TTIEF player.SetPosition (0, 50, - 2000) LoadTestTower() SetSkybox(LoadMaterial("abstract::skybox.mat")) HideMouse MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2 'SetStats(2) 'Main loop While Not KeyHit(KEY_ESCAPE) DebugPhysics KeyDown(KEY_P) If KeyDown(KEY_S) Then SaveBuffer(gbuffer, "screenshot.jpg") If KeyDown(KEY_F1) Then ViewType = FPSVIEW If KeyDown(KEY_F2) Then ViewType = CHASEVIEW UpdateFramework() player.Update() 'Position Camera If ViewType = CHASEVIEW 'no pivot EntityParent(fw.Main.camera, Null) PositionEntity(fw.Main.camera, EntityPosition(player.model)) RotateEntity(fw.Main.camera, EntityRotation(player.model)) MoveEntity(fw.Main.camera, Vec3(0, 5, - 10)) Else 'using pivot EntityParent(fw.Main.camera, player.camPivot) PositionEntity(fw.Main.camera, EntityPosition(player.camPivot)) End If fw.update() fw.Render() If ViewType = FPSVIEW Then DrawText "View Type: Using Pivot", 0, 80 Else DrawText "View Type: Rotating Cam", 0, 80 End If Flip Wend I have also played around with resizing the model in case its a rounding error with floats, but that didn't seem to help. Not moving the camera keeps everything smooth as well. Any thoughts? Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Canardia Posted May 2, 2010 Share Posted May 2, 2010 You are calling UpdateFramework() twice. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Foolish Posted May 2, 2010 Author Share Posted May 2, 2010 You are calling UpdateFramework() twice. I wish it was that simple. That second call is left over from troubleshooting this. Removing "updateframework" has no impact at all. Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Joh Posted May 3, 2010 Share Posted May 3, 2010 Remove UpdateFramework() also why this is called on loop?: Else 'using pivot EntityParent(fw.Main.camera, player.camPivot) PositionEntity(fw.Main.camera, EntityPosition(player.camPivot)) End If Parenting a cam to a pivot it's something you should do just once.. Quote Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10. Link to comment Share on other sites More sharing options...
Foolish Posted May 3, 2010 Author Share Posted May 3, 2010 Remove UpdateFramework() also why this is called on loop?: Else 'using pivot EntityParent(fw.Main.camera, player.camPivot) PositionEntity(fw.Main.camera, EntityPosition(player.camPivot)) End If Parenting a cam to a pivot it's something you should do just once.. I still get the shaky camera. I have minimized my loop to just what causes the shaky camera. I had the other code in there before to demonstrate that using the pivot allowed smooth movement. The following code excerpt, which maneuvers the camera is what creates the jerky results. 'SetStats(2) EntityParent(fw.Main.camera, Null) 'Main loop While Not KeyHit(KEY_ESCAPE) DebugPhysics KeyDown(KEY_P) player.Update() PositionEntity(fw.Main.camera, EntityPosition(player.model)) RotateEntity(fw.Main.camera, EntityRotation(player.model)) MoveEntity(fw.Main.camera, Vec3(0, 1, - 2.5)) fw.update() fw.Render() Flip Wend Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Joh Posted May 3, 2010 Share Posted May 3, 2010 What are you triyng to do with this? EntityParent(fw.Main.camera, Null) Also if the cam is placed on a controller it will be "shaky" because the controller is.. Try to position the cam after the render and update. Quote Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10. Link to comment Share on other sites More sharing options...
Foolish Posted May 6, 2010 Author Share Posted May 6, 2010 I think you nailed it. Parenting to the model will always be shaky. Parenting to a pivot is the way to go - at least when using Framework. Quote Windows XP Dual Core 2.66 Dual GeForce 7900 GTS in SLI (Yes, I know they are old.) Blitzmax with BlIDE Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.