• Hey Guest,

    As you know, censorship around the world has been ramping up at an alarming pace. The UK and OFCOM has singled out this community and have been focusing its censorship efforts here. It takes a good amount of resources to maintain the infrastructure for our community and to resist this censorship. We would appreciate any and all donations.

    Bitcoin Address (BTC): 39deg9i6Zp1GdrwyKkqZU6rAbsEspvLBJt

    Ethereum (ETH): 0xd799aF8E2e5cEd14cdb344e6D6A9f18011B79BE9

    Monero (XMR): 49tuJbzxwVPUhhDjzz6H222Kh8baKe6rDEsXgE617DVSDD8UKNaXvKNU8dEVRTAFH9Av8gKkn4jDzVGF25snJgNfUfKKNC8

Darkover

Darkover

Angelic
Jul 29, 2021
4,808
Light and depth
3d byte array to 2d render
z axis depth determines brightness of red
32*32*32 =32 768 bytes
Screen render 32 by 32 width and height
create sphere fills the 3d array with a sphere shape

Spot Light diffuse lighting using dot product

A8qy92E
C:
constant byte_width =640,byte_height=480, byte_depth=64
 
sequence byte_array
byte_array={}
--x,y,z
 
function distance3d(integer x1, integer y1, integer z1, integer x2, integer y2, integer z2)
 integer x3,y3,z3
 x3 = power(x1 - x2, 2)
 y3 = power(y1 - y2, 2)
 z3 = power(z1 - z2, 2)
 
 return sqrt(x3 + y3 + z3 )
end function
 
 
for i=1 to byte_depth do
  byte_array=append(byte_array, repeat(repeat(0,byte_width),byte_height) )
end for
 
for z=1 to byte_depth do
--byte_array=append(byte_array,{})
for y=1 to byte_height do
  for x=1 to byte_width do
 
  end for
end for
end for
 
 
procedure sphere(integer center_x, integer center_y, integer center_z, integer dist, atom colour)
atom dd
 
  for x=1 to byte_width do
    for y=1 to byte_height do
      for z=1 to byte_depth do
        dd=distance3d(x,y,z ,center_x,center_y,center_z)
        if dd<dist then
          byte_array[z][x][y]=colour
        end if
      end for
    end for
  end for
end procedure
 
procedure cube(integer start_x, integer start_y, integer start_z, integer size, atom colour)
 
  for x=start_x to start_x+size do
    for y=start_y to start_y+size do
      for z=start_z to start_z+size do
          byte_array[z][x][y]=colour
      end for
    end for
  end for
end procedure
 
 sphere(320,240,24, 24, rgb(255,0,0))
 
sphere(320,340,32, 32, rgb(255,255,0))
 
sphere(120,140,16, 16, rgb(255,0,255))
 
sphere(32,32,32, 32, rgb(0,255,0))
 
sphere(280,180,32, 32, rgb(0,0,255))
 
cube(320,240,1, 32 , rgb(0,0,255) )
 
 
function rgbs(atom rgb)
    return ( {and_bits(#000000FF, rgb),
              and_bits(#0000FF00, rgb) / #100,
              and_bits(#00FF0000, rgb) / #10000 } )
end function
 
sequence screen_pixels
screen_pixels=repeat(repeat({0,0,0},byte_width),byte_height)
 
integer light_x,light_y,light_z
integer light2_x,light2_y,light2_z
light_x=320
light_y=240
light_z=-32
 
light2_y=320
light2_x=300
 
light2_z=-32
 
integer surface_x,surface_y,surface_z
atom length1
surface_x=0
surface_y=0
surface_z=-1
 
length1=sqrt(0 + 0 + surface_z*surface_z )
surface_x=surface_x/length1
surface_y=surface_y/length1
surface_z=surface_z/length1
 
sequence dib,temp
dib = newDib(byte_width, byte_height)
 
atom lightness,lightness2,vx,vy,vz,ttt
ttt=time()
 
sequence active_pixels
active_pixels={}
 
  for x=1 to byte_width-1 do
    for y=1 to byte_height-1 do
       for z=1 to byte_depth do
    
         if byte_array[z][y][x]!=0 then
           active_pixels=append(active_pixels,{x,y,z})
           vx= light_x-x
           vy= light_y-y
           vz= light_z-z
 
           length1=sqrt(vx*vx + vy*vy + vz*vz )
 
           if length1!=0 then
             vx= vx/length1
             vy= vy/length1
             vz= vz/length1
             lightness=(vx*surface_x) + (vy*surface_y) + (vz*surface_z)
           end if
 
 
 
           --screen_pixels[x][y]={255 * ((1/byte_depth)* (byte_depth-z)) ,0,0}
           --screen_pixels[x][y]={255 *lightness ,0,0}
           temp=rgbs(byte_array[z][y][x])
    
        
        
        
           temp*=lightness
        
           screen_pixels[x][y]=temp--rgbs(byte_array[z][y][x]*lightness)
 
           fastPutDibPixel( dib, y,  x,  screen_pixels[x][y] )
 
           exit
         end if
       end for
    end for
  end for
 
 
procedure render_update()
integer x,y,z
    for i=1 to length(active_pixels) do
      x=active_pixels[i][1]
      y=active_pixels[i][2]
      z=active_pixels[i][3]
    
           vx= light_x-x
           vy= light_y-y
           vz= light_z+z
 
           lightness=0
           lightness2=0
 
           length1=sqrt(vx*vx + vy*vy + vz*vz )
 
           if length1!=0 then
             vx= vx/length1
             vy= vy/length1
             vz= vz/length1
             lightness=(vx*surface_x) + (vy*surface_y) + (vz*surface_z)
           end if
 
           vx= light2_x-x
           vy= light2_y-y
           vz= light2_z-z
 
           length1=sqrt(vx*vx + vy*vy + vz*vz )
 
           if length1!=0 then
             vx= vx/length1
             vy= vy/length1
             vz= vz/length1
             lightness2=(vx*surface_x) + (vy*surface_y) + (vz*surface_z)
           end if
 
           --screen_pixels[x][y]={255 * ((1/byte_depth)* (byte_depth-z)) ,0,0}
           --screen_pixels[x][y]={255 *lightness ,0,0}
           temp=rgbs(byte_array[z][y][x])
        
           ttt=lightness+lightness2
           if ttt>1 then
            ttt=1
           end if
           temp*=ttt
        
           screen_pixels[x][y]=temp--rgbs(byte_array[z][y][x]*lightness)
 
           fastPutDibPixel( dib, y,  x,  screen_pixels[x][y] )
 
    
    end for
    
 
end procedure
 
setTimer(Window1,1000,100)
 

Attachments

  • o8grKqR.jpg
    o8grKqR.jpg
    94.2 KB · Views: 0
  • nnutdkZ.jpg
    nnutdkZ.jpg
    10.5 KB · Views: 0
  • cgYiedL.jpg
    cgYiedL.jpg
    11 KB · Views: 0
  • aR8VDeK.jpg
    aR8VDeK.jpg
    9.9 KB · Views: 0
  • ibt3DRo.jpg
    ibt3DRo.jpg
    100.6 KB · Views: 0
  • Like
Reactions: Sprite_Geist, doormat25, Suicidebydeath and 2 others
O

oddetoad

Arcanist
Nov 25, 2023
496
 
  • Yay!
  • Like
Reactions: doormat25, http-410 and Darkover
S

somenone

He is not even capable of committing suicide
Aug 19, 2023
47
Shouldn't the angle of incidence of the beam (from the camera) be equal to the angle of reflection (from the sphere)? I didn't delve into the formulas, since I'm too stupid for this, but the captions in the picture confused me.
 

Similar threads

Darkover
Replies
2
Views
167
Offtopic
Darkover
Darkover
Darkover
Replies
1
Views
222
Offtopic
Forever Sleep
F
Darkover
Replies
0
Views
304
Offtopic
Darkover
Darkover
Darkover
Replies
3
Views
399
Offtopic
jodes2
jodes2