镜花水月 Kyōka Suigetsu: Fower in the miror, moon on the water
This Unity project is for achieving the aesthetics above that is visible but cannot be touched and cannot be described in words.
Unity 2022.3.17
Universal RP 14.0.9
AR Foundation 5.1.2
Apple ARKit XR Plugin 5.1.2
(optional, stable diffusion function required) Newtonsoft Json 3.2.1
Stencil function can be achieved through Renderer Feature
in Universal Renderer Data
to create portal effect. Through each portal the specific gameobjects can be seen and the maximum quantity of portals is 15 due to Universal Renderer Data
.
Assets/RP/ArPortal_Renderer.asset
Filtering\Opaque Layer Mask
Portal n and InWorld n should be unchecked.
Filtering\Transparent Layer Mask
Portal n and InWorld n should be unchecked.
Portal n\Event
BeforeRenderingOpaques
Portal n\Filter\LayerMask
Portal n
Portal n\Overrides\Stencil
Checked
Portal n\Overrides\Value
n
Portal n\Overrides\Compare Function
Equal
Portal n\Overrides\Fail
Replace
World n\Event
AfterRenderingOpaques
World n\Filter\LayerMask
World n
World n\Overrides\Stencil
Checked
World n\Overrides\Value
n
World n\Overrides\Compare Function
Equal
Layer
of gameobject
portal should be set to Portal n and gameobject
masked by the portal should be set to World n.
AR user can walk through the portal with AR device from AR experience to VR experience.
PortalDoor.csharp
as the component of gameobject
Portal which is the child of gameobject
Portal Door.
Innerworld
gameobject
should be the parent of all thegameobject
inside the portal, everything will be automatically controlled.
In World Layerint
should be the number oflayer
InWorldN.
Out World Layerint
should be the number oflayer
OutWorldN.
specific gameobject
such as the blue ball in the scene can move through the portal from inner world to outer world.
PortableObject.csharp
as the component of gameobject
Portable Object which is the child of gameobject
InnerWorld.
Innerworld
gameobject
should be the parent of all thegameobject
inside the portal, everything will be automatically controlled.
In World Layerint
should be the number oflayer
InWorldN.
Out World Layerint
should be the number oflayer
OutWorldN.
Show how to use both Stencil and Depth buffer to make object halfway through the portal door.
ArUrp.assets Universal Render Pipline Assets
's Depth Texture should be turn on
DepthMask.shader
The shader
of Depth Mask gameobject
to mask object
SetRenderQueue.cs
The script
Depth Mask gameobject
to force the render queue of depth mask
Queue Element0 should be 1980
Animated Model
used in this project Animated 3D Tyrannosaurus Rex Dinosaur Loop by LasquetiSpice is licensed under Creative Commons Attribution.
Dome Slider has a slider
in the right side of the screen which can be used to fade in and out gameobject
Dome.
DomeSlider.shadergarph
The shader
of Dome's material
Skybox Texture
Texture2D
a HDRI texture
SmoothnessFloat
for better edge between skybox texture and reality world
DistanceFloat
strength of VR
DomeSlider.csharp
on gameobject
Dome
Slider
Slider
control the level of transition of skybox
Skybox texture of the dome can be transited by a button and the name of the skybox should be shown in a inputfield which can be prompt input area for AIGC such as Skybox AI Generator by Blockade Labs.
DomeTransition.csharp
on gameobject
Dome
Textures
List<Texture2D>
HDRI textures
Switch ButtonButton
switch to next skybox
Input FieldInputField
Initial Transition Speedfloat
main transition speed
Accelerationfloat
the accelaration that when fade out will speed up transition and speed down when fade in
Maximum Transition Speedfloat
for better user experience during transition
Minimum Transition Speedfloat
for better user experience during transition
This sample upgrade Dome Transition into a AIGC project that you can type prompt to have AI generated skybox texture on the dome.
- Stable Diffusion WebUI is required. I have made a basic Unity project RuntimeSD for using stable diffusion in realtime through the app you build to connect with your stable diffusion API. You can follow the instruction to install SD.
- Adding
Launching Web UI with arguments:
--api
--share
to the command line options inwebui-user.bat
will generate a random share link that is displayed in the command window, that you can fill inDomeTransition_RuntimeSD.csharp
'sUrl
. - 360 Diffusion LoRA is required for Stable Diffusion in this project. This LoRA model should be put in ..\webui\models\Lora.
DomeTransition_RuntimeSD.csharp
on gameobject
Dome