Made a single hit cook torrence raytracer

A picture is worth a thousand words.
rouncer
Posts: 18
Joined: Wed Jun 19, 2013 11:04 am

Made a single hit cook torrence raytracer

Postby rouncer » Tue Feb 02, 2016 1:47 pm

Image


Getting organic surfaces with a cook torrence bounce... its on the books to add multibounce by recursing the procedure, but itll be alot slower.
Interesting things that make my framework different->

a) I render to a binary dithering map, and then i reduce it to the screens resolution.
b) I only use a low colour and a high colour, then the midrange develops as the dots join.
c) i then use add and multiply and clamp, segregated channels, to get my finished 'illumination'


my ior is 1.3 the consistency of cotton wool.

this lecture spills the beans on how to get these 'charactered' surfaces.
https://www.youtube.com/watch?v=Xi1FZZJ235I

note i dont understand the lecture that well, i just plug and played the code, its only 5 lines long :) blew my mind.


and the demo->
https://www.youtube.com/watch?v=eoFu_MNwoSg


my current weapon is a gtx980. 64x32 stream processors.

rouncer
Posts: 18
Joined: Wed Jun 19, 2013 11:04 am

Re: Made a single hit cook torrence raytracer

Postby rouncer » Thu Feb 04, 2016 6:33 am

Ill give myself a deadline for a miniature finished product on thursday, 11th feb, and ill give an executable, and the source for people to play with,
its very small, its one file only 711 lines so far, including all the comments and spaces and my newbie indents.

it has a fixed function material section that fits on the screen, its very simple.

The environment making process, is meshless volumetric functions, of course, i use a binary honing technique plus a feedback system to keep the occlusions when it finds them.
But it needs alot of improvement if i want to see volume functions in general. (which mathematicians would love. especially when they are all furry lookin hehe)

The scripter system will use fxc.exe as a commandline system call. from the program, which it communicates to, to update the scene. which actually has to recompile the entire
kernel to fit the new level in, because its a function call from the binary honing kernel, and it does take about 5 seconds to compile on my computer, because direct compute is a slow girly compiler, but its suited me, I cant be bothered learning cuda optimizations, im not so lowlevel with conventional hardware. (but i have crazy hardware ideas of my own regularly as well.)

The crazy stuff you see in the demo, are all little stretch variations of a common theme, some glitched bilinear filtering (which must be coded in yourself! or you can just borrow mine.)
and waves of harmonics on top of this.



//geometry function->

Code: Select all



//this has the bilinear filter in it.
int compute_altitude( int walkpos_x, int walkpos_z, int rpy)
{   
 int alt=-rpy-22100;
 int k;
 int adx,ady;
 int idx,idy;
 int w0,w1;

 int h=96;
 
 for(k=0;k<h;k+=16)
 {
  idx=((((walkpos_x+(alt>>2))/(k+1)))<<0)%(ipad1<<8);
  idy=(((walkpos_z/(k+1)))<<0)%(ipad1<<8);
 
  adx=idx>>8;
  ady=idy>>8;

  idx-=adx<<8;
  idy-=ady<<8;

  int nhh[4];
  int nhv[4];

  int k2=k;
  if(k2>3) k2=0;
 
  #define HG >>8)*(k+1))
  #define NM  3


  nhh[0]=abs(((Bufferui4[(adx)+((ady)<<NM)].amp)HG; 
 
  nhv[0]=abs(((Bufferui4[(adx)+((ady)<<NM)].amp)HG; 
  if(adx==ipad1-1)
  {
   nhh[1]=abs(((Bufferui4[(0)+((ady)<<NM)].amp)HG; 
   nhv[2]=abs(((Bufferui4[(0)+((ady)<<NM)].amp)HG; 
   if(ady==ipad1-1)
   {
    nhv[1]=abs(((Bufferui4[(adx)+((0)<<NM)].amp)HG; 
    nhh[2]=abs(((Bufferui4[(0)+((0)<<NM)].amp)HG; 
    nhh[3]=abs(((Bufferui4[(0)+((0)<<NM)].amp)HG; 
    nhv[3]=abs(((Bufferui4[(0)+((0)<<NM)].amp)HG; 
   }
   else
   {
    nhv[1]=abs(((Bufferui4[(adx)+((ady+1)<<NM)].amp)HG; 
    nhh[2]=abs(((Bufferui4[(0)+((ady+1)<<NM)].amp)HG; 
    nhh[3]=abs(((Bufferui4[(0)+((ady+1)<<NM)].amp)HG; 
    nhv[3]=abs(((Bufferui4[(0)+((ady+1)<<NM)].amp)HG; 
   }
  }
  else
  {
   nhh[1]=abs(((Bufferui4[(adx+1)+((ady)<<NM)].amp)HG; 
   nhv[2]=abs(((Bufferui4[(adx+1)+((ady)<<NM)].amp)HG; 
   if(ady==ipad1-1)
   {
    nhv[1]=abs(((Bufferui4[(adx)+((0)<<NM)].amp)HG; 
    nhh[2]=abs(((Bufferui4[(adx+1)+((0)<<NM)].amp)HG; 
    nhh[3]=abs(((Bufferui4[(adx+1)+((0)<<NM)].amp)HG; 
    nhv[3]=abs(((Bufferui4[(adx+1)+((0)<<NM)].amp)HG; 
   }
   else
   {
    nhv[1]=abs(((Bufferui4[(adx)+((ady+1)<<NM)].amp)HG; 
    nhh[2]=abs(((Bufferui4[(adx+1)+((ady+1)<<NM)].amp)HG; 
    nhh[3]=abs(((Bufferui4[(adx+1)+((ady+1)<<NM)].amp)HG; 
    nhv[3]=abs(((Bufferui4[(adx+1)+((ady+1)<<NM)].amp)HG; 
   }
  }
                 
 
 
  w0=idx;
  w1=idy;
 
  if(w0>1<<8 || w0<0
  || w1>1<<8 || w1<0)
  {
   int bp=1;
  }

 
  //bilinear average->
  int ad1=(((((nhh[0]*(255-w0))+(nhh[1]*(w0)))/255*(255-w1)))
          +((((nhh[2]*(255-w0))+(nhh[3]*(w0)))/255*(w1))))/255;
  int ad2=(((((nhv[0]*(255-w0))+(nhv[1]*(w0)))/255*(255-w0)))
          +((((nhv[2]*(255-w0))+(nhv[3]*(w0)))/255*(w0))))/255;

  int ad3=(ad1+ad2)/2;

  alt+=ad3;
 }
 
 return alt;
}





material bar done. i just have a few things to fix then the demo will go here.
I worked out how to get the powderyish surface, and its roughness as close as possible to 0, and gauss as high as you can get it, and you get the fat material.



heres a little microworld thing i did with it, with silver snail trails ->
https://www.youtube.com/watch?v=xHfX3ypSQJY


Return to “Visuals”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest