Formula need for ASM
OK as for the reason my discord account wont work at the moment, and i badly have a thing to ask; hence i create a new topic here: WHAT THE FUCKING HELL is this formula in ASM: y = 0,39845667173122100000x^-1,11205507677445000000 I have not found a way to express X^Y :-(( Any help here?? Any "no shader hacker" who can tell me how to express a X^Y in another way?? I know x^-1 = 1/X ^^
OK as for the reason my discord account wont work at the moment, and i badly have a thing to ask; hence i create a new topic here:


WHAT THE FUCKING HELL is this formula in ASM: y = 0,39845667173122100000x^-1,11205507677445000000

I have not found a way to express X^Y :-((

Any help here?? Any "no shader hacker" who can tell me how to express a X^Y in another way?? I know x^-1 = 1/X ^^

Like my work? Donations can be made via PayPal to: rauti@inetmx.de

#1
Posted 04/13/2019 04:29 PM   
Just a stab in the dark here, but perhaps this might help [quote="bo3b"] Prime Directive This is the prime directive code in ASM for DX9 and HelixMod. And the HLSL version for 3Dmigoto. In all cases, we are implementing the NVidia specified formula of: clipPos.x += EyeSign * Separation * ( clipPos.w – Convergence ) [/quote] http://wiki.bo3b.net/index.php?title=Canonical_Stereo_Code He also posted some ASM Gotcha [code]ASM Gotcha - You cannot use two different constant registers in a given instruction. add r30.x, c250.y, c220.x will silently fail. But add r30.x, c250.y, c250.x will work. Use temp registers as a workaround. Gotcha - Output registers cannot be read. mov r3, o0 will silently fail, but still assemble. Overwriting an output register works. Gotcha - Reading from a masked component of an input register can cause strange results (in some cases fixing the issue is insufficient to make the weirdness go away and the game has to be restarted). e.g. if an input register was declared dcl_texcoord5 v6.xy, then doing a mov r30, v6 is illegal as it tries to read from all four components of v6, the z and w of which are invalid. Gotcha - Right side swizzles can silently fail if you only use 2 or 3 parameters. e.g. mov r1.yzw, r30.xyz will silently add w to the end giving the result mov r1.yzw, r30.xyzw which maps yzw to yzw, which is not what you expect. mov r1.yzw, r30.xxyz is correct. [/code]
Just a stab in the dark here, but perhaps this might help

bo3b said: Prime Directive

This is the prime directive code in ASM for DX9 and HelixMod. And the HLSL version for 3Dmigoto. In all cases, we are implementing the NVidia specified formula of:

clipPos.x += EyeSign * Separation * ( clipPos.w – Convergence )


http://wiki.bo3b.net/index.php?title=Canonical_Stereo_Code


He also posted some ASM Gotcha

ASM

Gotcha - You cannot use two different constant registers in a given instruction. add r30.x, c250.y, c220.x will silently fail. But add r30.x, c250.y, c250.x will work. Use temp registers as a workaround.

Gotcha - Output registers cannot be read. mov r3, o0 will silently fail, but still assemble. Overwriting an output register works.

Gotcha - Reading from a masked component of an input register can cause strange results (in some cases fixing the issue is insufficient to make the weirdness go away and the game has to be restarted). e.g. if an input register was declared dcl_texcoord5 v6.xy, then doing a mov r30, v6 is illegal as it tries to read from all four components of v6, the z and w of which are invalid.

Gotcha - Right side swizzles can silently fail if you only use 2 or 3 parameters. e.g. mov r1.yzw, r30.xyz will silently add w to the end giving the result mov r1.yzw, r30.xyzw which maps yzw to yzw, which is not what you expect. mov r1.yzw, r30.xxyz is correct.

#2
Posted 04/13/2019 05:27 PM   
nope :-) i just need an exrpession for this wone in ASM y = 0,39845667173122100000x^-1,11205507677445000000 VALE = NUMBER * X^NUMBER2 I have a correction value to calculate with a power of function But i dont know how to express a VALUE-HIGH-SOMETHING dont know how its called in english.. for example 2 HIGH 2 (2^2) = 4 ... but whats .... for example 3^-5 ?????? I know 1^-1 = 1/-1
nope :-)

i just need an exrpession for this wone in ASM

y = 0,39845667173122100000x^-1,11205507677445000000


VALE = NUMBER * X^NUMBER2

I have a correction value to calculate with a power of function

But i dont know how to express a VALUE-HIGH-SOMETHING

dont know how its called in english..


for example 2 HIGH 2 (2^2) = 4 ... but whats .... for example 3^-5 ?????? I know 1^-1 = 1/-1

Like my work? Donations can be made via PayPal to: rauti@inetmx.de

#3
Posted 04/13/2019 05:51 PM   
Oh well, the only hacking I've done, is skipping shaders :P Perhaps look at DarkStarSword's repository. http://github.com/DarkStarSword/3d-fixes or http://darkstarsword.net/
Oh well, the only hacking I've done, is skipping shaders :P

Perhaps look at DarkStarSword's repository. http://github.com/DarkStarSword/3d-fixes or http://darkstarsword.net/

#4
Posted 04/13/2019 06:09 PM   
@Losti This is the function: pow (x,y) = x^y [url]https://docs.microsoft.com/es-es/windows/desktop/direct3dhlsl/dx-graphics-hlsl-pow[/url] Original credits to bo3b! he found that function years ago when Frame analysis don't exist and have to use to fix shadows/lights/reflections in the early fixes of Dying Light. *EDIT: You need for ASM. For ASM i don't know.
@Losti

This is the function: pow (x,y) = x^y

https://docs.microsoft.com/es-es/windows/desktop/direct3dhlsl/dx-graphics-hlsl-pow

Original credits to bo3b! he found that function years ago when Frame analysis don't exist and have to use to fix shadows/lights/reflections in the early fixes of Dying Light.

*EDIT: You need for ASM. For ASM i don't know.

MY WEB

Helix Mod - Making 3D Better

My 3D Screenshot Gallery

Like my fixes? you can donate to Paypal: dhr.donation@gmail.com

#5
Posted 04/13/2019 06:25 PM   
[quote="DHR"]@Losti This is the function: pow (x,y) = x^y [url]https://docs.microsoft.com/es-es/windows/desktop/direct3dhlsl/dx-graphics-hlsl-pow[/url] Original credits to bo3b! he found that function years ago when Frame analysis don't exist and have to use to fix shadows/lights/reflections in the early fixes of Dying Light. *EDIT: You need for ASM. For ASM i don't know.[/quote] ill have to wait for DSS it seems ^^ I have fixed a shader that need a power of correctioon formula.....y = 0,39845667173122100000x^-1,1120550767744500000 and i need this for ASM. X=Convergence, Y=calulated corretion value
DHR said:@Losti

This is the function: pow (x,y) = x^y

https://docs.microsoft.com/es-es/windows/desktop/direct3dhlsl/dx-graphics-hlsl-pow

Original credits to bo3b! he found that function years ago when Frame analysis don't exist and have to use to fix shadows/lights/reflections in the early fixes of Dying Light.

*EDIT: You need for ASM. For ASM i don't know.


ill have to wait for DSS it seems ^^

I have fixed a shader that need a power of correctioon formula.....y = 0,39845667173122100000x^-1,1120550767744500000


and i need this for ASM. X=Convergence, Y=calulated corretion value

Like my work? Donations can be made via PayPal to: rauti@inetmx.de

#6
Posted 04/13/2019 06:48 PM   
Untested shader model 5 ASM: [code] // y = (0.39845667173122100000 * x) ^ -1.11205507677445000000 // - Where x is r0.x and y is r1.x // 0.39845667173122100000 * x mul r1.x, r0.x, l(0.39845667173122100000) // Perform pow(x,y) which is exp(log(x) * y) // - Where x is r1.x and y is 1.11205507677445000000 // - Pow() isn't supported in sm5. Note log() and exp() are base 2 log r1.x, r1.x mul r1.x, r1.x, l(1.11205507677445000000) exp r1.x, r1.x // Perform 1/result due to the negative exponent div r1.x, l(1.0000), r1.x [/code] After trying different calculators, it seems the result should be positive.
Untested shader model 5 ASM:

// y = (0.39845667173122100000 * x) ^ -1.11205507677445000000
// - Where x is r0.x and y is r1.x

// 0.39845667173122100000 * x
mul r1.x, r0.x, l(0.39845667173122100000)

// Perform pow(x,y) which is exp(log(x) * y)
// - Where x is r1.x and y is 1.11205507677445000000
// - Pow() isn't supported in sm5. Note log() and exp() are base 2
log r1.x, r1.x
mul r1.x, r1.x, l(1.11205507677445000000)
exp r1.x, r1.x

// Perform 1/result due to the negative exponent
div r1.x, l(1.0000), r1.x

After trying different calculators, it seems the result should be positive.

---
Windows 10 x64 / 1x 980Ti GPU (no SLI, 418.81 driver) / 1920x1080

#7
Posted 04/13/2019 08:26 PM   
[quote="Losti"][quote="DHR"]@Losti This is the function: pow (x,y) = x^y [url]https://docs.microsoft.com/es-es/windows/desktop/direct3dhlsl/dx-graphics-hlsl-pow[/url] Original credits to bo3b! he found that function years ago when Frame analysis don't exist and have to use to fix shadows/lights/reflections in the early fixes of Dying Light. *EDIT: You need for ASM. For ASM i don't know.[/quote]ill have to wait for DSS it seems ^^ I have fixed a shader that need a power of correctioon formula.....y = 0,39845667173122100000x^-1,1120550767744500000 and i need this for ASM. X=Convergence, Y=calulated corretion value[/quote] A general approach you can use for problems like this is to express the function you want in HLSL, then compile that and look at the ASM generated. In this case, you should be able to use the HLSL pow function and see what the compiler turns that into. You can either use it in game if you've already got the shader in HLSL, or use the offline cmd_decompiler tool in a cmd window. Edit: Seems like Schwing.'s code is right there. Here are the docs: [url]https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/pow---vs[/url]
Losti said:
DHR said:@Losti

This is the function: pow (x,y) = x^y

https://docs.microsoft.com/es-es/windows/desktop/direct3dhlsl/dx-graphics-hlsl-pow

Original credits to bo3b! he found that function years ago when Frame analysis don't exist and have to use to fix shadows/lights/reflections in the early fixes of Dying Light.

*EDIT: You need for ASM. For ASM i don't know.
ill have to wait for DSS it seems ^^

I have fixed a shader that need a power of correctioon formula.....y = 0,39845667173122100000x^-1,1120550767744500000


and i need this for ASM. X=Convergence, Y=calulated corretion value

A general approach you can use for problems like this is to express the function you want in HLSL, then compile that and look at the ASM generated.

In this case, you should be able to use the HLSL pow function and see what the compiler turns that into. You can either use it in game if you've already got the shader in HLSL, or use the offline cmd_decompiler tool in a cmd window.

Edit: Seems like Schwing.'s code is right there. Here are the docs: https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/pow---vs

Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers

#8
Posted 04/13/2019 09:15 PM   
TAHNK YOU Schwing and Bo3B. Yes, i rememberm, DSS told me some time ago about the HLSL compile to ASM and grap the code ^^ Now i remember that ^^ but its a CS that HLSL code is wrong here. Ill now try the Schwing. Formula .-) DSS told me that LOG/EXP thing but i wasnt able to use because i dont understand the math behind LOG/EXP anymore ^^ its some time ago i was in shool ^^ ... stupid losti ^^ //EDITH: Something is not working here, the value should be 2,68 fix r14.w but it issnt, because the correction for the effect is far away from beeing OK. mul r14.w, r13.y, l(0.39845667173122100000) log r14.w, r14.w mul r14.w, r14.w, l(1.11205507677445000000) exp r14.w, r14.w div r14.w, l(1.0000), r14.w dp4 r14.x, cb0[22].xyzw, r2.xyzw mul r14.x, r14.x, -r13.y mul r14.x, r14.x, r13.x //mul r14.x, r14.x, l(2.68) mul r14.x, r14.x, r14.w add r2.x, r2.x, r14.x hm....................
TAHNK YOU Schwing and Bo3B.

Yes, i rememberm, DSS told me some time ago about the HLSL compile to ASM and grap the code ^^ Now i remember that ^^ but its a CS that HLSL code is wrong here.

Ill now try the Schwing. Formula .-) DSS told me that LOG/EXP thing but i wasnt able to use because i dont understand the math behind LOG/EXP anymore ^^ its some time ago i was in shool ^^ ... stupid losti ^^

//EDITH:

Something is not working here, the value should be 2,68 fix r14.w but it issnt, because the correction for the effect is far away from beeing OK.

mul r14.w, r13.y, l(0.39845667173122100000)
log r14.w, r14.w
mul r14.w, r14.w, l(1.11205507677445000000)
exp r14.w, r14.w
div r14.w, l(1.0000), r14.w


dp4 r14.x, cb0[22].xyzw, r2.xyzw
mul r14.x, r14.x, -r13.y
mul r14.x, r14.x, r13.x
//mul r14.x, r14.x, l(2.68)
mul r14.x, r14.x, r14.w
add r2.x, r2.x, r14.x

hm....................

Like my work? Donations can be made via PayPal to: rauti@inetmx.de

#9
Posted 04/14/2019 05:35 AM   
There's a line on the [url=https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/pow---ps]pow() doc page[/url] that says "this instruction could be expanded to exp(src1 * log(src0))".
There's a line on the pow() doc page that says "this instruction could be expanded to exp(src1 * log(src0))".

---
Windows 10 x64 / 1x 980Ti GPU (no SLI, 418.81 driver) / 1920x1080

#10
Posted 04/14/2019 08:10 AM   
I have found a working formula, the values are different, means the EXP and the LOG thing is not the same like x to the POWER of .... but its working now ^^
I have found a working formula, the values are different, means the EXP and the LOG thing is not the same like x to the POWER of .... but its working now ^^

Like my work? Donations can be made via PayPal to: rauti@inetmx.de

#11
Posted 04/14/2019 08:17 AM   
Hey, DSS is awake and solved it, the right expression is: r13.y is my X in the formula (the convergence) -1.1120550767744500000 is the exponent log r14.w, r13.y mul r14.w, r14.w, l(-1.1120550767744500000) exp r14.w, r14.w mul r14.w, r14.w, l(0.39845667173122100000) NICE !!! working now !!! without my manual correction in the formula, i used: //log r14.w, r13.y //mul r14.w, r14.w, l(1.01205507677445000000) //exp r14.w, r14.w //mul r14.w, r14.w, l(2.4245667173122100000) //// Perform 1/result due to the negative exponent //div r14.w, l(1.0000), r14.w and later another MUL for the r14.w by 1.16....it was working but it was not thath elegant and not that smooth correct as it is now ^^
Hey, DSS is awake and solved it, the right expression is:

r13.y is my X in the formula (the convergence)
-1.1120550767744500000 is the exponent

log r14.w, r13.y
mul r14.w, r14.w, l(-1.1120550767744500000)
exp r14.w, r14.w
mul r14.w, r14.w, l(0.39845667173122100000)



NICE !!! working now !!! without my manual correction in the formula, i used:

//log r14.w, r13.y
//mul r14.w, r14.w, l(1.01205507677445000000)
//exp r14.w, r14.w
//mul r14.w, r14.w, l(2.4245667173122100000)
//// Perform 1/result due to the negative exponent
//div r14.w, l(1.0000), r14.w

and later another MUL for the r14.w by 1.16....it was working but it was not thath elegant and not that smooth correct as it is now ^^

Like my work? Donations can be made via PayPal to: rauti@inetmx.de

#12
Posted 04/14/2019 09:01 AM   
Scroll To Top