Author Topic: Wavefront object viewer  (Read 79030 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #30 on: March 21, 2015, 02:05:36 AM »
Yes, I get the alpha mask aspect. In Oxygen's Opengl frame work, the Snapshot utility will make any uniform background transparent, and save the image as a png file. Ctrl-Shift-P

I was more interested in the primary hair texture, and whether it can be convincingly synthesised, with some sine waves and a Perlin noise generator :)


.
« Last Edit: March 21, 2015, 02:12:22 AM by Charles Pegge »

Frankolinox

  • Guest
Re: Wavefront object viewer
« Reply #31 on: March 21, 2015, 03:51:30 AM »
Noise generator is good for texture purpose.. ten years ago i wrote a nurbs script for a 3d application to simulate hairs.. they interpolate the hair density and thickness.. but i can remember you have done already good grass example for oxygen so far as I can remember.. if i find my scrpt i can send a screenshot too :) via smartphone.. regards frank

Frankolinox

  • Guest
Re: Wavefront object viewer
« Reply #32 on: March 21, 2015, 06:53:22 AM »
two images from my old nurbs project works with a simple "nurbshelper.js" (javascript) in similar cases ;). might be possible to creat such a tool for oxygenbasic too with a request editor for nurbs properties too.. unfortunately I haven't found yet the script.. very old file ones saved on usb stick

nice weekend, frank

.

Aurel

  • Guest
Re: Wavefront object viewer
« Reply #33 on: March 24, 2015, 01:31:07 PM »
Quote
See this article, there is not one single answer about this topic.
http://www.codeproject.com/Articles/224754/Guide-to-Win-Memory-DC.

that is why i am confused about DC things to

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #34 on: March 26, 2015, 02:33:32 PM »
Combining models :)

I wonder if there is a way to make Daz3D/Poser figures look more natural. Perhaps they are defined too precisely, compared to the real thing. Texture noise?


Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #35 on: March 27, 2015, 11:13:16 PM »
Quantino

Salt water Powered Car

https://www.youtube.com/watch?v=ERTIB-VlyL8

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #36 on: March 28, 2015, 07:01:42 PM »






Gilles Tran / 2003 / POV-Ray

http://www.oyonale.com

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #37 on: March 29, 2015, 03:39:18 AM »
Hi Mike,

How far can one go with ray-tracing, with the aid of shaders? Some of those POV-Rays scenes take hours, if not days to render, not taking advantage of graphics hardware acceleration.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #38 on: March 29, 2015, 11:06:23 AM »

Thanks for the info, Mike.

Unfortunately, I don't have the spare capacity to pursue Ray-Tracing at present, but you have some very interesting Opengl, on your forum, (http://www.fbsl.net/phpbb2/viewforum.php?f=36
) which I hope to follow up soon.

What format would you recommend as an alternative to OBJ ? - Depending on expressive potential, and availability of models.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #39 on: March 30, 2015, 10:16:41 AM »

Mike,

My effort at half-float block conversion, without lookup tables: (about 4 nanoseconds on my PC).

Code: OxygenBasic
  1.  
  2. 'HALF-FLOATS
  3. ============
  4.  
  5. 'IEE 754
  6. 'http://en.wikipedia.org/wiki/Single-precision_floating-point_format
  7. 'http://en.wikipedia.org/wiki/Half-precision_floating-point_format
  8.  
  9. sub FloatToHalfFloat(sys pf,ph,n)
  10. =================================
  11. {
  12. 'USE OF REGISTERS:
  13. 'edx sign transform
  14. 'eax exponent transform
  15. 'ecx significand transform
  16. 'esi source pointer
  17. 'edi dest pointer
  18. '
  19. mov esi,pf
  20. mov edi,ph
  21. (
  22.   dec dword n
  23.   jl exit
  24.   mov ecx,[esi]
  25.   mov edx,ecx
  26.   mov eax,ecx
  27.   and edx,0x80000000 'mask sign bit
  28.  shr ecx,0x0d       'reduce significand 23 bits to 10bits
  29.  shr edx,0x10       'shove sign bit down 16
  30.  shr eax,0x17       'shove exponent down 23
  31.  and ecx,0x3ff      'mask significand 10 bits
  32.  and eax,0xff       'mask exponent 8 bits
  33.  sub eax,0x70       'adjust exponent bias -112 == (15-127)
  34.  shl eax,0x0a       'place exponent 10 bits up
  35.  or  eax,ecx
  36.   or  eax,edx
  37.   mov [edi],ax
  38.   add esi,4
  39.   add edi,2
  40.   repeat
  41. )  
  42. }
  43.  
  44. sub HalfFloatToFloat(sys ph,pf,n)
  45. =================================
  46. {
  47. 'USE OF REGISTERS:
  48. 'edx sign transform
  49. 'eax exponent transform
  50. 'ecx significand transform
  51. 'esi source pointer
  52. 'edi dest pointer
  53. '
  54. mov esi,ph
  55. mov edi,pf
  56. (
  57.   dec dword n
  58.   jl exit
  59.   mov ecx,[esi]
  60.   mov edx,ecx
  61.   mov eax,ecx
  62.   and edx,0x8000    'mask sign bit
  63.  shl ecx,0x0d      'expand significand 10 bits to 23bits
  64.  shl edx,0x10      'shove sign bit up 16
  65.  shr eax,0x0a      'shove exponent down 10
  66.  and ecx,0x7fffff  'mask 23 bit significand
  67.  and eax,0x1f      'mask exponent 5 bits
  68.  add eax,0x70      'adjust exponent bias +112 == (127-15)
  69.  shl eax,0x17      'place exponent 23 bits up
  70.  or eax,ecx
  71.   or eax,edx
  72.   mov [edi],eax
  73.   add esi,2
  74.   add edi,4
  75.   repeat
  76. )  
  77. }
  78.  
  79.  
  80.  
  81.  
  82. string ShowFloatBits(float f)
  83. =============================
  84. {
  85. string c, s=space 32
  86. sys k,i
  87. cast float k=f
  88. for i = 1 to 32
  89.   if k and 0x80000000 then
  90.     c="1"
  91.   else
  92.     c="0"
  93.   end if
  94.   mid s,i,c
  95.   k=k << 1
  96. next
  97. return mid(s,1,1)+"  "+mid(s,2,8)+"  "+mid(s,10,8)+"  "+mid(s,18,8)+"  "+mid(s,26,7)+"  "
  98. }
  99.  
  100. string ShowHalfFloatBits(sys h)
  101. ===============================
  102. {
  103. string c, s=space 16
  104. sys k,i
  105. k=h
  106. for i = 1 to 16
  107.   if k and 0x8000 then
  108.     c="1"
  109.   else
  110.     c="0"
  111.   end if
  112.   mid s,i,c
  113.   k=k << 1
  114. next
  115. return mid(s,1,1)+"  "+mid(s,2,5)+"  "+mid(s,7,10)+"  "
  116. }
  117.  
  118.  
  119.  
  120.  
  121. 'TESTS
  122. '=====
  123.  
  124. ! GetTickCount lib "kernel32.dll" ()   as sys
  125.  
  126. 'print ShowFloatBits 1.5
  127. 'print ShowFloatBits -2.5
  128.  
  129. % asz 2e7 'size of conversion arrays
  130.  
  131. short hf[asz]
  132. float sf[asz]
  133. sf[1]=-1.5
  134. 'print ShowFloat sf[1]
  135. 'print sf[1]
  136. 'FloatToHalfFloat @sf,@hf,1
  137. 'print showHalfFloat hf[1]
  138. 'HalfFloatToFloat @hf,@sf,1
  139. 'print sf[1]
  140.  
  141. print "Start"
  142. t1=GetTickCount
  143. FloatToHalfFloat @sf,@hf,asz
  144. t2=GetTickCount
  145.  
  146. print str( (1e6/asz) * (t2-t1),1) " nanoseconds per float conversion"
  147.  
  148.  

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #40 on: March 31, 2015, 02:50:38 AM »

As proof of concept: ByteFloats: exponent 4 bits mantissa 3 bits :)

Code: OxygenBasic
  1.  
  2. 'BYTE-FLOATS
  3. ============
  4.  
  5. 'http://en.wikipedia.org/wiki/Minifloat
  6. 'related: IEE 754
  7. 'http://en.wikipedia.org/wiki/Single-precision_floating-point_format
  8. 'http://en.wikipedia.org/wiki/Half-precision_floating-point_format
  9.  
  10. sub FloatToByteFloat(sys pf,ph,n)
  11. =================================
  12. {
  13. 'USE OF REGISTERS:
  14. 'edx sign transform
  15. 'eax exponent transform
  16. 'ecx significand transform
  17. 'esi source pointer
  18. 'edi dest pointer
  19. '
  20. mov esi,pf
  21. mov edi,ph
  22. (
  23.   dec dword n
  24.   jl exit
  25.   mov ecx,[esi]
  26.   mov edx,ecx
  27.   mov eax,ecx
  28.   and edx,0x80000000 'mask sign bit
  29.  shr ecx,0x14       'reduce significand 23 bits to 3 bits 20==(23-3)
  30.  shr edx,0x18       'shove sign bit down 24
  31.  shr eax,0x17       'shove exponent down 23
  32.  and ecx,0x07       'mask significand 3 bits
  33.  and eax,0x0f       'mask exponent 4 bits
  34.  sub eax,0x78       'adjust exponent bias -120 == (7-127)
  35.  shl eax,0x03       'place exponent 3 bits up
  36.  or  eax,ecx
  37.   or  eax,edx
  38.   mov [edi],al
  39.   add esi,4
  40.   inc edi
  41.   repeat
  42. )  
  43. }
  44.  
  45. sub ByteFloatToFloat(sys ph,pf,n)
  46. =================================
  47. {
  48. 'USE OF REGISTERS:
  49. 'edx sign transform
  50. 'eax exponent transform
  51. 'ecx significand transform
  52. 'esi source pointer
  53. 'edi dest pointer
  54. '
  55. mov esi,ph
  56. mov edi,pf
  57. (
  58.   dec dword n
  59.   jl exit
  60.   mov cl,[esi]
  61.   mov edx,ecx
  62.   mov eax,ecx
  63.   and edx,0x80      'mask sign bit
  64.  shl ecx,0x14      'expand significand 3 bits to 23bits (23-3)
  65.  shl edx,0x18      'shove sign bit up 24
  66.  shr eax,0x03      'shove exponent down 3
  67.  and ecx,0x7fffff  'mask 23 bit significand
  68.  and eax,0x0f      'mask exponent 4 bits
  69.  add eax,0x78      'adjust exponent bias  120 == (127-7)
  70.  shl eax,0x17      'place exponent 23 bits up
  71.  or eax,ecx
  72.   or eax,edx
  73.   mov [edi],eax
  74.   inc esi
  75.   add edi,4
  76.   repeat
  77. )  
  78. }
  79.  
  80.  
  81.  
  82.  
  83. string ShowFloatBits(float f)
  84. =============================
  85. {
  86. string c, s=space 32
  87. sys k,i
  88. cast float k=f
  89. for i = 1 to 32
  90.   if k and 0x80000000 then
  91.     c="1"
  92.   else
  93.     c="0"
  94.   end if
  95.   mid s,i,c
  96.   k=k << 1
  97. next
  98. return mid(s,1,1)+"  "+mid(s,2,8)+"  "+mid(s,10,8)+"  "+mid(s,18,8)+"  "+mid(s,26,7)+"  "
  99. }
  100.  
  101. string ShowByteFloatBits(sys h)
  102. ===============================
  103. {
  104. string c, s=space 8
  105. sys k,i
  106. k=h
  107. for i = 1 to 8
  108.   if k and 0x80 then
  109.     c="1"
  110.   else
  111.     c="0"
  112.   end if
  113.   mid s,i,c
  114.   k=k << 1
  115. next
  116. return mid(s,1,1)+"  "+mid(s,2,4)+"  "+mid(s,6,3)+"  "
  117. }
  118.  
  119.  
  120.  
  121.  
  122. 'TESTS
  123. '=====
  124.  
  125.  
  126. 'print ShowFloatBits 1.5
  127. 'print ShowFloatBits -2.5
  128.  
  129. % asz 2e7 'size of conversion arrays
  130.  
  131. byte bf[asz]
  132. float sf[asz]
  133. sf[1]=-1.5
  134.  
  135. print ShowFloatBits sf[1]
  136. 'print sf[1]
  137. FloatToByteFloat @sf,@bf,1
  138. print showByteFloatBits bf[1]
  139. ByteFloatToFloat @bf,@sf,1
  140. print showFloatBits sf[1]
  141. print sf[1]
  142.  
  143.  
  144. ! GetTickCount lib "kernel32.dll" ()   as sys
  145. 'print "Start"
  146. 't1=GetTickCount
  147. 'FloatToHalfFloat @sf,@bf,asz
  148. 't2=GetTickCount
  149.  
  150. 'print str( (1e6/asz) * (t2-t1),1) " nanoseconds per float conversion"
  151.  

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #41 on: April 01, 2015, 10:19:03 PM »
Thanks for testing, Mike.

Yes, I see 0, infinity, and NAN make a simple transform impossible. The LUTs have it!

PS:

This function includes conditional blocks for processing 0 and infinity. But it costs an additional 15% in processing time, assuming an even distribution of 0.0 values.

Code: OxygenBasic
  1. sub FloatToHalfFloat(sys pf,ph,n)
  2. =================================
  3. {
  4. 'USE OF REGISTERS:
  5. 'edx sign transform
  6. 'eax exponent transform
  7. 'ecx significand transform
  8. 'esi source pointer
  9. 'edi dest pointer
  10. '
  11. mov esi,pf
  12. mov edi,ph
  13. (
  14.   dec dword n
  15.   jl exit
  16.   mov ecx,[esi]
  17.   mov edx,ecx
  18.   mov eax,ecx
  19.   and edx,0x80000000 'mask sign bit
  20.  shr edx,0x10       'shove sign bit down 16
  21.  (
  22.    'TEST FOR 0
  23.   test eax,0x7fffffff
  24.    jnz exit
  25.    jmp fwd nzero
  26.   )
  27.   shr eax,0x17       'shove exponent down 23
  28.  and eax,0xff       'mask exponent 8 bits
  29.  shr ecx,0x0d       'reduce significand 23 bits to 10 bits
  30.  sub eax,0x70       'adjust exponent bias -112 == (15-127)
  31.  (
  32.     'TEST FOR OVERFLOW / INFINITY / NAN
  33.    cmp eax,0x1f
  34.     jle exit
  35.     mov eax,0x1f
  36.   )  
  37.   shl eax,0x0a       'place exponent 10 bits up
  38.  and ecx,0x3ff      'mask significand 10 bits
  39.  or  eax,ecx
  40.   nzero:
  41.   or  eax,edx
  42.   mov [edi],ax
  43.   add esi,4
  44.   add edi,2
  45.   repeat
  46. )  
  47. }
  48.  
« Last Edit: April 01, 2015, 10:55:58 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #42 on: April 02, 2015, 04:48:57 AM »

Clamps for both zero and infinity are required, further diminishing performance. Is it worth pursuing, I wonder.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #43 on: April 03, 2015, 06:01:36 AM »
Hi Mike,

Before I start filling my demos with half-floats, do all graphics cards support them? - not just an nVidia thing.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #44 on: April 03, 2015, 06:50:34 AM »

Thanks Mike, I'll confine it to a few demos.

I also came across a brief discussion here:

http://forum.unity3d.com/threads/using-half-format-floating-point-on-pc.259845/

PS Your interiors remind me of the hall in Mentmore Towers:

http://theinfounderground.com/smf/index.php?topic=10708.0