Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabio914/watchRayTracer
RayTracer for watchOS
https://github.com/fabio914/watchRayTracer
apple-watch raytracer watchos
Last synced: 3 months ago
JSON representation
RayTracer for watchOS
- Host: GitHub
- URL: https://github.com/fabio914/watchRayTracer
- Owner: fabio914
- Created: 2015-12-06T01:04:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-07T01:36:41.000Z (almost 9 years ago)
- Last Synced: 2024-06-30T16:54:55.701Z (4 months ago)
- Topics: apple-watch, raytracer, watchos
- Language: Objective-C
- Size: 2.54 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-apple-watch - Watch RayTracer - RayTracer for watchOS (Sample Apps / Blog)
README
# Watch RayTracer
A simple ray tracer for iOS 9.0 and watchOS 2.0 written in Objetive-C.
## Why?
I wanted to be the first one to run a ray tracer on a watch. It works, however it may take a while to render a single frame on the Apple Watch.## Example
### Creating a scene
```objective-c
RTCamera * camera = [RTCamera cameraWithEye:[RTPoint pointWithX:-5.0 Y:8.0 Z:5.0] lookAt:[RTPoint pointWithX:0.0 Y:5.0 Z:0.0] up:[RTVector vectorWithX:0.0 Y:1.0 Z:0.0] fov:45.0 zvp:0.1];
RTBackground * background = [RTBackground backgroundWithCanvas:[RTCanvas canvasWithImage:[UIImage imageNamed:@"photosphere"]]];
RTMaterial * sphereMaterial = [RTMaterial materialWithAmbient:[RTComponent componentWithRed:0.1 green:0.1 blue:0.1] diffuse:[RTComponent componentWithRed:0.8 green:0.8 blue:0.08] specular:[RTComponent componentWithRed:0.98 green:0.98 blue:0.8] shininess:300.0 reflection:0.9 transparency:0.0];
RTSphere * sphere = [RTSphere sphereWithMaterial:sphereMaterial position:[RTPoint pointWithX:0.0 Y:5.0 Z:0.0] radius:1.0];RTMaterial * boxMaterial = [RTMaterial materialWithAmbient:[RTComponent componentWithRed:0.1 green:0.1 blue:0.1] diffuse:[RTComponent componentWithRed:0.5 green:0.5 blue:0.5] specular:[RTComponent componentWithRed:0.8 green:0.8 blue:0.8] shininess:300.0 reflection:0.75 transparency:0.0];
RTBox * box = [RTBox boxWithMaterial:boxMaterial position:[RTPoint pointWithX:0.0 Y:4.0 Z:0.0] size:[RTVector vectorWithX:3.0 Y:0.5 Z:3.0]];
RTLight * light = [RTLight lightAtPosition:[RTPoint pointWithX:2.0 Y:11.0 Z:6.0] withAmbient:[RTColour colourWithRed:255.0 green:255.0 blue:255.0] diffuse:[RTColour colourWithRed:255.0 green:255.0 blue:255.0] specular:[RTColour colourWithRed:255.0 green:255.0 blue:255.0]];
RTScene * scene = [RTScene sceneWithCamera:camera bakground:background objects:@[sphere, box] lights:@[light]];
```### Rendering that scene
Rendering with anti-aliasing and more reflections
```objective-cRTRayTracer * rt = [RTRayTracer niceRayTracerWithScene:scene dimension:[RTDimension dimensionWithSize:CGSizeMake(100, 100)]];
UIImage * result = [[rt trace] image];
```
Rendering without anti-aliasing and with less reflections
```objective-cRTRayTracer * rt = [RTRayTracer fastRayTracerWithScene:scene dimension:[RTDimension dimensionWithSize:CGSizeMake(100, 100)]];
UIImage * result = [[rt trace] image];
```
### Requires
* XCode 7.1 (iOS 9.0 + watchOS 2.0)### Developer
[Fabio de Albuquerque Dela Antonio](http://fabio914.blogspot.com)### Credits
Photo sphere by [Steve Troletti](http://www.trolettiphoto.com)