Gamestudio Links
Zorro Links
Newest Posts
Specular Shader
by Dooley
Yesterday at 18:17
is 3dgs byDirextX or Opengl?
by Dooley
Yesterday at 18:09
Tensorflow and Python 32 bit
by jcl
Yesterday at 13:28
New Zorro version 2.12
by jcl
05/21/19 17:23
Mixed frequency history (M1+D)
by jcl
05/20/19 12:21
This is my fault-tolerant ATR indicator for you
by OptimusPrime
05/18/19 16:35
missing trade variables
by AndrewAMD
05/18/19 12:37
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online
5 registered (kvm, Michael_Schwarz, Ayumi, Dooley, 1 invisible), 519 Guests and 1 Spider online.
Key: Admin, Global Mod, Mod
Newest Members
Reza65, Pritamchakra, h4h4rd, ccm, Pippo
18224 Registered Users
Topic Options
Rate This Topic
#474628 - 10/26/18 15:54 [SUB]float16 to var
txesmi Offline
Serious User

Registered: 06/13/07
Posts: 1216
Loc: Hiporope and its pain
Hi,
I recently needed to retrieve a pixel from a 16 bits floating point formatted render target.

Code:
var var_from_float16short(short _s) {
	int _sign = _s & 32768;
	int _exp = ((int)(_s & 31744) >> 10) - 15;
	int _frac = _s & 1023;
	var _r;
	memcpy(&_r, &_frac, 4);
	_r += 1;
	if(_exp)
		_r *= pow(2, _exp);
	if (_sign)
		_r = -_r;
	return _r;
}



Salud!

Top
#475469 - 12/12/18 13:28 Re: [SUB]float16 to var [Re: txesmi]
Superku Offline
Senior Expert

Registered: 09/13/03
Posts: 6841
Loc: Kiel (Germany)
Thanks for sharing!
_________________________
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

Top


Moderator:  HeelX, Lukas, Rei_Ayanami, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de