English
Source / code snippets

The Quake-ploy

 
- Page 1 -



p.specht

Berühmter bit-hack-Algorithmus from QUAKE III
to that Invertieren of Quadratwurzeln
... becomes with the Normierung the length of 3D-Vektoren in Single precision float-variables inserted. In Assembler over three time faster as 1/Sqrt() !, Error max. 1 %:

Youtube-Link (engl.):  [...] 
 
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
01/03/21  
 



« this Posting watts as Solution marked. »


Michael
W.
now Yes, whom should we really emulate can.

there The (Microsoft-)Floats Yes through Single() in a Longint stored go can...

// Inverse Square Root

// Def !threehalfs 1.5 // or as wirkliche Constant, then as prefix

Proc Q_rsqrt
Parameters number!
Declare i&, x2!, y!
Var threehalfs! = 1.5 // with richtiger Constant becomes these row then removes

x2! = number! * 0.5
y! = number!

i& = Single(y!)
i& = $5F3759DF - (i& >> 1)
y! = double(i&)

y! = y! * (threehalfs! - (x2! * y! * y!)) // y! * (threehalfs! - (x2! * Sqr(y!)))
// y! = y! * (threehalfs! - (x2! * y! * y!)) // y! * (threehalfs! - (x2! * Sqr(y!)))
Return y!
ENDPROC

I have only To to Formel geschaut.
simply test times.
 
Alle Sprachen
System: Windows 8/10, XProfan X4
Programmieren, das spannendste Detektivspiel der Welt.
01/06/21  
 




p.specht

Mutiger attempt, large THANK YOU!

sees well from:
// Inverse Square Root
// Def !threehalfs 1.5  // or as wirkliche Constant, then as prefix

Proc Q_rsqrt

    Parameters number!
    Declare i&, x2!, y!
    Var threehalfs! = 1.5// with richtiger Constant becomes these row then removes
    x2! = number! * 0.5
    y!  = number!
    i&  = Single(y!)
    i&  = $5F3759DF - (i& >> 1)
    y!  = double(i&)
    y!  = y! * (threehalfs! - (x2! * y! * y!))// y! * (threehalfs! - (x2! * Sqr(y!)))
    '//y!  = y! * (threehalfs! - (x2! * y! * y!))  // y! * (threehalfs! - (x2! * Sqr(y!)))
    Return y!

ENDPROC

Window Title "Testbench for Michael Wodrichs Quake-Trick"
AppendMenubar 100,"   Testwert           Quake-output          1/Sqrt()         Abs.Error         Rel.Err %"
cls:Set("decimals",7):Print
Declare w!

WhileLoop 1,999999,50:w!=&Loop/100//generiert 5000 Test steps

    Print "  ",w!,Q_rsqrt(w!),1/Sqrt(w!),(Q_rsqrt(w!)-1/Sqrt(w!)),(Abs(Q_rsqrt(w!)-1/Sqrt(w!))/(1/Sqrt(w!)))*100,"%"

    If %csrlin>27:WaitInput 8000:cls:Print:EndIf

    EndWhile

    Print:Print "---":Beep
    WaitInput
    End
 
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
01/06/21  
 




Sven
Bader
Since I straight with the Generierung of Normalen work, have so did i time whom Hack here ausprobiert. for the showed example could I none optischen Difference check. whether it in XProfan objectively faster is have I not yet ausprobiert.

in the next step should I incidentally yet The apiece 4 Normalen, which into Schnittpunkten meet summarize, then is the Schattierung neatened.


231 kB
Hochgeladen:09/25/21
Downloadcounter57
Download
 
09/25/21  
 




p.specht

keeps sure nice and warm with the many Haaren!
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
09/27/21  
 




Sven
Bader



301 kB
Hochgeladen:09/28/21
Downloadcounter62
Download
 
09/28/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

4.756 Views

Untitledvor 0 min.
Gast.0815Gestern (15:29)
Member 862464105/12/24
Axel Berse08/13/23
Sven Bader02/01/23
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie