Author Topic: _DEPTHBUFFER  (Read 2998 times)

0 Members and 1 Guest are viewing this topic.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
_DEPTHBUFFER
« on: December 12, 2020, 10:29:41 am »
Hi !
A dear forum member used to come up with an idea for spatial shading with _DEPTHBUFFER. He rewrote my code, did something after _MAPTRIANGLE 3d, and the display was more enjoyable. Unfortunately, I can't find this code in my backup, neither on google nor in my search engine here.
Does anyone remember this?

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: _DEPTHBUFFER
« Reply #1 on: December 12, 2020, 01:50:47 pm »
No mention of _DEPTHBUFFER but would this be of any use?...

Quote
Re: What is the best way to implement a depth buffer?

Quote
The deoth-buffer would  be tied to the entire frame...

Code: QB64: [Select]
  1. SUB PSET3D (X1 AS INTEGER, Y1 AS INTEGER, Z1 AS INTEGER, XANGLE AS INTEGER, YANGLE AS INTEGER, ZANGLE AS INTEGER, CLR AS INTEGER)
  2.  
  3. DIM AS INTEGER X, Y, Z
  4. X = X1: Y = Y1: Z = Z1
  5.  
  6. 'WE'LL INSERT OUR ROTATION CODE HERE:
  7. DIM AS INTEGER NEWX, NEWY, NEWZ, ROTX, ROTY, ROTZ
  8. 'ROTATION ON THE X-AXIS:
  9. NEWY = Y * COSTABLE(XANGLE) - Z * SINTABLE(XANGLE)
  10. NEWZ = Z * COSTABLE(XANGLE) + Y * SINTABLE(XANGLE)
  11.  
  12. Y = NEWY
  13. Z = NEWZ
  14.  
  15. 'ROTATION ON THE Y-AXIS:
  16. NEWZ = Z * COSTABLE(YANGLE) - X * SINTABLE(YANGLE)
  17. NEWX = X * COSTABLE(YANGLE) + Z * SINTABLE(YANGLE)
  18. X = NEWX
  19.  
  20. 'ROTATION ON THE Z-AXIS:
  21. NEWX = X * COSTABLE(ZANGLE) - Y * SINTABLE(ZANGLE)
  22. NEWY = Y * COSTABLE(ZANGLE) + X * SINTABLE(ZANGLE)
  23. ROTX = NEWX
  24. ROTY = NEWY
  25. ROTZ = NEWZ
  26.  
  27. DBUFFER(FOV * ROTX / (ROTZ + ZCENTER) + XCENTER, FOV * ROTY / (ROTZ + ZCENTER) + YCENTER).Z = Z
  28. DBUFFER(FOV * ROTX / (ROTZ + ZCENTER) + XCENTER, FOV * ROTY / (ROTZ + ZCENTER) + YCENTER).CLR = CLR
  29.  
  30. 'AND WE'LL CHANGE THE PSET3D ROUTINE TO USE THE ROTATED COORDS:
  31. PSET (FOV * ROTX / (ROTZ + ZCENTER) + XCENTER, FOV * ROTY / (ROTZ + ZCENTER) + YCENTER), CLR 'DIVIDE BOTH AXISES BY Z AND MOVE TO CENTER.
  32.  
  33. 'PIXEL (FOV * ROTX / (ROTZ + ZCENTER) + XCENTER, FOV * ROTY / (ROTZ + ZCENTER) + YCENTER), CLR 'DIVIDE BOTH AXISES BY Z AND MOVE
  34.  
  35. SUB glClear()
  36.  
  37. SUB glLoadIdentity()
  38.         XCENTER = 320
  39.         YCENTER = 240
  40.         ZCENTER = 256
  41.         FOV = 256
  42.  
  43. SUB glClearColor(Red AS SINGLE, Green AS SINGLE, Blue AS SINGLE, Alph AS SINGLE)
  44.         COLOR , RGBA(INT(Red * 255), INT(Green * 255), INT(Blue * 255), INT(Alph * 255))
  45.  



All of the above from "fatman2021"

(looks like some associated C code also)

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: _DEPTHBUFFER
« Reply #2 on: December 12, 2020, 02:27:32 pm »
thanks, no, that's not what I meant