Giter Site home page Giter Site logo

macroing / dayflower Goto Github PK

View Code? Open in Web Editor NEW
26.0 4.0 2.0 198.26 MB

A photorealistic 3D-renderer written in Java

Home Page: https://www.dayflower.org

License: GNU Lesser General Public License v3.0

Java 100.00% Batchfile 0.01%
3d-graphics ambient-occlusion aparapi java path-tracer ray-caster ray-tracer renderer opencl image-processing

dayflower's Introduction

Dayflower

Dayflower is an application and a library for rendering in Java.

Its primary focus is photorealistic 3D-rendering, preferably in realtime. However, it can also be used for 2D-rendering and image processing.

alt text alt text

Getting Started

To clone this repository and build the project using Apache Ant, you can type the following in Git Bash.

git clone https://github.com/macroing/Dayflower.git
cd Dayflower
ant

If you have cloned this repository and built the project using Apache Ant as presented above, you can run the project using its GUI in the following way.

cd distribution/Dayflower
java -Djava.library.path=lib/aparapi -jar Dayflower.jar

If you prefer to use Dayflower as a library and not as an application, the following Java source code demonstrates how you can use the CPU- and GPU renderers.

import org.dayflower.renderer.RenderingAlgorithm;
import org.dayflower.renderer.cpu.CPURenderer;
import org.dayflower.renderer.observer.FileRendererObserver;
import org.dayflower.scene.loader.JavaSceneLoader;

public class CPURendererExample {
    public static void main(String[] args) {
        CPURenderer cPURenderer = new CPURenderer(new FileRendererObserver("Image.png", true, false));
        cPURenderer.setScene(new JavaSceneLoader().load("./resources/scenes/CornellBox.java"));
        cPURenderer.setImage();
        cPURenderer.setMaximumBounce(20);
        cPURenderer.setMinimumBounceRussianRoulette(5);
        cPURenderer.setRenderingAlgorithm(RenderingAlgorithm.PATH_TRACING);
        cPURenderer.setup();
        cPURenderer.render(10);
        cPURenderer.dispose();
    }
}
import org.dayflower.renderer.RenderingAlgorithm;
import org.dayflower.renderer.gpu.GPURenderer;
import org.dayflower.renderer.observer.FileRendererObserver;
import org.dayflower.scene.loader.JavaSceneLoader;

public class GPURendererExample {
    public static void main(String[] args) {
        GPURenderer gPURenderer = new GPURenderer(new FileRendererObserver("Image.png", true, false));
        gPURenderer.setScene(new JavaSceneLoader().load("./resources/scenes/CornellBox.java"));
        gPURenderer.setImage();
        gPURenderer.setMaximumBounce(20);
        gPURenderer.setMinimumBounceRussianRoulette(5);
        gPURenderer.setRenderingAlgorithm(RenderingAlgorithm.PATH_TRACING);
        gPURenderer.setup();
        gPURenderer.render(10);
        gPURenderer.dispose();
    }
}

Supported Features

The tables below show the main features of the renderer.

Supported Rendering Algorithms

Name CPU GPU
Ambient Occlusion Yes Yes
Depth Camera Yes Yes
Path Tracing Yes Yes
Ray Casting Yes Yes
Ray Tracing Yes Yes

Supported Lights

Name CPU GPU
Diffuse Area Light Yes Yes
Directional Light Yes Yes
Image Light Yes Yes
Perez Light (Sun & Sky) Yes Yes
Point Light Yes Yes
Primitive Area Light Yes No
Spot Light Yes Yes

Supported Materials

Name CPU GPU
Bullseye Material Yes Yes
Checkerboard Material Yes Yes
Clear Coat Material Yes Yes
Disney Material Yes Yes
Fourier Material Yes No
Function Material Yes No
Glass Material Yes Yes
Glossy Material Yes Yes
Hair Material Yes No
KD Subsurface Material Yes No
Matte Material Yes Yes
Metal Material Yes Yes
Mirror Material Yes Yes
Plastic Material Yes Yes
Polka Dot Material Yes Yes
Substrate Material Yes Yes
Subsurface Material Yes No
Translucent Material Yes Yes
Uber Material Yes Yes

Supported Modifiers

Name CPU GPU
Bi Modifier Yes No
No-Op Modifier Yes Yes
Normal Map Low-Dynamic-Range (LDR) Image Modifier Yes Yes
Simplex Noise Normal Map Modifier Yes Yes
Steep Parallax Map Low-Dynamic-Range (LDR) Image Modifier Yes No

Supported Shapes

Name CPU GPU
Compound Shape Yes No
Cone Yes Yes
Constructive Solid Geometry (CSG) Yes No
Curve Yes No
Cylinder Yes Yes
Disk Yes Yes
Hyperboloid Yes Yes
Paraboloid Yes Yes
Plane Yes Yes
Polygon Yes Yes
Procedural Terrain Yes No
Rectangle Yes Yes
Rectangular Cuboid Yes Yes
Sphere Yes Yes
Torus Yes Yes
Triangle Yes Yes
Triangle Mesh Yes Yes

Supported Textures

Name CPU GPU
Blend Texture Yes Yes
Bullseye Texture Yes Yes
Checkerboard Texture Yes Yes
Constant Texture Yes Yes
Dot Product Texture Yes Yes
Function Texture Yes No
Low-Dynamic-Range (LDR) Image Texture Yes Yes
Marble Texture Yes Yes
Polka Dot Texture Yes Yes
Simplex Fractional Brownian Motion Texture Yes Yes
Surface Normal Texture Yes Yes
UV Texture Yes Yes

Documentation

The documentation for this library can be found in the Javadocs that are generated when building it.

Library

The following table describes the different APIs and their current status in the library.

Name Javadoc Unit Test
Dayflower ???.?% 15.7%
Change API 100.0% 100.0%
Geometry API 100.0% 77.8%
Geometry Bounding Volume API 100.0% 100.0%
Geometry Bounding Volume Hierarchy API 100.0% 0.0%
Geometry Rasterizer API 100.0% 0.0%
Geometry Shape API 100.0% 17.4%
Image API 100.0% 0.0%
Interpolation API ???.?% 0.0%
JavaFX Material API 100.0% 0.0%
JavaFX Scene Canvas API 100.0% 0.0%
JavaFX Shape API 100.0% 0.0%
JavaFX Texture API 100.0% 0.0%
Parameter API 100.0% 0.0%
Renderer API 100.0% 100.0%
Renderer CPU API 100.0% 0.0%
Renderer GPU API ???.?% 0.0%
Renderer Observer API 100.0% 0.0%
Sampler API 100.0% 0.0%
Scene API ???.?% 0.0%
Scene BSSRDF API ???.?% 0.0%
Scene BXDF API ???.?% 0.0%
Scene Compiler API 100.0% 0.0%
Scene Fresnel API 100.0% 0.0%
Scene Light API 100.0% 0.0%
Scene Loader API 100.0% 0.0%
Scene Material API ???.?% 0.0%
Scene Microfacet API 100.0% 0.0%
Scene Modifier API 100.0% 0.0%
Scene Texture API 100.0% 0.0%
Utility API ???.?% 70.8%
Wavefront Material API 100.0% 0.0%
Wavefront Object API 100.0% 0.0%

Dependencies

References

This library has been created with the help of many articles, books and renderer implementations.

The following list shows the renderer implementations that have been referenced the most, in alphabetical order.

Java 9 and Above

Dayflower is built for Java 8. When it's being used in Java 9 and above, certain problems are likely to occur. Some of them are presented below.

  • JavaFX was removed from the JDK and the JRE when Java 11 was released. In Java 11 it has to be added manually.

Note

This library has not reached version 1.0.0 and been released to the public yet. Therefore, you can expect that backward incompatible changes are likely to occur between commits. When this library reaches version 1.0.0, it will be tagged and available on the "releases" page. At that point, backward incompatible changes should only occur when a new major release is made.

dayflower's People

Contributors

macroing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dayflower's Issues

Closing the last tab in Dayflower Application causes a hang

The Application hangs and keeps the mouse bound. I was able to kill it from the command line and got the following exception


Exception in thread "JavaFX Application Thread" java.lang.ArithmeticException: / by zero
	at com.sun.javafx.scene.control.behavior.TabPaneBehavior.nextIndex(TabPaneBehavior.java:187)
	at com.sun.javafx.scene.control.behavior.TabPaneBehavior.findValidTab(TabPaneBehavior.java:175)
	at com.sun.javafx.scene.control.behavior.TabPaneBehavior.moveSelection(TabPaneBehavior.java:160)
	at com.sun.javafx.scene.control.behavior.TabPaneBehavior.moveSelection(TabPaneBehavior.java:155)
	at com.sun.javafx.scene.control.behavior.TabPaneBehavior.selectPreviousTab(TabPaneBehavior.java:151)
	at com.sun.javafx.scene.control.behavior.TabPaneBehavior.callAction(TabPaneBehavior.java:74)
	at com.sun.javafx.scene.control.behavior.BehaviorBase.callActionForEvent(BehaviorBase.java:218)
	at com.sun.javafx.scene.control.behavior.BehaviorBase.lambda$new$0(BehaviorBase.java:135)
	at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Scene$KeyHandler.process(Scene.java:3964)
	at javafx.scene.Scene$KeyHandler.access$1800(Scene.java:3910)
	at javafx.scene.Scene.impl_processKeyEvent(Scene.java:2040)
	at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2501)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(GlassViewEventHandler.java:248)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
	at com.sun.glass.ui.View.handleKeyEvent(View.java:546)
	at com.sun.glass.ui.View.notifyKey(View.java:966)
	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$null$10(GtkApplication.java:245)
	at java.lang.Thread.run(Thread.java:748)

[Feature Request] Live control of transforms for animated scenes.

It would be desirable to bind JavaFX Transform objects to specific Dayflower Transform objects. The purpose would be to animate objects in the scene and render again.

This feature would be useful for animation software to animate and render without having to make a new scene for each frame.

This would also be VERY useful for Robotics applications. Using the virtual range finder code a robot simulation could provide virtual sensor data as fast as a real sensor. This would let roboticsts test control code in virtual environments. (I would LOVE to include this feature in BowlerStudio https://commonwealthrobotics.com/ )

[Question] License?

You have LGPL and GPL in the repo, that seems like a contradiction?

I would need LGPL to really incorporate this as a feature, can you clarify how the licensing works from your perspective? Since its all your code, if you just choose to remove the GPL license then this can (and IMHO should) be a major step forward in Java rendering standards!

[Feature Request] Change JavaSceneLoader to use InputStream instead of File

For users of this coda as a library, an Input stream is more flexible than a File. I would like to generate scene code on the fly, so storing to a String would be preferable to writing to disk. It would also be interesting to stream scenes to be rendered over a network connection so passing in data as a SocketStream would be useful.

resources folder

I am trying to add this into NetBeansIDE 12.4, all seems fine except the resources folder where all of the files have errors in all of its lines, what is wrong with that folder? How in the world can a Java class has structure like this example below (BullseyeMaterial.java in resources folder)???

final Light light1 = new PerezLight();

final Material material1 = new MatteMaterial(new CheckerboardTexture());
final Material material2 = new BullseyeMaterial(new MatteMaterial(new Color3F(1.0F, 0.01F, 0.01F)), new MatteMaterial(new Color3F(0.01F, 1.0F, 0.01F)), new Point3F(10.0F, 10.0F, 10.0F));

final Shape3F shape1 = new Plane3F();
final Shape3F shape2 = new Sphere3F();

final Transform transform1 = new Transform(new Point3F(0.0F, 0.0F, 0.0F));
final Transform transform2 = new Transform(new Point3F(0.0F, 1.0F, 0.0F), Quaternion4F.from(Matrix44F.rotateX(AngleF.degrees(270.0F))));

final Primitive primitive1 = new Primitive(material1, shape1, transform1);
final Primitive primitive2 = new Primitive(material2, shape2, transform2);

final Camera camera = new Camera(new Point3F(0.0F, 2.0F, -10.0F), AngleF.degrees(40.0F));

scene.addLight(light1);
scene.addPrimitive(primitive1);
scene.addPrimitive(primitive2);
scene.setCamera(camera);
scene.setName("BullseyeMaterial");

Because of that I cannot run/test anything at all...

Add intersection methods to Rectangle2D, Rectangle2F and Rectangle2I

Add static intersection methods to the Rectangle2D, Rectangle2F and Rectangle2I classes.

These methods should take two instances of the same Rectangle2* type as parameters and return an Optional<Polygon2*> with the optional intersection.

They previously had methods returning an Optional<Rectangle2*>. This only works if both are axis-aligned.

[Question] Virtual Range finder (Realsense) depth image from Dayflower

I have been searching for pure java raytracer and found this project, FANTASTIC work! This is truly a hidden gem!

I am looking to implement a virtual range finder in Java for a robot simulation system. I would love to use the work you have done as-is, or with some small modifications if possible.

I want to render an image such that each "pixel" corresponds to a float value of distance to first occlusion, so i can encode it as a 16 bit greyscale image just like the Intel Realsense does. I was about to implement this manually in Aparapi, but found your project while reading through their site.

I have gotten the sample project running in Eclipse, and seem to have gotten the GPU acceleration running.

I have 3 main questions:

  1. Can I convert from a Javafx scene produced with other library for assets (JCSG) to the org.dayflower.scene.Scene, or must the scene be loaded via the DSL file? Can it handle generic MeshView's?

  2. Will Scene elements obey changes to transforms? As in, will an animated transform be animated synchronously in the rendered scene?

  3. Do you have any examples of a "depth camera view"?

calls to missing resources

Throughout the code there is zillions of calls to NONEXISTENT RESOURCES, that is no such directories/files are nowhere to be found in the code package downloadable from here at all!

Some exmaples of such calls:

private static final double[] IMAGE_4_D_DISPLACEMENT_MAP = Image.image4DLoad("./resources/textures/bricks2_disp.jpg");
private static final double[] IMAGE_4_D_NORMAL_MAP = Image.image4DLoad("./resources/textures/bricks2_normal.jpg");

There is no folder "textures" in resources folder or anywhere else in the whole package, and I would like to point out this is even in the test classes that should serve as presentation/preview of supposed functionalities of Dayflower!

Or this one here:

public static void main(final String[] args) {
        doRender("./generated/Simplex/Cone.png", 270.0D, cone3D(), 4.0D);
        doRender("./generated/Simplex/Cylinder.png", 270.0D, cylinder3D(), 4.0D);
        doRender("./generated/Simplex/Disk.png", 0.0D, disk3D(), 2.0D);
        doRender("./generated/Simplex/Hyperboloid.png", 270.0D, hyperboloid3D(), 4.0D);
        doRender("./generated/Simplex/Paraboloid.png", 270.0D, paraboloid3D(), 4.0D);
        doRender("./generated/Simplex/Plane.png", 0.0D, plane3D(point3D(0.0D, -1.0D, 0.0D), point3D(0.0D, -1.0D, 1.0D), point3D(1.0D, -1.0D, 0.0D)), 0.1D);
        doRender("./generated/Simplex/Polygon.png", 0.0D, polygon3D(), 2.0D);
        doRender("./generated/Simplex/Rectangle.png", 0.0D, rectangle3D(), 2.0D);
        doRender("./generated/Simplex/RectangularCuboid.png", 0.0D, rectangularCuboid3D(), 2.0D);
        doRender("./generated/Simplex/Sphere.png", 270.0D, sphere3D(), 4.0D);
        doRender("./generated/Simplex/Torus.png", 0.0D, torus3D(), 2.0D);
        doRender("./generated/Simplex/Triangle.png", 0.0D, triangle3D(), 4.0D);
    }

There is no folder called "generated" anywhere in the whole package, and I would like to point out this is even in the test classes that should serve as presentation/preview of supposed functionalities of Dayflower!

Thus there is no chance to even test this!

Recent dependancy change broke Java 8 support

A change in the dependencies causes Java 8 builds of the source to fail to compile.

Could not instrument class org/macroing/java/io/Files: Unsupported class file major version 61.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.