Skip to content

Commit

Permalink
Rotate medium randomly for every ray, hoping it will remove artefacts
Browse files Browse the repository at this point in the history
  • Loading branch information
dronir committed Jun 12, 2014
1 parent bd24db3 commit 727d72c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/programs/visual/hemiScatter.f90
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ subroutine sampleHemisphere(f, nSamples, Pf, Pp)
real(fd), dimension(2,nSamples) :: samples
real(fd), dimension(3) :: pSurface(3)
real(fd), dimension(3) :: D
real(fd) :: dz, thetaIn, thetaInOffset
real(fd) :: dz, thetaIn, thetaInOffset, phiOffset, x, y
integer :: i, j, k, iTheta
logical :: pFound, pLit

Expand All @@ -289,6 +289,7 @@ subroutine sampleHemisphere(f, nSamples, Pf, Pp)
pSurface(3) = M%hMean

D = 0.0_fd
PhiOffset = 0.0_fd

call ray_init(rC, RAY_TYPE_CAMERA)

Expand All @@ -302,7 +303,9 @@ subroutine sampleHemisphere(f, nSamples, Pf, Pp)
!!
pSurface(1:2) = samples(:,i)
call RANDOM_NUMBER(tstRnd)
call RANDOM_NUMBER(phiOffset)
thetaInOffset = dTheta*tstRnd
phiOffset = phiOffset * TWO_PI

pFound = .false.
do while (.not. pFound)
Expand All @@ -316,6 +319,12 @@ subroutine sampleHemisphere(f, nSamples, Pf, Pp)
if(tstRnd > 0.5) rC%D(2) = -rC%D(2)
end if

! Rotate ray here
x = rC%D(1)
y = rC%D(2)
rC%D(1) = x*cos(phiOffset) - y*sin(phiOffset)
rC%D(2) = x*sin(phiOffset) + y*cos(phiOffset)

if(rC%D(3) < 1e-2_fd) then
rC%D(3) = 1e-2
call vec_normalize(rC%D)
Expand Down Expand Up @@ -343,7 +352,8 @@ subroutine sampleHemisphere(f, nSamples, Pf, Pp)
if(pFound) then
do iTheta = 1, resTheta
thetaIn = (iTheta-1)*dTheta + thetaInOffset
D(1) = sin(thetaIn)
D(1) = sin(thetaIn)*cos(phiOffset)
D(2) = sin(thetaIn)*sin(phiOffset)
D(3) = cos(thetaIn)
call trc_gatherRadiance(M%grid, rC%D, D, iSect%P1 + TRACE_EPS * iSect%N, &
& iSect%N, 1.0_fd / real(nSamplesPerOrderTable(1), fd), &
Expand Down

0 comments on commit 727d72c

Please sign in to comment.