Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elliottt/rendrs
A raytracer in rust
https://github.com/elliottt/rendrs
ray-tracing raymarching rust
Last synced: 3 months ago
JSON representation
A raytracer in rust
- Host: GitHub
- URL: https://github.com/elliottt/rendrs
- Owner: elliottt
- Created: 2019-07-15T01:36:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-09T04:22:17.000Z (4 months ago)
- Last Synced: 2024-09-09T05:35:55.937Z (4 months ago)
- Topics: ray-tracing, raymarching, rust
- Language: Rust
- Size: 4.23 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rendrs
`rendrs` is a poorly named ray-marching raytracer. It has a scene description
language that's s-expression based, and documented in the language section.## Examples
`cargo run --release -- render scenes/complicated.scene`
![](examples/complicated.png)
## Running
`rendrs` can be run in one of two modes, as an offline renderer that will output
the render targets of the scene description, or in an interactive mode where it
will refresh the render targets in a web-browser window as the scene description
is edited and saved.The first mode is run via the `render` sub-command. It expects a scene file as
an argument, and has an optional `--threads` argument to control the number of
threads spawned during rendering.The second mode is run via the `serve` sub-command. It will watch the scene file
provided, and will open your web-browser to `http://127.0.0.1:8080` when
started. The port used can be controlled via the `--port` argument, and the
`--threads` argument is also valid here.## TODO
* [ ] `.obj` file mesh loading
* [ ] Global illumination integrator
* [ ] Handle non-square pixels for ascii rendering
* [x] Transparent objects
* [x] Sub-pixel sampling strategies## Language
The scene description language is made up of s-expressions. Top-level
declarations are used to define nodes, lights, patterns, materials, and cameras,
which are all used by render targets to produce a final output.Single-line comments start with the `;` character.
The following conventions are used in the descriptions below:
* `` - an identifier, starting with a lower-case ascii letter, followed by
ascii letters, digits or the symbols `-`, `_`, `!`, or `?`
* `` - a number, with an optional decimal component
* `` - a three dimensional vector, specified as `( )`, where
each of the components are expected to be number literals
* `` - a three dimensional point, specified in the same format as
``
* `` - a double-quoted string
* `` - the same format as ``, but with a leading `:`
* `` - a hex color, specified as `#rrggbb`
* `` - either a number specifyin the value in radians, or
`(degrees )` to specify it in degrees.### Nodes
Node declarations take the form:
```lisp
(node )
```The following shape descriptions are available:
* `(plane )` - a plane whose normal is given by the vector.
* `(sphere )` - a sphere whose radius is given by the number.
* `(box )` - a box whose width, height, and depth are
given by the three numeric literal arguments.
* `(torus )` - a torus with the given hole diameter, and outer
radius.
* `(group ...)` - Group together the following nodes into one node. The
nodes can be either inlined shape definitions, or the names of nodes
introduced through a top-level `(node ...)` declaration.
* `(union ...)` - Union together nodes. This behaves similarly to
`(group ...)`, but the difference is that for material application it's
considered to be a single object, wheras the members of a group are still
considered to be separate objects.
* `(smooth-union ...)` - Union the nodes together, but smoothly
blend between the nodes according to the numeric parameter given.
* `(subtract )` - Subtract the second node from the first. The
material from the second node will be used as the material for the cutout,
giving some control over how the removal looks.
* `(intersect ...)` - The intersection of all of the objects.
* `(transform )` - Apply the given transform to the node when
rendering it.
* `(paint )` - Apply the given material to the node when
rendering.### Transforms
Transforms can be used to transform nodes or patterns in the scene graph during
rendering.* `(compose ...)` - Compose all the transformations left-to-right.
* `(rotate )` - A rotation specified in axis-angle notation.
* `(uniform-scale )` - Uniform scaling in all dimensions.
* `(scale )` - Non-uniform scaling in all dimensions. WARNING: this
doesn't function exactly correctly for SDFs, and may have unexpected behavior
as a result.
* `(look-at )` - Compose the look-at transform to orient
the first point, the eye, towards the second point, the target. Especially
useful for orienting cameras.### Lights
Lights can be added to the scene with a `light` declaration:
```lisp
(light )
```The light value can take one of the following forms:
* `(diffuse )` - A diffuse light applied to the entire scene.
* `(point )` - A point light with the given color, positioned at
the point.### Patterns
Patterns can be declared with the following form:
```lisp
(pattern )
```The pattern values can take one of the following forms:
* `(solid )` - The solid color pattern.
* `(gradient )` - Blending between the two colors given the
object-space coordinate's x-value.
* `(stripes )` - Alternating between the two patterns in
vertical stripes, based on the object space coordinate's x-value.
* `(checkers )` - A checkerboard pattern that alternates
between the two patterns. The checkers are three-dimensional volumes, so
they're more like cubes in space.
* `(shells )` - Rings of alternating patterns, centered at
the origin.
* `(transform )` - Apply the transformation to the
object-space point before determing the color produced by the sub-pattern.### Materials
Materials can be declared with the following form:
```lisp
(material )
```The material values can take one of the following forms:
* `(phong )` - The Phong reflection model, with the following arguments:
* `:pattern ` - (required) the pattern to use for the surface
* `:ambient ` - (default `0.1`) the ambient light contribution,
`[0,1]`
* `:diffuse ` - (default `0.9`) the diffuse light contribution,
`[0,1]`
* `:specular ` - (default `0.9`) the specular light contribution,
`[0,1]`
* `:shininess ` - (default `200`) the specular light contribution
* `:reflective ` - (default `0`) how reflective the surface is,
`[0,1]`
* `:transparent ` - (default 0) how transparent the surface is,
`[0,1]`
* `:refractive_index ` - (default 0) the index of refraction for the
surface, must be positive.
* `(emissive )` - The surface behaves as a light source. This is
currently not very helpful, as the only integrator available is a Whitted
ray-tracer, that doesn't handle emissive objects well.### Cameras
Cameras can be declared at the top-level with the following form:
```lisp
(camera )
```There is currently only one type of camera, a `pinhole` camera. It takes the
following form:```lisp
(pinhole )
```The first two numbers are width and height of the canvas produced, the transform
is the world-to-camera transform, and the last angle is the field of view of
the transform.### Render Targets
Render targets are declared as follows:
```lisp
(render )
````` is one of the following forms:
* `(file )` - write the output to the file specified in the string
* `(ascii )` - Render the output as ascii, and use the string name to
disambiguate it from other `ascii` targets.There is currently only one `` supported, the `whitted` integrator.
It takes as an argument a `` and `` value. The only sampler
currently implemented is the `(uniform )` sampler, where the
two numeric parameters are the number of horizontal and vertical samples to
collect for a single pixel.Finally, the `` argument will be the root of the scene, and only nodes
reachable from that node will be rendered.