Dos Batch Raycast - Maze3D/Explorer3D Beta

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Dos Batch Raycast - Explorer3D Beta

#31 Post by dbenham » 07 Sep 2015 08:25

einstein1969 wrote:@dbenham
I have tested the version 0.4.0 - 0.4.1 and 0.41a and all is ok.
Than I only modify a line of code for probe multitasking on my monocore.
from:

Code: Select all

  set /a proc=NUMBER_OF_PROCESSORS, childCnt=proc-1

to:

Code: Select all

  set /a proc=NUMBER_OF_PROCESSORS+1, childCnt=proc-1

In this case the result are not always the same. The output is only half some time. Some time is full and sometime is half good and half not. :(

EDIT: it would seem that the job variable is not set for the main thread and/or use the child/parallel definition.

I cannot reproduce that behavior :?

It runs flawlessly when my total number of active processes never exceeds the number of processors.

But I do see something odd about 1 frame out of 25 if I set NUMBER_OF_PROCESSORS to 5, even though my machine has 4 cores. Every now and then, it seems like one of the render files is not updated with new data, so the output is garbled. I modified the code to investigate a bit - instead of deleting the job file, I move it to original_name.sav. I can then look at each job and render file in another window as soon as I see a problem. It is really odd, because the job must have run - all the job files with .sav extension have the correct data and the last modified timestamps of each job and render file indicate each job was run and each render file created at the correct time (I looked at timestamps with millisecond precision).

I am totally stumped as to what could be happening :? :evil:


Dave Benham

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#32 Post by einstein1969 » 14 Sep 2015 07:57

Hi Dave,

There are many days I'm trying to debug 0.4.1 but I had to stop. I was going crazy ... :shock:

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#33 Post by einstein1969 » 11 Oct 2015 18:56

Hi to all,

I have developed a new engine. This is developed on monocore. I have used a grid accelerated tecnology (for reference search SEADS by Fujimoto)

I have a little optimized with "Empty Environment", use variable name with prefix $ for faster SET and some other minor trick.

The new engine return the SIDE of ray intersection with wall, usefull for simulate a light/shadow

This is the full demo without antialiasing that calcultate the average FPS.

On my monocore @2.00Ghz is near 3 FPS 8)

Code: Select all

:::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal Enabledelayedexpansion

mode 69,58

set "preserve= TMP COMSPEC NUMBER_OF_PROCESSORS preserve "
for /f "delims==" %%v in ('set') do if "!preserve: %%v =!" equ "!preserve!" set "%%v="
set "preserve="

set  MAP[0]=11111111111111111
set  MAP[1]=11212121212121211
set  MAP[2]=12.............21
set  MAP[3]=11.............11
set  MAP[4]=12.............21
set  MAP[5]=11.............11
set  MAP[6]=12.............21
set  MAP[7]=11.............11
set  MAP[8]=12.............21
set  MAP[9]=11.............11
set MAP[10]=12.............21
set MAP[11]=11.............11
set MAP[12]=12.............21
set MAP[13]=11.............11
set MAP[14]=12121212121212121
set MAP[15]=11111111111111111

For /L %%N in (1,1,50) do set S=_!S!

For /L %%N in (1,1,50) do set S0=Û!S0!
For /L %%N in (1,1,50) do set S0s=°!S0s!

For /L %%N in (1,1,50) do set S1=²!S1!
For /L %%N in (1,1,50) do set S1s= !S1s!

set /a "PI=(35500000/113+5)/10, PI_div_2=(35500000/113/2+5)/10, PIx2=2*PI, PI32=PI+PI_div_2"
set "SIN=(a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000)"

set /A Playerx=5*10000, PlayerY=4*10000, _Angle=0

rem for average FPS
set "t1=!time: =0!"

for /l %%. in (1,1,100) do (

  rem for instant FPS
  rem set "t1=!time: =0!"

  call :raycast

  rem for average FPS
  for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000, FPS=100000/(a*10/%%.), a=a*10/%%."
  Title Raycast Dos Batch  -  Time Elapsed:!a!ms - FPS: !FPS:~0,-2!.!FPS:~-2! [%%.]

  rem for instant FPS
  rem for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000, FPS=10000/a"
  rem Title Raycast Dos Batch  -  Time Elapsed:!a!0ms - FPS: !FPS:~0,-2!.!FPS:~-2! [%%.]

  set a=&set FPS=

  set /A _Angle+=15
)

pause
exit /B

:::::::::::::::::::::::::::::::::::::::::::::::::
:raycast

setlocal

( %= Empty Environment =%
  for %%v in (_Angle Number_of_Processors PI PI32 PIx2 PI_div_2 SIN
              prompt comspec PlayerX PlayerY) do set "%%v="

  set "transposedLine="
  set/A  from=%_angle%-32, to=%_angle%+32
  For /L %%Z in (!from!,1,!to!) do (
 
      %= Sin_Cos inline for speed =%
      (
        setlocal
        set "p1=%%Z * %PI% / 180"
        set "p4=((%%Z-%_angle%) * %PI% / 180)"

        set /a "a=(!p1!) %% %PIx2%, b=(a>>31|1)*a"
        if !b! gtr %PI32% (
          set /a "a=a-(a>>31|1)*%PIx2%, c=%SIN%"
        ) else if !b! gtr %PI_div_2% (
          set /a "a=(a>>31|1)*%PI%-a, c=%SIN%"
        ) else set /a "c=%SIN%"

        set /a "a=(%PI_div_2%-!p1!) %% %PIx2%, b=(a>>31|1)*a"
        if !b! gtr %PI32% (
          set /a "a=a-(a>>31|1)*%PIx2%, d=%SIN%"
        ) else if !b! gtr %PI_div_2% (
          set /a "a=(a>>31|1)*%PI%-a, d=%SIN%"
        ) else set /a "d=%SIN%"

        set /a "a=(%PI_div_2%-!p4!) %% %PIx2%, b=(a>>31|1)*a"
        if !b! gtr %PI32% (
          set /a "a=a-(a>>31|1)*%PIx2%, b=%SIN%"
        ) else if !b! gtr %PI_div_2% (
          set /a "a=(a>>31|1)*%PI%-a, b=%SIN%"
        ) else set /a "b=%SIN%"

        for /F "tokens=1,2,3" %%A in ("!c! !d! !b!") do (
          endlocal
          set /a "aStepY=%%A, aStepX=%%B, corr=%%C"
        )
      )

    set /A $X=%PlayerX%/10000, $Y=%PlayerY%/10000

    if !aStepX! equ 0 (
      set /A $tx=Dtx=100000000, $SX=0
    ) else if !aStepX! lss 0 (
                  set /A "$tx=($X*10000-PlayerX)/aStepX, Dtx=-10000*10000/aStepX, $SX=-1"
           ) else set /A "$tx=(($X+1)*10000-PlayerX)/aStepX, Dtx=10000*10000/aStepX, $SX=1"
    if !aStepY! equ 0 (
      set /A $ty=Dty=100000000, $SY=0
    ) else if !aStepY! lss 0 (
                  set /A "$ty=($Y*10000-PlayerY)/aStepY, Dty=-10000*10000/aStepY, $SY=-1"
           ) else set /A "$ty=(($Y+1)*10000-PlayerY)/aStepY, Dty=10000*10000/aStepY, $SY=1"

    set "$B=" & set /A "Distance=21*10000"

    for /L %%. in (1,1,3) do if not defined $B for /L %%? in (1,1,7) do if not defined $B (

        if !$tx! lss !$ty! (
           set /A $tx+=Dtx, $X+=$SX
           for /f "tokens=1,2" %%X in ("!$X! !$Y!") do if "!Map[%%Y]:~%%X,1!" geq "1" (
             set /A Distance=$tx-Dtx, Side=0, $B=!Map[%%Y]:~%%X,1!
           )
        ) else (
           set /A $ty+=Dty, $Y+=$SY
           for /f "tokens=1,2" %%X in ("!$X! !$Y!") do if "!Map[%%Y]:~%%X,1!" geq "1" (
             set /A Distance=$ty-Dty, Side=1, $B=!Map[%%Y]:~%%X,1!
           )
        )
    )
    if not defined $B for /f "tokens=1,2" %%X in ("!$X! !$Y!") do set "B$=!Map[%%Y]:~%%X,1!"

    set /A "Height=25*10000/( (Distance/2*corr/10000) + 1234 ), Len=Height*2, st=(50-len)/2+1"

    %= 2D-clipping =%
    if !st! lss 1 (set st=1) else if !st! gtr 50 set st=50

    for /f "tokens=1,2" %%X in ("!st! !len!") do if !$B! equ 1 (
        if !side! equ 0 (
           set "N%%Z=-!S:~0,%%X!+!S0:~0,%%Y!+!S:~0,%%X!-"
        ) else set "N%%Z=-!S:~0,%%X!+!S0s:~0,%%Y!+!S:~0,%%X!-"
    ) else (
        if !side! equ 0 (
           set "N%%Z=-!S:~0,%%X!+!S1:~0,%%Y!+!S:~0,%%X!-"
        ) else set "N%%Z=-!S:~0,%%X!+!S1s:~0,%%Y!+!S:~0,%%X!-"
    )
    set "transposedLine=!transposedLine!^!N%%Z:~%%n,1^!"
  )

)

cls & for /L %%n in (0, 1, 55) do echo( ^|%transposedLine%^|

endlocal

exit /b


Einstein1969

EDIT: I haven't used files for transpose. This is monocore version.

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#34 Post by einstein1969 » 16 Oct 2015 11:33

I have released a new version @ viewtopic.php?f=3&t=5824.

Use a version of DDA algorithm.

Code: Select all

:: ver. 0.5.0   2015-10-16 einstein1969
::  - Implemented DDA algorithm. Improved speed (~40%)
::  - Moved output of execution time on title + Add FPS counter.
::  - "H" now display Help.
::  - "M" now toggle the view of the Map
::  - Improved speed by clear the environment + other optimization (~10-15% on reference system)
::  - Map more readable.
::  - revert "reduce CALLs and rearrange code to minimize CALL distance" for easy code develop. TODO later. See ver. 0.4.x
::  - revert fast 3D clipping


Unfortunately I can not test the multithreaded part not having a multicore. :(
Anyone can test the new version? Thanks

einstein1969

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#35 Post by einstein1969 » 17 Oct 2015 12:04

I have released a new version @ viewtopic.php?f=3&t=5824.

Use a modified version of choice emulator by aGerman, token in the thread of dbenham's BATCHSNAKE.

Code: Select all

:: ver. 0.5.1   2015-10-17 einstein1969
::  - Add choice emulation. Now it should run on XP platform. Not tested.
::


I have an idea to increase performance. Like jeb, that not repeat testing on MAP, it is possible
use "ray coherence" tips used in realtime raytrace. We test about "X" time the same Map path.
It is possible avoid this and use a linear interpolation. The goal of 15 FPS is not far.

einstein1969

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#36 Post by einstein1969 » 18 Oct 2015 04:49

This is the new engine with a lot of optimizations:

Code: Select all

- Precompute all: Sin, Cos, Correction for fisheye errors.
- Use % trick for variables
- Use "For" instead of "For /F" with LF for separate elements. The For is faster!
- Minimize SET
- Keep the environment near empty, with use temporary files for storage.
- Optimize for rotate Rigth. But rotate left is similar. Moving is faster than rotate.


We pass from about 350 ms to about 210ms (~ 5 FPS) on average 8)

Any idea for other optimizations?

Code: Select all

:::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal Enabledelayedexpansion

mode 69,58

set "preserve= TMP COMSPEC NUMBER_OF_PROCESSORS preserve "
for /f "delims==" %%v in ('set') do if "!preserve: %%v =!" equ "!preserve!" set "%%v="
set "preserve="

set   MAP[1]=1212121212...2121212121..........
set   MAP[2]=2........1...1........2..121.....
set   MAP[3]=1........21212....121.1.2...2....
set   MAP[4]=1........21212....121.1.2...2....
set   MAP[5]=1.............................2..
set   MAP[6]=2....1...12121................2..
set   MAP[7]=1....2...2...2.....1..11.....1...
set   MAP[8]=1....1...1...1....12..2.2...2....
set   MAP[9]=2....2...2...2........1..121.....
set  MAP[10]=1212212121...1212121212..........

set /A Playerx=4*10000, PlayerY=5*10000, Angle=0

For /L %%N in (1,1,50) do set S=_!S!

For /L %%N in (1,1,50) do set S0=Û!S0!
For /L %%N in (1,1,50) do set S0s=°!S0s!

For /L %%N in (1,1,50) do set S1=²!S1!
For /L %%N in (1,1,50) do set S1s= !S1s!

setlocal
For /L %%N in (-32,1,32) do (
        set /A I=%%N+32
        call :sin_cos "%%N * PI / 180" sin cos
        set "_C=!_C! !cos!"
        set "TL=!TL!^!N!I!:~%%n,1^!"
)
echo !_C!>corr.txt
echo !TL!>TL.txt
endlocal

set/A  from=%angle%-32, to=%angle%+32
For /L %%Z in (%from%,1,%to%) do (
  call :sin_cos "%%Z * PI / 180" aStepY aStepX
  set "SC=!SC!"!aStepY! !aStepX!" "
)

rem for average FPS
set "t1=!time: =0!"

for /l %%. in (1,1,360) do (

  rem for instant FPS
  rem set "t1=!time: =0!"

  call :raycast

  rem for average FPS
  for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000, FPS=100000/(a*10/%%.), a=a*10/%%."
  Title Raycast Dos Batch  -  Time Elapsed:!a!ms - FPS: !FPS:~0,-2!.!FPS:~-2! [%%.]

  rem for instant FPS
  rem for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=(((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d, a+=(a>>31)&8640000, FPS=10000/a"
  rem Title Raycast Dos Batch  -  Time Elapsed:!a!0ms - FPS: !FPS:~0,-2!.!FPS:~-2! [%%.]

  set a=&set FPS=

  rem set /A Playerx=4*10000, PlayerY=5*10000+%%.*500

  set /A Angle+=1, to+=1

  call :sin_cos "!to! * PI / 180" aStepY aStepX
  set "SC=!SC!"!aStepY! !aStepX!" "
  set SC=!SC:*"=!
  set SC=!SC:*"=!

  rem pause>nul
)

pause
exit /B

rem 3.10 - 4.38 - 4.46 - 4.48 - 4.65 - 4.76 - 4.87 - 4.80 - 4.78/4.83 - 4.90
rem set /A aStepY=%%u, aStepX=%%v
rem for %%C in (!Z!) do set corr=!_C:~%%C,5!

:::::::::::::::::::::::::::::::::::::::::::::::::
:raycast
setlocal
for /f usebackq^ delims^=^ eol^= %%A in (corr.txt) do set "_C=%%A"

( %= Empty Environment =%
  for %%v in (Angle Number_of_Processors prompt comspec PlayerX
              PlayerY from to SC aStepY aStepX) do set "%%v="

  set Z=0
  For %%Z in (%SC%) do for /f "tokens=1,2" %%u in (%%Z) do (


    if %%v gtr 0 (
      set /A "$X=%PlayerX%/10000, $tx=(($X+1)*10000-%PlayerX%)*10000/%%v, Dtx=10000*10000/%%v, $SX=1"
    ) else if %%v lss 0 (
                  set /A "$X=%PlayerX%/10000, $tx=($X*10000-%PlayerX%)*10000/%%v, Dtx=-10000*10000/%%v, $SX=-1"
           ) else set /A $X=%PlayerX%/10000, $tx=Dtx=100000000, $SX=0

    if %%u gtr 0 (
      set /A "$Y=%PlayerY%/10000, $ty=(($Y+1)*10000-%PlayerY%)*10000/%%u, Dty=10000*10000/%%u, $SY=1, Distance=21*10000"
    ) else if %%u lss 0 (
                  set /A "$Y=%PlayerY%/10000, $ty=($Y*10000-%PlayerY%)*10000/%%u, Dty=-10000*10000/%%u, $SY=-1, Distance=21*10000"
           ) else set /A $Y=%PlayerY%/10000, $ty=Dty=100000000, $SY=0, Distance=21*10000

    set "$B="
    for /L %%£ in (1,1,3) do if not defined $B for /L %%? in (1,1,7) do if not defined $B (
        if !$tx! lss !$ty! (
           set /A $tx+=Dtx, $X+=$SX
           for /f "tokens=1,2" %%X in ("!$X! !$Y!") do if "!Map[%%Y]:~%%X,1!" geq "1" (
             set /A Distance=$tx-Dtx, Side=0, $B=!Map[%%Y]:~%%X,1!
           )
        ) else (
           set /A $ty+=Dty, $Y+=$SY
           for /f "tokens=1,2" %%X in ("!$X! !$Y!") do if "!Map[%%Y]:~%%X,1!" geq "1" (
             set /A Distance=$ty-Dty, Side=1, $B=!Map[%%Y]:~%%X,1!
           )
        )
    )
    for %%C in (!Z!) do set /A "Len=(25*10000/( (Distance/2*!_C:~%%C,5!/10000) + 1234 ))*2, st=(50-len)/2+1, I=Z/5, Z+=5"
    %= 2D-clipping =%
    if !st! lss 1 (set st=1) else if !st! gtr 50 set st=50
    for /f "tokens=1,2" %%X in ("!st! !len!") do if !$B! equ 1 (
        if !side! equ 0 (
              set "N!I!=-!S:~0,%%X!+!S0:~0,%%Y!+!S:~0,%%X!-"
        ) else set "N!I!=-!S:~0,%%X!+!S0s:~0,%%Y!+!S:~0,%%X!-"
    ) else (
        if !side! equ 0 (
           set "N!I!=-!S:~0,%%X!+!S1:~0,%%Y!+!S:~0,%%X!-"
        ) else set "N!I!=-!S:~0,%%X!+!S1s:~0,%%Y!+!S:~0,%%X!-"
    )
  )
)
set /P "TL="<TL.txt
cls & for /L %%n in (0, 1, 55) do echo( ^|%TL%^|
endlocal
exit /b

:Sin_Cos rad*10000 return_var*10000     rem RADIANT
  setlocal

  set /a "PI=(35500000/113+5)/10, PI_div_2=(35500000/113/2+5)/10, PIx2=2*PI, PI32=PI+PI_div_2"
  set "SIN=(a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000)"

    set /a "a=(%~1) %% %PIx2%, b=(a>>31|1)*a"
    if !b! gtr %PI32% (set /a "a=a-(a>>31|1)*%PIx2%, c=%SIN%")  else (
      if !b! gtr %PI_div_2% (set /a "a=(a>>31|1)*%PI%-a, c=%SIN%") else set /a "c=%SIN%")

    set /a "a=(%PI_div_2%-%~1) %% %PIx2%, b=(a>>31|1)*a"
    if !b! gtr %PI32% (set /a "a=a-(a>>31|1)*%PIx2%, a=%SIN%")  else (
      if !b! gtr %PI_div_2% (set /a "a=(a>>31|1)*%PI%-a, a=%SIN%") else set /a "a=%SIN%")
 
  (endlocal & set "%2=%c%" & set "%3=%a%")
goto :eof


einstein1969

npocmaka_
Posts: 512
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Dos Batch Raycast - Explorer3D Beta

#37 Post by npocmaka_ » 18 Oct 2015 06:08

Giving ideas without implementing them is easy :lol:


May be :sin_cos is compact enough to be macro instead of function.Though jeb reworked that function and he didn't made it macro so may be it's not possible :?:


And the script is big enough so may be using anonymous function instead of :raycast will give you small performance improvement - at least this one is pretty easy for check.

jeb
Expert
Posts: 1041
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Dos Batch Raycast - Explorer3D Beta

#38 Post by jeb » 18 Oct 2015 12:09

npocmaka_ wrote:May be :sin_cos is compact enough to be macro instead of function.Though jeb reworked that function and he didn't made it macro so may be it's not possible :?:

It's possible, but I remeber that there was no or only a very small gain.

But it's possible to use a lookup table, but even then it's necessary to use only a few variables, else the array search is nearly as long as the calculation (Yes I tested it).

npocmaka_ wrote:And the script is big enough so may be using anonymous function instead of :raycast will give you small performance improvement - at least this one is pretty easy for check.

As the raycast function is only called onced, it's nearly unimportant.

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#39 Post by einstein1969 » 19 Oct 2015 08:39

@npocmaka_
I have fast read the thread on anonymous function call and haven't understund how they work. maybe i should testing a lot...
I have seen that the gain is small for the time the raycast code get (200ms about on last algorithm optimized). For now i agree with jeb.

I the future when the time is small starch could come in handy !!

I have changed the algoritmh 3 times. Now it's necessary again for bypass this limits.
Now the algorithm go for each ray and traverse the map until found a wall. Then return the distance.

The idea is to use rays packets. Will start with two ray that are not near and look if go trought same destination.
If the destination is the same than the ray in the middle go in the same destination too. And with linear interpolation we calculate the distance.

This is the new algorithm, written in pseudocode (and recursive for now... anonymous function call might be usefull?)

Code: Select all

subroutine raypacket (from, to) 
   if from = to then .....????
   else
      destination1=raytraverse(from)
      destination2=raytraverse(to)
     if destination1=destination2 then
           if from - to > 1 then linear_interpolate_distance(from,to)
     else begin
         raypacket (from, from+(to-from)/2)
         raypachet (from+(to-from)/2+1, to)
     end
   end



I need help for implement new idea that allows us to get more speed gain. :evil:

einstein1969
Last edited by einstein1969 on 20 Oct 2015 04:02, edited 1 time in total.

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#40 Post by einstein1969 » 20 Oct 2015 03:16

Hi,

this is the table of improvements updated:

Improvements:

Code: Select all

vers.  frame time  FPS     Columns
0.01a   14890ms    0.06      40
0.01b    5870ms    0.17      40     swap out environment
0.1.0    3610ms    0.27      64     new algorithm (ray marching like, fixed step)
0.2.0    3840ms    0.26      64
0.3.0     750ms    1.33      64     jeb trick fast ray traversal
0.4.1     720ms    1.38*     64     dbenham multithread on monocore @2.00Ghz , 2-3 times faster on quad-core machine (4-5 frames per second)
0.5.1     400ms    2.50**    64     dda algorithm on monocore @2.00Ghz
0.5.x     200ms    5.00**    64     optimized dda algorithm on monocore @2.00Ghz (on demo code) - forecast in 0.5.x
0.6.x    <100ms  >10.00**  64/128   forecast

*: on monocore. In multicore the FPS are more
**: multicore performance data not avaible N/D :(

Future implementations: my idea :idea:
- double width (pass from 64 to 128 Columns) for small size fonts (increase only resolution on Y, same performance/FPS)
- choice default chars (Fast antialising, Normal, Wireframe, etc.)
- Asyncronous input (like BatchSnake)
- Aacini's Event-driven multi-thread scheme for Batch files 8)
- Use velocity(amount/seconds) for movements/rotations. This allows you to move at the same speed of platforms with different performances and singlecore/multicore
- Double Y resolutions. Choice chars for double resolution on Y (a little slower)
- what else? ...

What would you like to see in the new release?
Anyone can do tests on multicore and return the results performance here?

einstein1969

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#41 Post by einstein1969 » 12 Dec 2015 13:15

dbenham wrote:
einstein1969 wrote:@dbenham
I have tested the version 0.4.0 - 0.4.1 and 0.41a and all is ok.
Than I only modify a line of code for probe multitasking on my monocore.
from:

Code: Select all

  set /a proc=NUMBER_OF_PROCESSORS, childCnt=proc-1

to:

Code: Select all

  set /a proc=NUMBER_OF_PROCESSORS+1, childCnt=proc-1

In this case the result are not always the same. The output is only half some time. Some time is full and sometime is half good and half not. :(

EDIT: it would seem that the job variable is not set for the main thread and/or use the child/parallel definition.

I cannot reproduce that behavior :?

It runs flawlessly when my total number of active processes never exceeds the number of processors.

But I do see something odd about 1 frame out of 25 if I set NUMBER_OF_PROCESSORS to 5, even though my machine has 4 cores. Every now and then, it seems like one of the render files is not updated with new data, so the output is garbled. I modified the code to investigate a bit - instead of deleting the job file, I move it to original_name.sav. I can then look at each job and render file in another window as soon as I see a problem. It is really odd, because the job must have run - all the job files with .sav extension have the correct data and the last modified timestamps of each job and render file indicate each job was run and each render file created at the correct time (I looked at timestamps with millisecond precision).

I am totally stumped as to what could be happening :? :evil:


Dave Benham


Hi Dave,

I have an idea for found the concurrency problem if there are more processes than processor.

It's possible use a LOCK/MUTEX when there is access to shared resource or atomic instruction like RENAME etc. ?

I think that in this mode it's possible understund where is the real problem.

Francesco

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Explorer3D Beta

#42 Post by einstein1969 » 11 Feb 2016 12:55

Hi to all,

I have found a new algorithm for speedup.

This new algorithm is based on DE (Distance estimator functions) and is knowed how "Sphere tracing" or "Raymarch distance fileds"

With this algorithm is possible:
- speedup,
- use true antialiasing
- go from 2.5D versus full 3D. (with step size!!!) 8)

Links:
- http://computergraphics.stackexchange.com/questions/161/what-is-ray-marching-is-sphere-tracing-the-same-thing
- http://graphics.cs.illinois.edu/papers/zeno
- http://9bitscience.blogspot.it/2013/07/raymarching-distance-fields_14.html
- http://blog.hvidtfeldts.net/index.php/2011/06/distance-estimated-3d-fractals-part-i/

I thinks that the previus idea of "raypackect" is possible with this new algorithm. Multithreading also. ;)

stay tuned!

Francesco Poscetti aka Einstein1969

einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Maze3D/Explorer3D Beta

#43 Post by einstein1969 » 22 Mar 2016 04:47

I have released version 0.5.2 @ viewtopic.php?f=3&t=5824.

Use the Aacini method for calculus the functions SIN(X). See Definition and use of arithmetic "functions" in Batch files
The code is small and is about 20% faster than previous, less than 300ms on monocore @2Ghz! 3.33FPS

Code: Select all

::
:: ver. 0.5.2   2016-03-22 einstein1969
::  - Add new SIN(x) calculus using Aacini method. Improved speed (~20%)
::


Can anyone test on multicore? Give me the FPS, Ghz and Number of core of PC

einstein1969

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Dos Batch Raycast - Maze3D/Explorer3D Beta

#44 Post by foxidrive » 22 Mar 2016 12:13

I had a look einstein and it's an impressive bit of coding to get the graphics so nice.

EDIT: On a subsequent play I also noticed some odd wall reflections that appeared when I turned a little in a passage, where no wall seemed to be earlier. It was a bit tricky to navigate, but the curves and lines are nice work.

FPS: 6.25

CPU is Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
No of Cores: 4 (2 logical cores per physical)

https://www.cpubenchmark.net/cpu.php?cp ... 40+3.40GHz





Old post:

I am unsure where the FPS is shown though - this was the status on the screen.
The titlebar had text but the right side was not visible due to the narrower window.

PlayerX/Y:279512/86802 OldplayerX/Y:269513/86802
FAST: Angle:0 GridX/Y:27/8 StepX/Y=9999/0 wait=0


einstein1969
Expert
Posts: 941
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Dos Batch Raycast - Maze3D/Explorer3D Beta

#45 Post by einstein1969 » 22 Mar 2016 15:13

Thanks foxidrive.

You can change this line of code for visualize on screen the FPS:

Code: Select all

    echo !method!: Angle:!Angle! GridX/Y:!gridx!/!gridy! StepX/Y=!StepX!/!StepY! wait=!wait!%space%

with this:

Code: Select all

    echo !method!: Angle:!Angle! GridX/Y:!gridx!/!gridy! StepX/Y=!StepX!/!StepY! wait=!wait! FPS:!FPS:~0,-2!.!FPS:~-2! 

Post Reply