Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: PatternSurfaces[0].Pixels[X,Y] MORE SLOW

  1. #1

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    Hi.

    I'm simulate rain in my game: http://www.miniracingonline.com

    I convert to gray scale in TBakground to simulate gray day. ValueRain is for more or slow rain (slow or more color)

    [pascal]
    // DXImageList.Items[1] = Original color Background, not change
    // DXImageList.Items[2] = Final Background (chage color)

    // for eah pixel X,Y:
    ColorPixel := DXImageList.Items[1].PatternSurfaces[0].Pixels[X,Y]; //original color image
    R := GetRValue(ColorPixel);
    G := GetGValue(ColorPixel);
    B := GetBValue(ColorPixel);
    ColorAver := (R + G + B) div 3;
    if R < ColorAver then
    R := Min(R+ValueRain ,ColorAver)
    else
    R := Max(R-ValueRain ,ColorAver);
    if G < ColorAverthen
    G := Min(G+ValueRain ,ColorAver)
    else
    G := Max(G-ValueRain ,ColorAver);
    if B < ColorAverthen
    B := Min(B+ValueRain ,ColorAver)
    else
    B := Max(B-ValueRain ,ColorAver);
    // aply new color to background
    DXImageList.Items[2].PatternSurfaces[0].Pixels[X,Y] := RGB(R,G,B);
    [/pascal]

    I paint 8 pixels by milisec but is MORE slow (100 fps to 20 fps :x ). Normally Background is 5000x3500 pixels :shock:

    Another tecnique to change color faster ?

    Thanks

    Original color image:


    Color of Full Rain:
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  2. #2

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    sorry I know this is offtopic, but what are you using for netplay? since delphix's only uses tcp and doesn't work with routers/?

  3. #3

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    For netplay I use DirectPlay of unDelphiX. Work open TPC port (6666 TCP in my game) in router, server and clients :?

    DirectPlay 8 no need to open ports for clients, but delphix use DirectPlay7. I prove convert to directplay 8 but not work :evil:

    Kotai.
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  4. #4

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    I have testing rain change:

    Track 1024 x 768 pixels --> 2 minutes :?
    Track 4000 x 4000 pixels --> 55 minutes :x (race long are 20 or 30 minutes)

    I change in real time, but 1 change are 55 minutes :shock: ... I need one change each 1 or 2 minutes...

    I change 8 pixels by milisec and FPS down 100 to 40... This not work fine :cry: I need change minium 100 pixels by milisec

    :idea: I can change palette ? In my game Tbackground are in 16bits color... ¬ø pallete are only for 256 colors ?

    Kotai
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  5. #5
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    Cant you draw a semi transparent alpha scaled image over the background instead? Wont this be significantly faster?
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  6. #6

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    Yes, undoubtedly.

    Draw your background again, but with transparency and using the rainy-track texture instead!
    My site: DelphiTuts.com (coming soon)...

    Download Font Studio 4.21 here.

  7. #7

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    with DrawAlpha( ) ? I will probe, but efect rain isn't a semi transparent alpha scaled, is convert to gray scale.

    If I draw a semi transparent alpha scaled image, who restore original colors (gradually) when rain finish ? :?

    I test this night and coment.

    Thanks.
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

  8. #8
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    Add the original colors back by slowly removing the alpha value to white - this means less and less alpha value.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  9. #9

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    Off way?

    You can use PokeBlendPixel() function or direct commit property Pixel (assembler based routines, feature from unDelphiX) to DXDraw Surface. But the Surface has to locked. And can be effective set up the SystemMemory flag.

    Illustrate code here:
    Code:
          DXDraw.Surface.Lock;
          DXDraw.Surface.Pixel&#91;X, Y&#93; &#58;= TheColor;
          TheColor &#58;= DXDraw.Surface.Pixel&#91;X+1, Y+1&#93;;
          DXDraw.Surface.Unlock;
    Regards
    Ijcro.

  10. #10

    PatternSurfaces[0].Pixels[X,Y] MORE SLOW

    I can 2 problems with pixel

    1) when SystemMemory flag is set FPS down 100 to 18 :shock: (with out rain, when rain down to 16 fps)

    2) This method are not persistent. In next frame i lost all pixel

    if not set systemmemory not work, but all code execute and speed is fantastic, I put 320 pixel by milisecond and frames down 100 to 70. Pixel[] are 40 times more rapid than Pixels[]



    I will test DrawAlpha.

    Kotai.
    www.kotai.es
    www.remakesonline.com -> Nemesis Online & Bubble Bobble Online & Castlevania Online & Penguin Adventure Online
    www.miniracingonline.com

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •