Office Diwali Decoration : Augmented Reality Experience (using Google’s ARCore)

Prathamesh Sawant
Nov 2 · 4 min read
Office Diwali Competition + Google ARCore = Diwali AR Experience 😈

Diwali: What is it ?

Diwali, Divali, Deepawali or Dipavali is the festival of lights which symbolises the spiritual “victory of light over darkness, good over evil and knowledge over ignorance”. It is one of the most widely celebrated festivals across India.

How is it celebrated ?

During the festival, Hindus, Jains and Sikhs illuminate their homes, temples and work spaces with diyas, candles and lanterns in India

How do workplaces in India celebrate diwali ?

Most companies in India they conduct a diwali decoration competition by forming groups.

…. and so did the company for which I work for.

This served as a great opportunity to explore google’s amazing arcore library and also to win the competition. 😎

Complete view

Augmented Image module of ARcore was used to place 5 objects in the frame.

  1. Clay pot/ Diya — 3D Object (@ 00:06)
  2. Wall Decoration 1 — PNG Image (@ 00:25)
  3. Latern / Kandil — 3D Object (@ 00:44)
  4. Rangoli — PNG Image (@ 01:08)
  5. Wall Decoration 2 — PNG Image (@ 01:41)

Major/Minor Challenges:

1) To show a overlapping png/jpeg image on Augmented Image — refer to the above video @ ( 00:25 , 01:08, 01:41)

Option 1

ViewRenderable ❎: ImageView as a layout. Resulting image seen in the frame is not smooth and is pixelated. Easiest but not worth.

Option 2

ShapeFactory + MaterialFactory + Texture.Builder

In 3D World, you always start with a cube/sphere and then you add material to it. Material can have a color or a texture. (I am not sure if it can have both 🤔)

So in order to achieve our goal we need a flat cube (size : y = 0F ). Next we need a material which can be transparent and has capabilities to accept a texture. Texture is nothing but layer of paper with which we intend to wrap the cube which in our case is the image. Following approach has been used in the above code.

  1. Create Texture by passing bitmap( png/jpeg image).
  2. Create Transparent Material with texture from Step 1
  3. Finally create a Cube and apply material from Step 2
  4. Use the cube as ModelRenderable and set it to your Anchor.

This implementation results in smooth image overlapping the augmented image. Worth the time.

2) Finding your theme/requirement specific 3D Models

What is the point of having an AR Experience with no 3D models ? It was difficult for me to find a free 3D model of diya( A small lamp usually made out of clay and lit using oil and a cotton thread). There isn’t much of 3D Models available directly as per your requirements.

So this gave me an amazing opportunity to learn a 3D Model Sofware Blender and create a 3D Model by myself. It is a free and open-source software. Once you have created your 3D model then you can export the .obj file and use it in Android Studio.

Diya 3D Model preview:

It was fun to learn blender ! Definitely worth.

3. ARCore backward compatibility 😶

Unfortunately, it is not supported in all devices. ARCore requires

  • Android 7.0 or later (some models require newer versions)
  • A device that originally shipped with the Google Play Store
  • Internet access, in order to install or update Google Play Services for AR

Complete Info: supported-devices

Project Source:

There isn’t much in the code. Google’s ARCore has handled most of the challenging task for you. If you follow their tutorials and sample code you will be fine. It is just the 3D models that you need to take care of and is the only challenging part of creating an AR application.

3D Models:

  1. Lantern : https://grabcad.com/library/aakash-kandil-skylamp
  2. Diya :

Conclusion

  • Google ARCore — Sky’s the limit.
  • 3D Models should be planned properly before starting with the development.

Augmented Images is just not the only part of ARCore there is so much more but this module did serve my needs and I was able to create all of this which included learning ARCore, Blender and creating the android application in 4 days.

A bit off AR: Another Project that I developed and used in the competition

Thank you for using your precious time to reading this article. I hope it helped you understand a different use case of using Augmented Reality. If you liked this article clap your 👏 to say “thanks!”.

Prathamesh Sawant

Written by

Full Stack Developer | Designer | Gamer | My Portfolio : http://pratham.xyz