I implemented a new class called "Sampler" which generates either random values, halton (2,3) values or sobol values and stores them before in an array before rendering. I tried every one and compared the results at 10 samples, and i am kind of disappointed by halton and sobol, they both look horrible, why is that?
![randomsampler.png](https://picload.org/image/ricgloaa/randomsampler.png)
![haltonsampler.png](https://picload.org/image/ricgloal/haltonsampler.png)
![sobolsampler.png](https://picload.org/image/ricglooa/sobolsampler.png)
This is my computeSamples(x,y)-function:
def computeSample(x,y):
samplePoint = sampler.getSamplePoint(x,y)
jitterX = samplePoint[0]
jitterY = samplePoint[1]
x += jitterX
y += jitterY
xdir = (x / width) * 2.0 - 1.0
ydir = ((y / height) * 2.0 - 1.0) * aspect
direction = Point3D(xdir,ydir,zdir).normalize()
ray = Ray(camera,direction)
return trace(ray,1)
And this is my "Sampler":
class Sampler:
def __init__(self,type,width,height):
self.type = type
self.width = width
self.height = height
self.samplePoints = []
self.counter = 0
for x in range(width):
for y in range(height):
if(self.type is SampleType.Random):
self.samplePoints.append([random(),random()])
elif(self.type is SampleType.Halton):
self.samplePoints.append([Halton(2,self.counter),Halton(3,self.counter)])
elif(self.type is SampleType.Sobol):
sobolValue = i4_sobol(2,self.counter)
self.samplePoints.append([sobolValue[0][0],sobolValue[0][1]])
elif(self.type is SampleType.NoneS):
self.samplePoints.append([0,0])
self.counter += 1
def getSamplePoint(self,x,y):
return self.samplePoints[x*self.height+y]