Jump to content

Paul Thomas

Members
  • Posts

    339
  • Joined

  • Last visited

Posts posted by Paul Thomas

  1. index.php?app=downloads&module=display&section=screenshot&id=37

    File Name: Radial Blur and Radial Masked Blur

    File Submitter: Eternal Crisis

    File Submitted: 23 Dec 2009

    File Category: Materials

    Resolution: 512x512

     

    Free for use with any Leadwerks Engine game or project.

     

     

     

    Directions for Framewerk with engine version 2.8:

     

    Field filter_radialblur:TShader
    Field filter_radialmaskedblur:TShader
    
    Field radialblur_enabled:Int = False
    Field radialblur_blur:Float = 0.0070
    
    Field radialmaskedblur_enabled:Int = False
    Field radialmaskedblur_mask:TTexture
    Field radialmaskedblur_opacity:Float = 1.0
    Field radialmaskedblur_blur:Float = 0.0075
    

     

    Within the Draw method:

     

    If radialblur_enabled
    DrawEffectRadialBlur(postbuffer[1-cb].colorbuffer[0])
    EndIf
    
    If radialmaskedblur_enabled
    DrawEffectRadialMaskedBlur(postbuffer[1-cb].colorbuffer[0])
    EndIf
    

     

     

    The methods:

     

    Method DrawEffectRadialBlur(colortexture:TTexture)
    	If Not filter_radialblur filter_radialblur = LoadShader("abstract::radialblur.vert","abstract::radialmaskedblur.frag")
    
    SetShader(filter_radialblur)
    SetShaderFloat(filter_radialblur, "blur", radialblur_blur)
    
    colortexture.bind(0)
    DrawFlippedImage(colortexture)
    EndMethod
    
    Method DrawEffectRadialMaskedBlur(colortexture:TTexture)
    	If Not filter_radialmaskedblur filter_radialmaskedblur = LoadShader("abstract::radialmaskedblur.vert","abstract::radialmaskedblur.frag")
    	If Not radialmaskedblur_mask radialmaskedblur_mask = LoadTexture("abstract::radialmask_full.dds")
    
    SetShader(filter_radialmaskedblur)
    SetShaderFloat(filter_radialmaskedblur, "opacity", radialmaskedblur_opacity)
    SetShaderFloat(filter_radialmaskedblur, "blur", radialmaskedblur_blur)
    
    colortexture.bind(0)
    radialmaskedblur_mask.bind(1)
    DrawFlippedImage(colortexture)
    EndMethod
    

     

     

     

    This effect doesn't play nicely while submerged, so it's best to disable the effect when you're submerged, and turn it back on (if it was on when going submerged) when you're no longer submerged.

    For the radialmaskedblur you can change the radialmaskedblur_mask texture to use different effects. The zip file provides six different textures that will provide the blur within specific locations. Feel free to play around with them and/or make your own.

    If anyone makes any improvements to the shader or improvements with the shader in combination with framewerk, please let me know.

     

    Click here to download this file

    • Upvote 1
  2. Try

     

    skycam.ClearMode = CameraClearMode.Depth;
    

     

    In Framewerk there is also a ClearBuffer(BUFFER_DEPTH) before "World.Current = background" and after the background "World.Render()"

     

    See if it helps?

     

    I really need to download your headers and try this out. I really like the syntax flow.

  3. For the actual red radius that follows the terrain?

     

    BlitzMax

     

    In loop somewhere:

    pick = camerapick(camera, vec3(mousex(), mousey(), 1000.0), 0, 0)
     if pick <> null and tterrain(pick.entity)
       createradiusmesh(tterrain(pick.entity), pick.position.x, pick.position.y, pick.position.z)
     endif
    

     

    The above could be simplified, it was final code after testing purposes, but never polished up.

     

    function createradiusmesh(terrain:tterrain, x:float, y:float, z:float)
       if radiusmesh freeentity(radiusmesh)
     radiusmesh = createmesh()
     entitycolor(radiusmesh, vec4(1.0, 0.0, 0.0, 1.0))
     radiussurface = createsurface(radiusmesh)
    
       for local i:int = 1 to 360
         local px:float = x + cos(i) * radius
         local pz:float = z + sin(i) * radius
         local h:float = terrainelevation(terrain, pz, px)
         addvertex(radiussurface, vec3(px, h, pz))
       next
    
     radiussurface.mode = GL_LINE_LOOP
     updatemesh(radiusmesh)
     entityshadowmode(radiusmesh, false)
    endfunction
    

     

    Again, can be polished up, and you need a tmesh/tsurface for the above. I'm not really sure how to do this with the current C# headers, have to still try the header out, just haven't had the time.

     

    Code above was also rewritten for this forum instead of copy and pasted, so there could be mistakes but it looks correct.

     

    And thanks :blink:

    • Upvote 2
  4. lol. I'd like to mimic most of the 2.28 sandbox and then continue to build it to be more targeted for my project. Yes, I'm reinventing the wheel, but I can't build upon the LE sandbox. Project targeted features such as changing the time of day, visual cloud layer manipulation, eventually weather, and so forth.

     

    If the original LE sandbox was a module or available for purchase, that would be fantastic, but at the moment I'll have to work on this enough to fit my projects needs.

  5. Yeah, going to start experimenting with TerrainElevation instead, since using TerrainElevation was the only way to make my radius tool work correctly (drawn based on terrain height). I have a fairly smooth terrain editor so far, but I still have to work on providing radius (inner and outer). My calculations at the moment are way off.

  6. Now that I'm done feeling stupid, here it is, after I realized no math was really required.

     

    Gather terrain resolution from your sandbox scene or use createterrain.

     

    local pick:tpick
    local grid:tvec3
    local height:float
    local terrain:tterrain
    
    if mousehit(1)
     pick = camerapick(camera, vec3(mousex(), mousey(), 1000.0), 0, 0)
       if pick <> null and tterrain(pick.entity)
         terrain = tterrain(pick.entity)
         grid = pick.position
    
         grid.x = grid.x + ((-terrainResolution / 2) + terrainResolution)
         grid.z = grid.z + ((-terrainResolution / 2) + terrainResolution)
    
         height = terrainheight(terrain, grid.z, grid.x)
         setterrainheight(terrain, grid.z, grid.x, height + 0.001)
       endif
    endif
    

     

    That will edit the terrain while playing around with your program.

     

    Or

     

    terrain.resolution
    

     

    For BlitzMax

  7. I'm using BlitzMax, but will eventually use C# once everything is finalized on that end. However, I'll be using both languages, since I'm building my editor in BlitzMax, and I don't feel like starting that over.

  8. Almost. I'll probably have it completed here in just a few, and I'll post up an example. Wanted to mess with terrain editing while "in-game" and it's going well, just have to finalize some of the math. Grid x=0, y=0 works fine, except that I have the y backwards, same with Grid x=128, y=128 (on a 128x128 terrain). Grid x=0, y=128 and Grid x=128, y=0, I have backwards, lol. So click 0, 128 raises the terrain over at 128, 0.

×
×
  • Create New...