joonsrenderer 1.1-java → 1.3.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +117 -0
- data/.mvn/wrapper/maven-wrapper.properties +2 -0
- data/CHANGELOG.md +12 -1
- data/README.md +1 -1
- data/Rakefile +6 -1
- data/docs/Gemfile +2 -0
- data/docs/_config.yml +3 -0
- data/docs/_includes/header.html +1 -1
- data/docs/_includes/top.html +11 -0
- data/docs/_layouts/default.html +6 -15
- data/docs/_posts/2017-01-06-media.md +101 -0
- data/docs/_posts/2017-01-08-animated_ray_tracing.md +2 -2
- data/docs/_posts/2017-01-08-resources.md +14 -0
- data/docs/about.md +2 -2
- data/docs/assets/media_captured.png +0 -0
- data/docs/assets/media_rendered.png +0 -0
- data/joonsrenderer.gemspec +2 -2
- data/lib/commons.compiler/module-info.class +0 -0
- data/lib/commons.compiler/module-info.java +7 -0
- data/lib/janino/module-info.class +0 -0
- data/lib/janino/module-info.java +5 -0
- data/lib/joonsrenderer/version.rb +1 -1
- data/mvnw +310 -0
- data/mvnw.cmd +182 -0
- data/pom.rb +22 -22
- data/pom.xml +32 -17
- data/src/{test/java/a_maintest.java → a_maintest.java} +1 -1
- data/src/main/java/SunflowGUI.java +295 -351
- data/src/main/java/joons/JRFiller.java +15 -23
- data/src/main/java/joons/JoonsRenderer.java +6 -5
- data/src/main/java/org/sunflow/AsciiFileSunflowAPI.java +1 -1
- data/src/main/java/org/sunflow/BinaryFileSunflowAPI.java +1 -1
- data/src/main/java/org/sunflow/SunflowAPI.java +5 -5
- data/src/main/java/org/sunflow/core/GIEngine.java +3 -1
- data/src/main/java/org/sunflow/core/Geometry.java +1 -1
- data/src/main/java/org/sunflow/core/ImageSampler.java +3 -0
- data/src/main/java/org/sunflow/core/InstanceList.java +1 -1
- data/src/main/java/org/sunflow/core/IntersectionState.java +7 -6
- data/src/main/java/org/sunflow/core/ParameterList.java +3 -2
- data/src/main/java/org/sunflow/core/PhotonStore.java +1 -0
- data/src/main/java/org/sunflow/core/Ray.java +4 -3
- data/src/main/java/org/sunflow/core/TextureCache.java +1 -1
- data/src/main/java/org/sunflow/core/accel/BoundingIntervalHierarchy.java +1 -1
- data/src/main/java/org/sunflow/core/accel/KDTree.java +1 -1
- data/src/main/java/org/sunflow/core/photonmap/CausticPhotonMap.java +2 -2
- data/src/main/java/org/sunflow/core/photonmap/GlobalPhotonMap.java +2 -2
- data/src/main/java/org/sunflow/core/renderer/BucketRenderer.java +3 -1
- data/src/main/java/org/sunflow/image/writers/EXRBitmapWriter.java +28 -19
- data/src/main/java/org/sunflow/image/writers/PNGBitmapWriter.java +5 -0
- data/src/main/java/org/sunflow/image/writers/TGABitmapWriter.java +20 -14
- data/src/main/java/org/sunflow/system/BenchmarkFramework.java +2 -2
- data/src/main/java/org/sunflow/system/RenderGlobalsPanel.java +5 -4
- metadata +20 -8
- data/docs/_includes/head.html +0 -15
@@ -1,24 +1,24 @@
|
|
1
1
|
package joons;
|
2
2
|
|
3
|
-
import
|
4
|
-
import
|
3
|
+
import org.sunflow.util.FloatArray;
|
4
|
+
import org.sunflow.util.IntArray;
|
5
5
|
|
6
6
|
public class JRFiller {
|
7
7
|
|
8
|
-
private final
|
9
|
-
private final
|
10
|
-
private final
|
11
|
-
private final
|
8
|
+
private final FloatArray vertices;
|
9
|
+
private final IntArray triangleIndices;
|
10
|
+
private final FloatArray spheres;
|
11
|
+
private final FloatArray points;
|
12
12
|
|
13
13
|
private final String fillType;
|
14
14
|
public float[] p; //array of parameters
|
15
15
|
public int np = 0; //number of parameters
|
16
16
|
|
17
17
|
public JRFiller(String fillType, float... params) {
|
18
|
-
vertices = new
|
19
|
-
triangleIndices = new
|
20
|
-
spheres = new
|
21
|
-
points = new
|
18
|
+
vertices = new FloatArray();
|
19
|
+
triangleIndices = new IntArray();
|
20
|
+
spheres = new FloatArray();
|
21
|
+
points = new FloatArray();
|
22
22
|
|
23
23
|
this.fillType = fillType;
|
24
24
|
p = params;
|
@@ -29,12 +29,12 @@ public class JRFiller {
|
|
29
29
|
return fillType;
|
30
30
|
}
|
31
31
|
|
32
|
-
public
|
32
|
+
public FloatArray getVertices() {
|
33
33
|
return vertices;
|
34
34
|
}
|
35
35
|
|
36
36
|
private void writeTriangleIndices() {
|
37
|
-
for (int i = 0; i < (vertices.
|
37
|
+
for (int i = 0; i < (vertices.getSize() / 9); i++) {
|
38
38
|
//vertices/3 = number of 3d points
|
39
39
|
//vertices/9 = number of triangles
|
40
40
|
triangleIndices.add(i * 3);
|
@@ -44,20 +44,12 @@ public class JRFiller {
|
|
44
44
|
}
|
45
45
|
|
46
46
|
public float[] verticesToArray() {
|
47
|
-
|
48
|
-
for (int i = 0; i < vertices.size(); i++) {
|
49
|
-
v[i] = vertices.get(i);
|
50
|
-
}
|
51
|
-
return v;
|
47
|
+
return vertices.trim();
|
52
48
|
}
|
53
49
|
|
54
50
|
public int[] triangleIndicesToArray() {
|
55
51
|
writeTriangleIndices();
|
56
|
-
|
57
|
-
for (int i = 0; i < triangleIndices.size(); i++) {
|
58
|
-
t[i] = triangleIndices.get(i);
|
59
|
-
}
|
60
|
-
return t;
|
52
|
+
return triangleIndices.trim();
|
61
53
|
}
|
62
54
|
|
63
55
|
public void addSphere(float x, float y, float z, float r) {
|
@@ -67,7 +59,7 @@ public class JRFiller {
|
|
67
59
|
spheres.add(r);
|
68
60
|
}
|
69
61
|
|
70
|
-
public
|
62
|
+
public FloatArray getSpheres() {
|
71
63
|
return spheres;
|
72
64
|
}
|
73
65
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
package joons;
|
2
2
|
|
3
|
-
import
|
3
|
+
import org.sunflow.util.FloatArray;
|
4
4
|
|
5
5
|
import org.sunflow.SunflowAPI;
|
6
6
|
import org.sunflow.math.Matrix4;
|
@@ -210,6 +210,7 @@ public class JoonsRenderer {
|
|
210
210
|
case(AMBIENT_OCCLUSION):
|
211
211
|
case(LIGHT):
|
212
212
|
case(MIRROR):
|
213
|
+
case(GLASS):
|
213
214
|
fillers.add(new JRFiller(type, params));
|
214
215
|
break;
|
215
216
|
default:
|
@@ -661,8 +662,8 @@ public class JoonsRenderer {
|
|
661
662
|
}
|
662
663
|
|
663
664
|
//light spheres
|
664
|
-
|
665
|
-
int noOfSpheres = (int) spheres.
|
665
|
+
FloatArray spheres = temp.getSpheres();
|
666
|
+
int noOfSpheres = (int) spheres.getSize() / 4;
|
666
667
|
|
667
668
|
for (int j = 0; j < noOfSpheres; j++) {
|
668
669
|
float x = spheres.get(j * 4);
|
@@ -801,8 +802,8 @@ public class JoonsRenderer {
|
|
801
802
|
api.instance("Object_" + i + ".instance", "Object_" + i);
|
802
803
|
|
803
804
|
//render the respective spheres
|
804
|
-
|
805
|
-
int noOfSpheres = spheres.
|
805
|
+
FloatArray spheres = temp.getSpheres();
|
806
|
+
int noOfSpheres = spheres.getSize() / 4;
|
806
807
|
|
807
808
|
for (int j = 0; j < noOfSpheres; j++) {
|
808
809
|
float x = spheres.get(j * 4);
|
@@ -12,7 +12,7 @@ import org.sunflow.math.Matrix4;
|
|
12
12
|
|
13
13
|
class AsciiFileSunflowAPI extends FileSunflowAPI {
|
14
14
|
|
15
|
-
private OutputStream stream;
|
15
|
+
private final OutputStream stream;
|
16
16
|
|
17
17
|
AsciiFileSunflowAPI(String filename) throws IOException {
|
18
18
|
stream = new BufferedOutputStream(new FileOutputStream(filename));
|
@@ -12,7 +12,7 @@ import org.sunflow.math.Matrix4;
|
|
12
12
|
|
13
13
|
class BinaryFileSunflowAPI extends FileSunflowAPI {
|
14
14
|
|
15
|
-
private DataOutputStream stream;
|
15
|
+
private final DataOutputStream stream;
|
16
16
|
|
17
17
|
BinaryFileSunflowAPI(String filename) throws FileNotFoundException {
|
18
18
|
stream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename)));
|
@@ -68,9 +68,9 @@ public class SunflowAPI implements SunflowAPIInterface {
|
|
68
68
|
UI.printError(Module.API, "JVM available memory is below %d MB (found %d MB only).\nPlease make sure you launched the program with the -Xmx command line options.", RECOMMENDED_MAX_SIZE, maxMb);
|
69
69
|
}
|
70
70
|
String compiler = System.getProperty("java.vm.name");
|
71
|
-
if (compiler == null || !(compiler.contains("HotSpot") && compiler.contains("Server"))) {
|
72
|
-
UI.printError(Module.API, "You do not appear to be running Sun's server JVM\nPerformance may suffer");
|
73
|
-
}
|
71
|
+
// if (compiler == null || !(compiler.contains("HotSpot") && compiler.contains("Server"))) {
|
72
|
+
// UI.printError(Module.API, "You do not appear to be running Sun's server JVM\nPerformance may suffer");
|
73
|
+
// }
|
74
74
|
UI.printDetailed(Module.API, "Java environment settings:");
|
75
75
|
UI.printDetailed(Module.API, " * Max memory available : %d MB", maxMb);
|
76
76
|
UI.printDetailed(Module.API, " * Virtual machine name : %s", compiler == null ? "<unknown" : compiler);
|
@@ -639,7 +639,7 @@ public class SunflowAPI implements SunflowAPIInterface {
|
|
639
639
|
if (filename == null) {
|
640
640
|
return new SunflowAPI();
|
641
641
|
}
|
642
|
-
SunflowAPI api
|
642
|
+
SunflowAPI api;
|
643
643
|
if (filename.endsWith(".java")) {
|
644
644
|
Timer t = new Timer();
|
645
645
|
UI.printInfo(Module.API, "Compiling \"" + filename + "\" ...");
|
@@ -684,7 +684,7 @@ public class SunflowAPI implements SunflowAPIInterface {
|
|
684
684
|
* @return <code>true</code> upon success, <code>false</code> otherwise
|
685
685
|
*/
|
686
686
|
public static boolean translate(String filename, String outputFilename) {
|
687
|
-
FileSunflowAPI api
|
687
|
+
FileSunflowAPI api;
|
688
688
|
try {
|
689
689
|
if (outputFilename.endsWith(".sca")) {
|
690
690
|
api = new AsciiFileSunflowAPI(outputFilename);
|
@@ -21,8 +21,10 @@ public interface GIEngine {
|
|
21
21
|
public Color getGlobalRadiance(ShadingState state);
|
22
22
|
|
23
23
|
/**
|
24
|
-
* Initialize the engine.
|
24
|
+
* Initialize the engine.This is called before rendering begins.
|
25
25
|
*
|
26
|
+
* @param options
|
27
|
+
* @param scene
|
26
28
|
* @return <code>true</code> if the init phase succeeded, <code>false</code>
|
27
29
|
* otherwise
|
28
30
|
*/
|
@@ -15,7 +15,7 @@ import org.sunflow.system.UI.Module;
|
|
15
15
|
*/
|
16
16
|
public class Geometry implements RenderObject {
|
17
17
|
|
18
|
-
private Tesselatable tesselatable;
|
18
|
+
private final Tesselatable tesselatable;
|
19
19
|
private PrimitiveList primitives;
|
20
20
|
private AccelerationStructure accel;
|
21
21
|
private int builtAccel;
|
@@ -10,8 +10,11 @@ public interface ImageSampler {
|
|
10
10
|
/**
|
11
11
|
* Prepare the sampler for rendering an image of w x h pixels
|
12
12
|
*
|
13
|
+
* @param options
|
14
|
+
* @param scene
|
13
15
|
* @param w width of the image
|
14
16
|
* @param h height of the image
|
17
|
+
* @return
|
15
18
|
*/
|
16
19
|
public boolean prepare(Options options, Scene scene, int w, int h);
|
17
20
|
|
@@ -36,9 +36,9 @@ public final class IntersectionState {
|
|
36
36
|
* Initializes all traversal stacks.
|
37
37
|
*/
|
38
38
|
public IntersectionState() {
|
39
|
-
for (
|
40
|
-
for (int j = 0; j <
|
41
|
-
|
39
|
+
for (StackNode[] stack : stacks) {
|
40
|
+
for (int j = 0; j < stack.length; j++) {
|
41
|
+
stack[j] = new StackNode();
|
42
42
|
}
|
43
43
|
}
|
44
44
|
}
|
@@ -102,13 +102,14 @@ public final class IntersectionState {
|
|
102
102
|
}
|
103
103
|
|
104
104
|
/**
|
105
|
-
* Record an intersection with the specified primitive id.
|
106
|
-
|
107
|
-
|
105
|
+
* Record an intersection with the specified primitive id.The parent object
|
106
|
+
is assumed to be the current instance. The u and v parameters are used to
|
107
|
+
pinpoint the location on the surface if needed.
|
108
108
|
*
|
109
109
|
* @param id primitive id of the intersected object
|
110
110
|
* @param u u surface paramater of the intersection point
|
111
111
|
* @param v v surface parameter of the intersection point
|
112
|
+
* @param w
|
112
113
|
*/
|
113
114
|
public final void setIntersection(int id, float u, float v, float w) {
|
114
115
|
instance = current;
|
@@ -36,13 +36,14 @@ public class ParameterList {
|
|
36
36
|
* Creates an empty ParameterList.
|
37
37
|
*/
|
38
38
|
public ParameterList() {
|
39
|
-
list = new FastHashMap
|
39
|
+
list = new FastHashMap<>();
|
40
40
|
numVerts = numFaces = numFaceVerts = 0;
|
41
41
|
}
|
42
42
|
|
43
43
|
/**
|
44
|
-
* Clears the list of all its members.
|
44
|
+
* Clears the list of all its members.If some members were never used, a
|
45
45
|
* warning will be printed to remind the user something may be wrong.
|
46
|
+
* @param showUnused
|
46
47
|
*/
|
47
48
|
public void clear(boolean showUnused) {
|
48
49
|
if (showUnused) {
|
@@ -95,11 +95,12 @@ public final class Ray {
|
|
95
95
|
}
|
96
96
|
|
97
97
|
/**
|
98
|
-
* Create a new ray by transforming the supplied one by the given matrix.
|
99
|
-
|
100
|
-
|
98
|
+
* Create a new ray by transforming the supplied one by the given matrix.If
|
99
|
+
the matrix is
|
100
|
+
<code>null</code>, the original ray is returned.
|
101
101
|
*
|
102
102
|
* @param m matrix to transform the ray by
|
103
|
+
* @return
|
103
104
|
*/
|
104
105
|
public Ray transform(Matrix4 m) {
|
105
106
|
if (m == null) {
|
@@ -11,7 +11,7 @@ import org.sunflow.system.UI.Module;
|
|
11
11
|
*/
|
12
12
|
public final class TextureCache {
|
13
13
|
|
14
|
-
private static HashMap<String, Texture> textures = new HashMap
|
14
|
+
private static final HashMap<String, Texture> textures = new HashMap<>();
|
15
15
|
|
16
16
|
private TextureCache() {
|
17
17
|
}
|
@@ -17,7 +17,7 @@ public class BoundingIntervalHierarchy implements AccelerationStructure {
|
|
17
17
|
private int[] objects;
|
18
18
|
private PrimitiveList primitives;
|
19
19
|
private BoundingBox bounds;
|
20
|
-
private int maxPrims;
|
20
|
+
private final int maxPrims;
|
21
21
|
|
22
22
|
public BoundingIntervalHierarchy() {
|
23
23
|
maxPrims = 2;
|
@@ -471,7 +471,7 @@ public class KDTree implements AccelerationStructure {
|
|
471
471
|
// current plane
|
472
472
|
int pClosed = 0, pPlanar = 0, pOpened = 0;
|
473
473
|
long ptrMasked = ptr & (~TYPE_MASK & 0xFFFFFFFFF0000000L);
|
474
|
-
long ptrClosed = ptrMasked
|
474
|
+
long ptrClosed = ptrMasked;
|
475
475
|
long ptrPlanar = ptrMasked | PLANAR;
|
476
476
|
long ptrOpened = ptrMasked | OPENED;
|
477
477
|
while (i < nSplits && (splits[i] & 0xFFFFFFFFF0000000L) == ptrClosed) {
|
@@ -41,7 +41,7 @@ public final class CausticPhotonMap implements CausticPhotonMapInterface {
|
|
41
41
|
bounds = new BoundingBox();
|
42
42
|
maxPower = 0;
|
43
43
|
maxRadius = 0;
|
44
|
-
photonList = new ArrayList
|
44
|
+
photonList = new ArrayList<>();
|
45
45
|
photonList.add(null);
|
46
46
|
photons = null;
|
47
47
|
storedPhotons = halfStoredPhotons = 0;
|
@@ -267,7 +267,7 @@ public final class CausticPhotonMap implements CausticPhotonMapInterface {
|
|
267
267
|
|
268
268
|
int found;
|
269
269
|
float px, py, pz;
|
270
|
-
private int max;
|
270
|
+
private final int max;
|
271
271
|
private boolean gotHeap;
|
272
272
|
protected float[] dist2;
|
273
273
|
protected Photon[] index;
|
@@ -22,7 +22,7 @@ public final class GlobalPhotonMap implements GlobalPhotonMapInterface {
|
|
22
22
|
private int log2n;
|
23
23
|
private int numGather;
|
24
24
|
private float gatherRadius;
|
25
|
-
private BoundingBox bounds;
|
25
|
+
private final BoundingBox bounds;
|
26
26
|
private boolean hasRadiance;
|
27
27
|
private float maxPower;
|
28
28
|
private float maxRadius;
|
@@ -425,7 +425,7 @@ public final class GlobalPhotonMap implements GlobalPhotonMapInterface {
|
|
425
425
|
|
426
426
|
int found;
|
427
427
|
float px, py, pz;
|
428
|
-
private int max;
|
428
|
+
private final int max;
|
429
429
|
private boolean gotHeap;
|
430
430
|
protected float[] dist2;
|
431
431
|
protected Photon[] index;
|
@@ -34,7 +34,7 @@ public class BucketRenderer implements ImageSampler {
|
|
34
34
|
private int bucketSize;
|
35
35
|
private int bucketCounter;
|
36
36
|
private int[] bucketCoords;
|
37
|
-
private boolean dumpBuckets;
|
37
|
+
private final boolean dumpBuckets;
|
38
38
|
// anti-aliasing
|
39
39
|
private int minAADepth;
|
40
40
|
private int maxAADepth;
|
@@ -67,6 +67,7 @@ public class BucketRenderer implements ImageSampler {
|
|
67
67
|
dumpBuckets = false; // for debugging only - not user settable
|
68
68
|
}
|
69
69
|
|
70
|
+
@Override
|
70
71
|
public boolean prepare(Options options, Scene scene, int w, int h) {
|
71
72
|
this.scene = scene;
|
72
73
|
imageWidth = w;
|
@@ -142,6 +143,7 @@ public class BucketRenderer implements ImageSampler {
|
|
142
143
|
return String.format("%s%d sample%s", depth < 0 ? "1/" : "", pixelAA * pixelAA, depth == 0 ? "" : "s");
|
143
144
|
}
|
144
145
|
|
146
|
+
@Override
|
145
147
|
public void render(Display display) {
|
146
148
|
this.display = display;
|
147
149
|
display.imageBegin(imageWidth, imageHeight, bucketSize);
|
@@ -48,27 +48,36 @@ public class EXRBitmapWriter implements BitmapWriter {
|
|
48
48
|
@Override
|
49
49
|
public final void configure(final String option, String value) {
|
50
50
|
if (option.equals(COMPRESSION)) {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
switch (value) {
|
52
|
+
case "none":
|
53
|
+
compression = NO_COMPRESSION;
|
54
|
+
break;
|
55
|
+
case "rle":
|
56
|
+
compression = RLE_COMPRESSION;
|
57
|
+
break;
|
58
|
+
case "zip":
|
59
|
+
compression = ZIP_COMPRESSION;
|
60
|
+
break;
|
61
|
+
default:
|
62
|
+
UI.printWarning(Module.IMG, "EXR - Compression type was not recognized - defaulting to zip");
|
63
|
+
compression = ZIP_COMPRESSION;
|
64
|
+
break;
|
60
65
|
}
|
61
66
|
} else if (option.equals("channeltype")) {
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
switch (value) {
|
68
|
+
case "float":
|
69
|
+
channelType = FLOAT;
|
70
|
+
channelSize = FLOAT_SIZE;
|
71
|
+
break;
|
72
|
+
case "half":
|
73
|
+
channelType = HALF;
|
74
|
+
channelSize = HALF_SIZE;
|
75
|
+
break;
|
76
|
+
default:
|
77
|
+
UI.printWarning(Module.DISP, "EXR - Channel type was not recognized - defaulting to float");
|
78
|
+
channelType = FLOAT;
|
79
|
+
channelSize = FLOAT_SIZE;
|
80
|
+
break;
|
72
81
|
}
|
73
82
|
}
|
74
83
|
}
|
@@ -14,17 +14,21 @@ public class PNGBitmapWriter implements BitmapWriter {
|
|
14
14
|
private String filename;
|
15
15
|
private BufferedImage image;
|
16
16
|
|
17
|
+
@Override
|
17
18
|
public void configure(String option, String value) {
|
18
19
|
}
|
19
20
|
|
21
|
+
@Override
|
20
22
|
public void openFile(String filename) throws IOException {
|
21
23
|
this.filename = filename;
|
22
24
|
}
|
23
25
|
|
26
|
+
@Override
|
24
27
|
public void writeHeader(int width, int height, int tileSize) throws IOException, UnsupportedOperationException {
|
25
28
|
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
26
29
|
}
|
27
30
|
|
31
|
+
@Override
|
28
32
|
public void writeTile(int x, int y, int w, int h, Color[] color, float[] alpha) throws IOException {
|
29
33
|
for (int j = 0, index = 0; j < h; j++) {
|
30
34
|
for (int i = 0; i < w; i++, index++) {
|
@@ -33,6 +37,7 @@ public class PNGBitmapWriter implements BitmapWriter {
|
|
33
37
|
}
|
34
38
|
}
|
35
39
|
|
40
|
+
@Override
|
36
41
|
public void closeFile() throws IOException {
|
37
42
|
ImageIO.write(image, "png", new File(filename));
|
38
43
|
}
|