void trace(){
  glUseProgram(computeProgram);
  invProjMatrix.transformProject(tmpVector.set(-1,-1,0));
  glUniform3f(ray00Uniform,tmpVector.x,tmpVector.y,tmpVector.z);
  invProjMatrix.transformProject(tmpVector.set(-1,1,0));
  glUniform3f(ray01Uniform,tmpVector.x,tmpVector.y,tmpVector.z);
  invProjMatrix.transformProject(tmpVector.set(1,-1,0));
  glUniform3f(ray10Uniform,tmpVector.x,tmpVector.y,tmpVector.z);
  invProjMatrix.transformProject(tmpVector.set(1,1,0));
  glUniform3f(ray11Uniform,tmpVector.x,tmpVector.y,tmpVector.z);
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER,trianglesSsboBinding,ssbo);
  glBindImageTexture(framebufferImageBinding,raytraceTexture,0,false,0,GL_WRITE_ONLY,GL_RGBA8);
  int worksizeX=mathRoundPoT(width);
  int worksizeY=mathRoundPoT(height);
  glDispatchCompute(worksizeX / workGroupSizeX,worksizeY / workGroupSizeY,1);
  glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
  glBindImageTexture(framebufferImageBinding,0,0,false,0,GL_WRITE_ONLY,GL_RGBA8);
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER,trianglesSsboBinding,0);
  glUseProgram(0);
}

void trace ( ) { glUseProgram ( computeProgram ) ; invProjMatrix . transformProject ( tmpVector . set ( - 1 , - 1 , 0 ) ) ; glUniform3f ( ray00Uniform , tmpVector . x , tmpVector . y , tmpVector . z ) ; invProjMatrix . transformProject ( tmpVector . set ( - 1 , 1 , 0 ) ) ; glUniform3f ( ray01Uniform , tmpVector . x , tmpVector . y , tmpVector . z ) ; invProjMatrix . transformProject ( tmpVector . set ( 1 , - 1 , 0 ) ) ; glUniform3f ( ray10Uniform , tmpVector . x , tmpVector . y , tmpVector . z ) ; invProjMatrix . transformProject ( tmpVector . set ( 1 , 1 , 0 ) ) ; glUniform3f ( ray11Uniform , tmpVector . x , tmpVector . y , tmpVector . z ) ; glBindBufferBase ( GL_SHADER_STORAGE_BUFFER , trianglesSsboBinding , ssbo ) ; glBindImageTexture ( framebufferImageBinding , raytraceTexture , 0 , false , 0 , GL_WRITE_ONLY , GL_RGBA8 ) ; int worksizeX = mathRoundPoT ( width ) ; int worksizeY = mathRoundPoT ( height ) ; glDispatchCompute ( worksizeX / workGroupSizeX , worksizeY / workGroupSizeY , 1 ) ; glMemoryBarrier ( GL_SHADER_IMAGE_ACCESS_BARRIER_BIT ) ; glBindImageTexture ( framebufferImageBinding , 0 , 0 , false , 0 , GL_WRITE_ONLY , GL_RGBA8 ) ; glBindBufferBase ( GL_SHADER_STORAGE_BUFFER , trianglesSsboBinding , 0 ) ; glUseProgram ( 0 ) ; }
compute one frame by tracing the scene using our compute shader .
