Skip to content

Commit

Permalink
Changed patch spec
Browse files Browse the repository at this point in the history
  • Loading branch information
DheerendraRathor committed Sep 21, 2017
1 parent b17219c commit 032a3c5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ This program takes a JSON specification of environment to be traced. Currently o
"Width": 400,
"Height": 200,
"Samples": 10,
"IMin": 0,
"IMax": 200,
"JMin": 0,
"JMax": 400
"Patch": [0, 200, 0, 400]
},
"Camera": {
"LookFrom": [-2, 1, 0.5],
Expand Down Expand Up @@ -98,24 +95,25 @@ This program takes a JSON specification of environment to be traced. Currently o
<td>Number of samples per pixel</td>
</tr>
<tr>
<td>IMin, IMax, JMin, JMax</td>
<td>integer</td>
<td>Defines specific patch of image to be rendered</td>
<td>Patch</td>
<td>list[int][4]</td>
<td>Defines specific patch of image to be rendered. Patch is defined as [x0, y0, x1, y1] and all points
(x, y) are considered given that x0 &le; x &lt; x1 and y0 &le; y &lt; y1 </td>
</tr>
<tr>
<td rowspan="7">Camera</td>
<td>LookFrom</td>
<td>list3</td>
<td>list[float][3]</td>
<td>Coordinates of camera lens</td>
</tr>
<tr>
<td>LookAt</td>
<td>list3</td>
<td>list[float][3]</td>
<td>Coordinate of point where camera is pointed.</td>
</tr>
<tr>
<td>UpVector</td>
<td>list3</td>
<td>list[float][3]</td>
<td>Point defining direction of up direction for camera</td>
</tr>
<tr>
Expand Down Expand Up @@ -147,7 +145,7 @@ This program takes a JSON specification of environment to be traced. Currently o
<tr>
<td rowspan=3>Sphere</td>
<td>Center</td>
<td>list3</td>
<td>list[float][3]</td>
<td>Center of sphere</td>
</tr>
<tr>
Expand All @@ -168,7 +166,7 @@ This program takes a JSON specification of environment to be traced. Currently o
</tr>
<tr>
<td>Albedo</td>
<td>list3</td>
<td>list[float][3]</td>
<td>Albedo of Material</td>
</tr>
<tr>
Expand All @@ -184,7 +182,7 @@ This program takes a JSON specification of environment to be traced. Currently o
</tbody>
</table>

**Note**: list3 => list of 3 float elements
**Note**: list[x][n] => list of elements of type x with size n

## Usages
```bash
Expand Down
5 changes: 1 addition & 4 deletions examples/fiveSpheres.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"Height": 400,
"Width": 800,
"Samples": 100,
"IMin": 0,
"IMax": 400,
"JMin": 0,
"JMax": 800
"Patch": [0, 400, 0, 800]
},
"Camera": {
"LookFrom": [-2, 1, 0.5],
Expand Down
9 changes: 5 additions & 4 deletions models/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ type ImageInput struct {
Height int
Width int
Samples int
IMin int
IMax int
JMin int
JMax int
Patch [4]int
}

func (i *ImageInput) GetPatch() (int, int, int, int) {
return i.Patch[0], i.Patch[1], i.Patch[2], i.Patch[3]
}

type CameraInput struct {
Expand Down
5 changes: 1 addition & 4 deletions sample_world.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"Width": 400,
"Height": 200,
"Samples": 10,
"IMin": 0,
"IMax": 200,
"JMin": 0,
"JMax": 400
"Patch": [0, 200, 0, 400]
},
"Camera": {
"LookFrom": [-2, 1, 0.5],
Expand Down
6 changes: 4 additions & 2 deletions tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ func GoTrace(env *models.World, progress chan<- bool) {
renderer := make(chan bool, renderRoutines)
defer close(renderer)

for i := env.Image.IMax - 1; i >= env.Image.IMin; i-- {
for j := env.Image.JMin; j < env.Image.JMax; j++ {
imin, imax, jmin, jmax := env.Image.GetPatch()

for i := imax - 1; i >= imin; i-- {
for j := jmin; j < jmax; j++ {
renderer <- true
renderWg.Add(1)
go func(i, j, samples int, camera *models.Camera, world *models.HitableList, pngImage *image.RGBA) {
Expand Down

0 comments on commit 032a3c5

Please sign in to comment.