Author Topic: source  (Read 3924 times)

Koroljov

  • Guest
source
« on: August 09, 2003, 04:56:44 pm »
Can we not read the source of jPCT? I am trying to write a 3d engine in jave for years, I have been able to create something, but it still doesn't work good.

koroljov

  • Guest
source
« Reply #1 on: August 09, 2003, 04:59:57 pm »
No it really doesn't matter that the source isn't up to date or that it's a real mess. I can read any code in 21 programmer languages, I just want to know how it works. (I'll decompile it anyway, but that is very difficult).

koroljov

  • Guest
source
« Reply #2 on: August 09, 2003, 05:04:54 pm »
I just read decompilation is not allowed. Sorry i won't decompile it.

koroljov

  • Guest
source
« Reply #3 on: August 09, 2003, 05:10:44 pm »
Can't you tell some names of the used algorithms so I can seek them on the internet? How can it work so quick in full screen? How many divisions are there in the inner loop of the application? How is it clipped? How can you make a color lighter or darker? Do you really have to get the r g b -values, edit them and put them in 1 int again with lots of << and >> operators?

Online EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
source
« Reply #4 on: August 17, 2003, 12:55:43 pm »
Quote from: "koroljov"
Can't you tell some names of the used algorithms so I can seek them on the internet? How can it work so quick in full screen? How many divisions are there in the inner loop of the application? How is it clipped? How can you make a color lighter or darker? Do you really have to get the r g b -values, edit them and put them in 1 int again with lots of << and >> operators?
Sorry for the late reply, but i was on a trip to sweden for two weeks. The inner loop for a point-sampled pixel looks like this

Code: [Select]
for (int tx=x+yPos; tx<=end; tx++) {

   if (zbuffer[tx]>iz) {
      col=texels[((((t1&texClampU)>>18)+(((t2&texClampV)>>18)<<shift)))];

      r=(((col>>16))*(srI>>10))>>16;
      g=(((col>>8)&255)*(sgI>>10))>>16;
      b=((col&255)*(sbI>>10))>>16;

      if ((r&0xffffff00)!=0) { r=(255>>(byte) (r>>28&8)); }
      if ((g&0xffffff00)!=0) { g=(255>>(byte) (g>>28&8)); }
      if ((b&0xffffff00)!=0) { b=(255>>(byte) (b>>28&8)); }
   
      pixels[tx]=b|(g<<8)|(r<<16);
      zbuffer[tx]=iz;
   }

   t1+=dus;
   t2+=dvs;

   srI+=delr;
   sgI+=delg;
   sbI+=delb;

   iz+=delz;
}


In the inner loop, the subspans are linear interpolated, so no division is needed here. In the loop that does the subdivision, no division is needed too because it has all been replaced by multiplying with 1/(whatever).
I don't know where to look on the net for a better description, because it's simply the way i'm doing these things for ages now.
Please note that this is the inner loop of the SoftGL-Renderer which requires some multiplications and supports texture-wrapping from version 0.92 (to be released...) on, so it's a bit slower than the Legacy-Renderer, but not much.

Koroljov

  • Guest
source
« Reply #5 on: August 19, 2003, 09:00:24 pm »
Vielen Dank.

It is very interesting. It is much faster than using
u =  (i*(Vz*Oy-Vy*Oz) + j*(Vx*Oz-Vz*Ox)+(Vy*Ox-Vx*Oy))/(i*(Vy*Uz-Vz*Uy)+j*(Vz*Ux-Vx*Uz) + (Vx*Uy-Vy*Ux))
and
v = ( i*(Uy*Oz-Uz*Oy) + j*(Uz*Ox-Ux*Oz) + (Ux*Oy-Uy*Ox))/( i*(Vy*Uz-Vz*Uy) + j*(Vz*Ux-Vx*Uz) + (Vx*Uy-Vy*Ux))

Online EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
source
« Reply #6 on: August 19, 2003, 11:51:42 pm »
Quote from: "Koroljov"
It is very interesting. It is much faster than using
u =  (i*(Vz*Oy-Vy*Oz) + j*(Vx*Oz-Vz*Ox)+(Vy*Ox-Vx*Oy))/(i*(Vy*Uz-Vz*Uy)+j*(Vz*Ux-Vx*Uz) + (Vx*Uy-Vy*Ux))
and
v = ( i*(Uy*Oz-Uz*Oy) + j*(Uz*Ox-Ux*Oz) + (Ux*Oy-Uy*Ox))/( i*(Vy*Uz-Vz*Uy) + j*(Vz*Ux-Vx*Uz) + (Vx*Uy-Vy*Ux))
Obviously... :wink: