Here we briefly explain how we implemented the application of paint on a workpiece and the simulation of running paint if to much paint was applied. The paint application is based on the Asset ProjectionSpray. CustomDrawingController, CustomSpotDrawer and CustomDrawables which are described in the following are custom versions of the corresponding scripts provided by the asset.
-
The starting point is the
CustomDrawingControllerwhich is extended by theSprayGunwhich calls theDrawmethod every frame while the trigger of the spray gun is pressed. In theDrawmethod theCustomSpotDraweris used which can be imagined as a spot light pointing on the workpiece and adds paint on the respective areas of the workpiece every frame. The paint applied to the workpiece is controlled by thecookiewhich is an image defined in thePaintController. In our case thecookieis shaped like an ellipse which is the normal spraying pattern of a spray gun. TheDrawmethod in theCustomDrawingControllerscales the cookie in dependence of the speed of the spray gun. Otherwise there would be gaps between to cookie applications because the frame rate is limited. -
The
CustomSpotDrawercalls theDrawmethod in theCustomDrawablescript which is added to every workpiece. Here a texture is created (heightmapOutput) presenting the thickness of the coat for the different areas of the workpiece. The paint thickness is encoded in the 4 color channels. r is the thickness of the paint applied from a range further away than the maximum spraying distance (defined in the coat), g is the thickness of the paint applied from a range closer than the minimum spraying distance, b is the general thickness of the paint but reduced on greater distances, and a is the general thickness of the paint independent of the distance. In a prior state of the application the r and the g channel were used to visualize the dominant spray distance on the workpiece. This was removed and now the a channel is used mainly. -
Once every
FixedUpdatetheUpdateWorkpiecemethod of theCustomDrawablescript is called. Here the surface of the workpiece is controlled in dependence of the heightmap texture. That means color, metallic strength, occlusion and the roughness is calculated with the help of shaders. -
At the end of every
FixedUpdatewe also calculate the running paint in theSimulatePaintRunmethod which modifies the heightmap texture. The paint thickness encoded in a pixel is influenced by the neighbouring pixels. To determine the neighbouring pixel the orientation of the workpiece is considered. For implementation details see theSimulateDripshader.