tylermorganwall / rayvertex

3D Software Rasterizer for R
https://www.rayvertex.com
65 stars 2 forks source link

toon_outline_width of 0 should result in no outline #8

Open WilliamTylerBradley opened 2 years ago

WilliamTylerBradley commented 2 years ago

When using the material_list function with type = "toon", I think having toon_outline_width = 0 should result in no outline. Instead, it makes all the objects red. I didn't see another option to remove the outline, but I might have missed it.

remotes::install_github("tylermorganwall/rayvertex")
#> Skipping install of 'rayvertex' from a github remote, the SHA1 (f1c3289f) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(rayvertex)

# Example works like the documentation
set.seed(1)
col = hsv(runif(1))
scene = sphere_mesh(position=runif(3),
                    material=material_list(diffuse=col, type="toon",toon_levels = 3, 
                                           toon_outline_width = 0.025,
                                           ambient=col,ambient_intensity=0.2),radius=0.1)

for(i in 1:30) {
  col = hsv(runif(1))
  scene = add_shape(scene, sphere_mesh(position=runif(3),
                                       material=material_list(diffuse=col, type="toon",toon_levels = 3,
                                                              toon_outline_width = 0.025,
                                                              ambient=col, ambient_intensity=0.2),
                                       radius=0.1))
}

rasterize_scene(scene,
                light_info=directional_light(direction=c(0.5,0.8,1)),
                background = "white",fov=10)
#> Setting `lookat` to: c(0.53, 0.49, 0.50)

# set toon_outline_width = 0
# I'd expect this to be the previous image with no black outlines on the spheres
# but it makes all of them red instead?
set.seed(1)
col = hsv(runif(1))
scene = sphere_mesh(position=runif(3),
                    material=material_list(diffuse=col, type="toon",toon_levels = 3, 
                                           toon_outline_width = 0,
                                           ambient=col,ambient_intensity=0.2),radius=0.1)

for(i in 1:30) {
  col = hsv(runif(1))
  scene = add_shape(scene, sphere_mesh(position=runif(3),
                                       material=material_list(diffuse=col, type="toon",toon_levels = 3,
                                                              toon_outline_width = 0,
                                                              ambient=col, ambient_intensity=0.2),
                                       radius=0.1))
}

rasterize_scene(scene,
                light_info=directional_light(direction=c(0.5,0.8,1)),
                background = "white",fov=10)
#> Setting `lookat` to: c(0.53, 0.49, 0.50)

# set toon_outline_width = -0.025
# This gets the desired result, but feels hacky
set.seed(1)
col = hsv(runif(1))
scene = sphere_mesh(position=runif(3),
                    material=material_list(diffuse=col, type="toon",toon_levels = 3, 
                                           toon_outline_width = -0.025,
                                           ambient=col,ambient_intensity=0.2),radius=0.1)

for(i in 1:30) {
  col = hsv(runif(1))
  scene = add_shape(scene, sphere_mesh(position=runif(3),
                                       material=material_list(diffuse=col, type="toon",toon_levels = 3,
                                                              toon_outline_width = -0.025,
                                                              ambient=col, ambient_intensity=0.2),
                                       radius=0.1))
}

rasterize_scene(scene,
                light_info=directional_light(direction=c(0.5,0.8,1)),
                background = "white",fov=10)
#> Setting `lookat` to: c(0.53, 0.49, 0.50)

Sys.info()
#>                                                                                                 sysname 
#>                                                                                                "Darwin" 
#>                                                                                                 release 
#>                                                                                                "21.5.0" 
#>                                                                                                 version 
#> "Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101" 
#>                                                                                                nodename 
#>                                                                                            "Tylers-MBP" 
#>                                                                                                 machine 
#>                                                                                                "x86_64" 
#>                                                                                                   login 
#>                                                                                                  "root" 
#>                                                                                                    user 
#>                                                                                          "tylerbradley" 
#>                                                                                          effective_user 
#>                                                                                          "tylerbradley"

Created on 2022-06-08 by the reprex package (v2.0.1)