| |
|
|
- 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. |
|
|
| |
|
|
|
|
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.
|
|
|
| |
|
|
|
p.specht
| keeps sure nice and warm with the many Haaren! |
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 09/27/21 ▲ |
|
|
|
|
Sven Bader |
|
|
| |
|
|