• Welcome to Dark Bit Factory & Gravity.
 

comp scene test.

Started by ninogenio, December 09, 2008

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

ninogenio

hi guys i was wondering if you had any advice on improving the look of my led scene and also i want too make sure it runs on your system ok.

this is an unfinished scene ripped from my comp entry.
Challenge Trophies Won:

bikerboy

#1
just tested it both fullscreen and windoed mode and runs smoothly :)

nice effect both background and scroller :D


Shockwave

Runs perfectly here Nino..

Looking really smooth and nice too!

XPSP2 P4 3.0 Ghz, ATI X1650
Shockwave ^ Codigos
Challenge Trophies Won:

Hezad

Ran fine :)  (in fact the animation was a bit jerky, but my computer has some serious problems these days lol so please just assume it ran right :) )


It looks pretty cool  ;D


Quoteany advice on improving the look of my led scene

hum not really, just a subjective thought : The space between the rectangular leds make them look like some ascii art (imho), that's beautiful :) But I don't see it as leds.
However, all those cool scrolling and rotating stuff are drawn in a way which make me think about stadiums gigantic screens, and so reinforce the fact it looks like leds.

Anyway, I already like it a lot  :D
Music + Coding :
http://Hezad.no-ip.org

Hosting / Hébergement :
www.hezad.com

hellfire

Quoteany advice on improving the look of my led scene
How about a bit of glow?
Challenge Trophies Won:

Clyde

One area I would suggest you look into is the colourings used.
Also instead of a line for you LEDS's perhaps use a small filled circle; like the graphic used for bullet points in word processing.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

ninogenio

cheers everyone for testing this, really good comments.

@hellfire: wow how did you do that? how would i go about that in my engine, additive blending on the final buffer before being passed through for rendering maybe?.

@Clyde i totaly agree i have been playing around with the coloring for a few days, i just cant seem to get it any better than this. i also tryed circles but i liked the feel of squares better.
Challenge Trophies Won:

hellfire

Quotehow did you do that?
i took a screencapture, applied pretty much of gaussian blur (radius of ~30 pixels), subtracted some intensity (so that darker areas don't contribute to the glow), scaled the brightness up (blurring made it rather dark) and added the result to the original picture.
i also hue-shifted by ~180 degree (because blue is preceived as darkest colour and doesn't work so well for shiny things) and fiddled a bit with the intensity of the initial picture.
Challenge Trophies Won:

ninogenio

well its a really nice effect! ive just been messing around with a gaussian blur but i cant get it quite right ill keep going and see what if i can get close to your image. cheers.
Challenge Trophies Won:

ninogenio

finaly i got quite a nice glow.

this version is really really slow due to all the extra calcs i wonder now if i can optimize this enough to get it going at a fast speed.also the edges of the grid are a bit messed up i know how to fix this though its just the way my blur routine works.
Challenge Trophies Won:

benny!

@hellfire:
K++ for explaining how you made the image glow.
Always love the glowing filter.


@nino:
Nice work - runs a bit slower now - but glow FX is very
nice!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Hezad

Idem :) A bit slower, but really cool  :clap:
Music + Coding :
http://Hezad.no-ip.org

Hosting / Hébergement :
www.hezad.com

Shockwave

Really nice looking glow effect, I think it would be even more effective if you changed the colours to red / orange like Hellfire suggested.

Speed wise, I am guessing that it has dropped from full framerate to about 8fps here but the glow is so nice that it must be worth optimising.
Shockwave ^ Codigos
Challenge Trophies Won:

hellfire

Nice!
The glow seems to be a bit off to the upper left, though - make sure to use an odd-sized filter-matrix so that the center element is actually in center.

Quotethis version is really really slow due to all the extra calcs i wonder now if i can optimize this
Are you using a 2d filter matrix? Since the gaussian is completely symetrical, you can separate it into two consecutive passes, one doing horizontal, another one doing vertical blur (you're using the center row and center coloumn as 1d filters).
A good approximation of the gaussian weights for a radius "r" is f(x)= e ^ -(x^2*4/r^2) (with x=-r..+r, x=0 being the center element).
You should prescale the weights so that their sum is some power of two, so you can replace the final divide by a shift.
Another approach is to use a triangular filter-shape (a somewhat poor approximation of a gaussian) so that for every new pixel only one input sample comes in (and another one falls out), the existing sum can be scaled by a constant.
Generally you don't need to apply gaussian to the full resolution of the image (you are blurring anyways), just reduce the image size by a simple 2x2 box-filter beforehand.
Alternatively you can approximate the gaussian by a series of box-filters of different radii (look up "summed area tables").
For filters of reasonable size (means <50) you're usually faster with a well optimized 2x1d approach.
Challenge Trophies Won:

Clyde

Maybe applying a copper list of colours, would make it more funky.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

ninogenio

thanks everyone for sharing your thoughts/comments i will really consider them!

@hellfire theres loads of room for improvement right now im trying to approximate a gaussian by doing a box filter on the whole screen buffer 8 times with a radius of 12 then correcting and adding the result to the original image. which is slow.

infact here is my glow function, it was botched together very quickly last night.


Dim Shared TBuf(800*600) As integer
Sub Smooth( TempBuffer As Integer Ptr , ByVal ScrWidth As Integer , ByVal ScrHeight As Integer )
   
    Dim MaxPixel As Integer
    Dim OffSet As Integer
    Dim Pixel As UInteger
    Dim R As UInteger
    Dim G As UInteger
    Dim B As UInteger
    Dim Nr As UInteger
    Dim Ng As UInteger
    Dim Nb As UInteger
    Dim As Integer Radius = 12
   
    Dim X As integer
   
    For X=0 to 600*800
        TBuf(x) = 0
        Tbuf(x) = TempBuffer[x]
    Next
    For X = 0 to 4
        MaxPixel = ScrWidth*ScrHeight
        For OffSet = ScrWidth*Radius To ( MaxPixel - ( ScrWidth * Radius ) )
            Pixel = TBuf( OffSet - ( Radius - 1 ) )
            B = Pixel
            Nb = B Shr 2
       
            Pixel = TBuf( OffSet + ( Radius - 1 ) )
            B = Pixel
            Nb = Nb + ( B Shr 2 )

            Pixel = Tbuf( offset + ( ScrWidth * ( radius - 1 ) ) )
            B = Pixel
            Nb = Nb + ( B Shr 2 )

            Pixel = Tbuf( offset - ( ScrWidth * ( radius - 1 ) ) )
            B = pixel
            Nb = Nb + ( B Shr 2 )
       
            TBuf( OffSet ) = Nb
     
        Next
    next
       
    For X=0 to 600*800
        TempBuffer[ x  ] += Tbuf(x)*3
        If TempBuffer[ x ] > 255 Then TempBuffer[ x ] = 255
    Next
End Sub
Challenge Trophies Won:

ninogenio

ive managed to roughly double the speed to 15fps with these changes.


Sub Smooth( TempBuffer As Integer Ptr , ByVal ScrWidth As Integer , ByVal ScrHeight As Integer )
   
    Dim X As Integer
    Dim TBuf As Integer Ptr
    Dim TB As Integer Ptr
   
    Dim OffSet As Integer
    Dim Nb As Integer
    Dim As UByte Radius = 11
    Dim As Integer MaxPixel = ( ScrWidth * ScrHeight ) - ( ScrWidth * Radius )
    Dim As Integer O1 = ( Radius - 1 )
    Dim As Integer O2 = ( ScrWidth * ( radius - 1 ) )

    TBuf = Callocate( 800 * 600 * Sizeof( Integer ) )
    memcpy( @Tbuf[ 0 ] , @TempBuffer[ 0 ] , 800 * 600 * SizeOf( Integer ) )

    For X = 0 to 4
        TB = TBuf+ScrWidth*Radius
        For OffSet = ScrWidth*Radius To MaxPixel

            Nb = TBuf[ OffSet - o1 ]
            Nb = Nb + ( TBuf[ OffSet + o1 ] )
            Nb = Nb + ( Tbuf[ offset + o2 ] )
            Nb = Nb + ( Tbuf[ offset - o2 ] )
       
            *TB = Nb Shr 2
            TB += 1
        Next
    next
       
    For X = 0 To 600 * 800
       
        TempBuffer[ X ] += Tbuf[ X ]*3
        If TempBuffer[ X ] > 255 Then TempBuffer[ X ] = 255
    Next
   
    DeAllocate( TBuf )
   
End Sub


but now im stumped, there is a few bottlenecks the memcpy being one and a four array acesses in the tightest part of my main for loop structure. i cant see any way of getting more speed out can any of you guys?
Challenge Trophies Won:

Shockwave

memcpy is a fast function so I don't think that's going to be much of a bottleneck.

To get more speed I'd consider using pointers more in this part of the code;

            Nb = TBuf[ OffSet - o1 ]
            Nb = Nb + ( TBuf[ OffSet + o1 ] )
            Nb = Nb + ( Tbuf[ offset + o2 ] )
            Nb = Nb + ( Tbuf[ offset - o2 ] )


That could be simplified quite a lot and probably contained in a #define statement.. There must be other stuff too, it's still not as fast as it should be :)
Shockwave ^ Codigos
Challenge Trophies Won:

ninogenio

cheers shockwave ill have a go at making that part additive pointers.

i meant there was a bottleneck coming from the fact i had to memcpy the framebuffer to a temprary buffer not from the memcpy function itself.
Challenge Trophies Won:

ninogenio

cheers nick 20fps now!


Sub Smooth( TempBuffer As Integer Ptr , ByVal ScrWidth As Integer , ByVal ScrHeight As Integer )
   
    Dim X As Integer
    Dim TBuf As Integer Ptr
    Dim TB As Integer Ptr
    Dim TB1 As Integer Ptr
    Dim TB2 As Integer Ptr
    Dim TB3 As Integer Ptr
    Dim TB4 As Integer Ptr
   
    Dim OffSet As Integer
    Dim Nb As Integer
    Dim As UByte Radius = 11
    Dim As Integer MaxPixel = ( ScrWidth * ScrHeight ) - ( ScrWidth * Radius )
    Dim As Integer O1 = ( Radius - 1 )
    Dim As Integer O2 = ( ScrWidth * ( radius - 1 ) )
    Dim As Integer o3 = ( ScrWidth * Radius )
   
    TBuf = Callocate( 800 * 600 * Sizeof( Integer ) )
    memcpy( @Tbuf[ 0 ] , @TempBuffer[ 0 ] , 800 * 600 * SizeOf( Integer ) )

    For X = 0 to 4
        TB = TBuf+o3
        TB1 = TBuf+( o3 - o1 )
        TB2 = TBuf+( o3 + o1 )
        TB3 = Tbuf+( o3 + o2 )
        TB4 = Tbuf+( o3 - o2 )
        For OffSet = o3 To MaxPixel

            *TB = ( *TB1 + *TB2 + *TB3 + *TB4 ) Shr 2
            TB += 1
            TB1 += 1
            TB2 += 1
            TB3 += 1
            TB4 += 1
           
        Next
    next
       
    For X = 0 To 600 * 800
       
        TempBuffer[ X ] += Tbuf[ X ]*3
        If TempBuffer[ X ] > 255 Then TempBuffer[ X ] = 255
    Next
   
    DeAllocate( TBuf )
   
End Sub

any more? also ive attached this version in red which i think looks really cool.
Challenge Trophies Won: