Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Add ray traced bump and highlights to an image
ResourceFunction["ImageRayTraceBump"][img] uses ray tracing to simulate bump shading and specular highlights based on the brightness channel of img. | |
ResourceFunction["ImageRayTraceBump"][img1,img2] simulates bump shading and specular highlights in img1 based on the brightness channel of img2. |
"BumpBlur" | 1 | radius of the blur applied to the bump map |
"BumpHeight" | 10 | how high the bump appears to be |
"EyeHeight" | 600 | how high, in pixels, is the viewer |
"LightPosition" | {-2,2,1} | where the light appears to be coming from |
"LightType" | "Directional" | what kind of light is shining on img |
"Shininess" | 5 | how reflective the surface of img appears to be |
"Directional" (default) | light hits each pixel from the same direction and then bounces towards the observer. |
"Point" | light travels from one location to each pixel and then bounces towards the observer. |
"Uniform" | light hits each pixel from the same direction and then bounces straight upward. |
Add bump to an image:
In[1]:= |
Out[1]= |
Add bump from one image to another:
In[2]:= |
Out[2]= |
In ImageRayTraceBump[img1,img2], the two images need not be the same size. If either dimension of img2 is smaller than that of img1, it reflects and tiles:
In[3]:= |
Out[3]= |
If a dimension of img2 is larger, img2 covers img1 starting in the top left corner:
In[4]:= |
Out[4]= |
The option "BumpBlur" sets the radius for the blur filter of the bump map. Values should be non-negative integers. Practical settings are 0 ≤ n ≤ 8 where n is a real number. If small features are causing too much salt-like reflections, increase this setting a little:
In[5]:= |
The option "BumpHeight" sets the apparent height:
In[6]:= |
Out[6]= |
One solution for too much glare from the light source is to increase the height of the observer via the "EyeHeight" option value:
In[7]:= |
Out[7]= |
For the default "Directional" and the "Uniform" light types, the option "LightPosition" sets the direction from which every pixel receives light. The vector is from the light position to the center of the image:
In[8]:= |
Out[8]= |
For the default "Point" light type, the option "LightPosition" sets the location from which every pixel receives light:
In[9]:= |
Out[9]= |
The "LightType" option controls how the light source behaves:
In[10]:= |
Out[10]= |
Low settings will look rough or dull; high settings will look wet or glassy. Practical values are 0≤n≤10,n∈ℝ:
In[11]:= |
Out[11]= |
Give a photo, like this of an elephant's hide, a subtle 3D realism:
In[12]:= |
Out[13]= |
Use ImageRayTraceBump as an artistic filter:
In[14]:= |
Out[15]= |
Combine two procedural images (here, a density plot and a graphic of overlapping polygons) to create snakeskin:
In[16]:= |
Out[16]= |
Animate the light position:
In[17]:= |
Out[17]= |
This work is licensed under a Creative Commons Attribution 4.0 International License