PushingP is an offline Whitted ray tracing renderer written in Java.
PushingP was created out of an enthusiasm for computer graphics and a desire to learn about ray tracing algorithms and data structures.
PushingP is short for PushingP(ixels), a refence to the application's job of filling the pixels of the screen with color.
PushingP was developed by following Jamis Buck's book The Ray Tracer Challenge
To build PushingP from source, the project requires Java 21 and Maven 3 to be installed on the host device.
To build a jar file that contains PushingP and demonstration scenes run:
mvn clean compile assembly:single
The generated jar file will be in the /target
folder.
In the directory that contains the jar file:
java -jar PushingP-version.jar -demo_help
java -jar PushingP-version.jar -demo_name
java -jar PushingP-version.jar -soft_shadows
PushingP can also be run using: java -cp PushingP-version.jar com.BudgiePanic.rendering.App -argument
You can render an image of your own scene using:
javac -cp ".:PushingP-version.jar" MyFile.java
java -cp ".:PushingP-verion.jar" MyFile
The following class generates an image of a sphere infront of a flat surface.
MyFile.java
import com.BudgiePanic.rendering.util.*;
import com.BudgiePanic.rendering.scene.*;
import com.BudgiePanic.rendering.util.light.*;
import com.BudgiePanic.rendering.util.pattern.*;
import com.BudgiePanic.rendering.util.shape.*;
import com.BudgiePanic.rendering.util.transform.Transforms;
import com.BudgiePanic.rendering.util.transform.View;
import com.BudgiePanic.rendering.toy.BaseDemo;
public class MyFile extends BaseDemo {
public static void main(String[] args) {
new MyFile().run();
}
@Override
public String getName() {
return "my_image.ppm";
}
@Override
public Camera getCamera() {
return new SuperSamplingCamera(
new PinHoleCamera(640, 480, AngleHelp.toRadians(90),
View.makeViewMatrix(Tuple.makePoint(0,1,-5), Tuple.makePoint(0,0,1), Directions.up)),
SuperSamplingCamera.defaultMode
);
}
@Override
public World createWorld() {
World world = new World();
Light light = new AreaLight(Colors.white, Tuple.makePoint(5,5,-7), Directions.forward, Directions.up, 3, 3, AreaLight.randomSamples);
world.addLight(light);
var sphere = new Sphere(Transforms.identity().assemble());
world.addShape(sphere);
var background = new Cube(Transforms.identity().scale(15,15,0.1).translate(0,0,5).assemble());
world.addShape(background);
return world;
}
}
The toy
package contains code examples of how to use PushingP.
PushingP currently exports images in the ppm
format.
ppm
images can be viewed using an image viewing program, such as GNU's GIMP application.
PushingP has the following features:
*.ppm
image writer*.ppm
texture importer*.obj
object importer PushingP is released under the Apache 2.0 open source license