private void trace(){
  glUseProgram(computeProgram);
  long thisTime=System.nanoTime();
  float elapsedSeconds=(thisTime - firstTime) / 1E9f;
  glUniform1f(timeUniform,elapsedSeconds);
  float blendFactor=frameNumber / (frameNumber + 1.0f);
  glUniform1f(blendFactorUniform,blendFactor);
  glUniform1f(lightRadiusUniform,lightRadius * 0.1f);
  glBindImageTexture(framebufferImageBinding,raytraceTexture,0,false,0,GL_READ_WRITE,GL_RGBA32F);
  glBindImageTexture(worldPositionImageBinding,positionTexture,0,false,0,GL_READ_ONLY,GL_RGBA32F);
  glBindImageTexture(worldNormalImageBinding,normalTexture,0,false,0,GL_READ_ONLY,GL_RGBA16F);
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER,objectsSsboBinding,objectsSsbo);
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER,trianglesSsboBinding,trianglesSsbo);
  int worksizeX=mathRoundPoT(width);
  int worksizeY=mathRoundPoT(height);
  glDispatchCompute(worksizeX / workGroupSizeX,worksizeY / workGroupSizeY,1);
  glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER,trianglesSsboBinding,0);
  glBindBufferBase(GL_SHADER_STORAGE_BUFFER,objectsSsboBinding,0);
  glBindImageTexture(framebufferImageBinding,0,0,false,0,GL_READ_WRITE,GL_RGBA32F);
  glBindImageTexture(worldPositionImageBinding,0,0,false,0,GL_READ_ONLY,GL_RGBA32F);
  glBindImageTexture(worldNormalImageBinding,0,0,false,0,GL_READ_ONLY,GL_RGBA16F);
  glUseProgram(0);
  frameNumber++;
}

private void trace ( ) { glUseProgram ( computeProgram ) ; long thisTime = System . nanoTime ( ) ; float elapsedSeconds = ( thisTime - firstTime ) / 1E9f ; glUniform1f ( timeUniform , elapsedSeconds ) ; float blendFactor = frameNumber / ( frameNumber + 1.0f ) ; glUniform1f ( blendFactorUniform , blendFactor ) ; glUniform1f ( lightRadiusUniform , lightRadius * 0.1f ) ; glBindImageTexture ( framebufferImageBinding , raytraceTexture , 0 , false , 0 , GL_READ_WRITE , GL_RGBA32F ) ; glBindImageTexture ( worldPositionImageBinding , positionTexture , 0 , false , 0 , GL_READ_ONLY , GL_RGBA32F ) ; glBindImageTexture ( worldNormalImageBinding , normalTexture , 0 , false , 0 , GL_READ_ONLY , GL_RGBA16F ) ; glBindBufferBase ( GL_SHADER_STORAGE_BUFFER , objectsSsboBinding , objectsSsbo ) ; glBindBufferBase ( GL_SHADER_STORAGE_BUFFER , trianglesSsboBinding , trianglesSsbo ) ; int worksizeX = mathRoundPoT ( width ) ; int worksizeY = mathRoundPoT ( height ) ; glDispatchCompute ( worksizeX / workGroupSizeX , worksizeY / workGroupSizeY , 1 ) ; glMemoryBarrier ( GL_SHADER_IMAGE_ACCESS_BARRIER_BIT ) ; glBindBufferBase ( GL_SHADER_STORAGE_BUFFER , trianglesSsboBinding , 0 ) ; glBindBufferBase ( GL_SHADER_STORAGE_BUFFER , objectsSsboBinding , 0 ) ; glBindImageTexture ( framebufferImageBinding , 0 , 0 , false , 0 , GL_READ_WRITE , GL_RGBA32F ) ; glBindImageTexture ( worldPositionImageBinding , 0 , 0 , false , 0 , GL_READ_ONLY , GL_RGBA32F ) ; glBindImageTexture ( worldNormalImageBinding , 0 , 0 , false , 0 , GL_READ_ONLY , GL_RGBA16F ) ; glUseProgram ( 0 ) ; frameNumber ++ ; }
compute one frame by tracing the scene using our compute shader .
