Deadline: June 19 (Thu) at 15:00pm
If you have not installed Unity & Blender on your computer, install them if they are not installed on your computer.
First, update your local repository.
$ cd pba-<username> # go to the local repository
$ git checkout main # set main branch as the current branch
$ git branch -a # make sure you are in the main branch
$ git fetch origin main # download the main branch from the remote repository
$ git reset --hard origin/main # reset the local main branch same as remote repositoryIf you encounter some errors, give up updating your local repository and restart from the remote repository. In other words, clone the remote repository in a new location (see task00 for cloning).
Create the task07 branch and set it as the current branch.
$ git branch task07 # create task07 branch
$ git checkout task07 # switch into the task07 branch
$ git branch -a # make sure you are in the task07 branchNow you are ready to go!
Do the following procedure (mostly similar to task06).
- In the
UnityHub, make a new Unity project namedtask07underpba-<username>/task07. - You will see project related folders like
pba-<username>/task07/task07/Assets.
- Add a 3D plane by left click menu in the
Hiearchywindow (top-left),3D Object>Plane. - Make sure the position of the plane at
(0., 0., 0.) - Keep the other parameters default (e.g., scale is
(1., 1., 1.))
- Set the position of the
Main Camerato(0.0, 0.8, -1.8). - Keep the other parameters default (Field of View is
60). - Set the window resolution to
300x300.
- Import the
pba-<username>/task07/annulus.objto the asset by dragging it into theAssetswindow (bottom). - Click
annulusprefab in theAssetswindow. You will seeinspectorwindow on the right. In theModeltab, enableRead/Writecheckbox. - Import the
annulusPrefab to the scene by draggingannulusin theAssetswindow (bottom) to theHierarchywindow (top-left). - In the
Hierarchywindow, clickdefaultGameObject under theannulusprefab. - Set the position of the
annulusto(0.0, 1.3, 0.0). Make sureannulus > default's position is(0., 0., 0.).
You do not see the annulus objet in the Game window (center) because default material do not show the back side of the faces. Let's fix it by creating new material.
- Make a new material by selecting the right click menu in the
Assetswindow (bottom)Create > Rendering > Material. - Click the
New Materialin theAsssetswindow (bottom) to showInspectorwindow (right) - Set the material color red by click the
Base Mapand set the RGB color as(255,0,0). - Click the
Render Facepull down manu inSurface Optionsand selectBoth - Drag the
New Materialto theannulus > defaultin theHiearchywindow (left).
- Add a sphere collider component to the GameObject,
annulus > default, by clicking "Add Component" in theinspectorwindow of theannulus > defaultGameObject. - Set the radius of the sphere collider to
0.31
- Drag following CSharp codes to the
Assetswindow.pba-<username>/task07/MyCloth.cspba-<username>/task07/TopologyOfUniformMesh.cspba-<username>/task07/BlockSparseMatrix.cspba-<username>/task07/ObjExporterToAssets.cs
- Attach
MyCloth.csin theAssetswindow to thedefaultGameObject in theannulusPrefab.
This program means to compute dynamic animation of a skirt as a mass-spring system. The program uses the variational Euler's method to compute implicit time integration. The variational problem is solved using the Newton's method.
The current code does not compute the hessian of the elastic energy of the spring very accurately so the simulation is unstable.
write code to correctly compute hessian of a spring. node2vtx[i_node] stands for spring's end positions.
When the return hessian can be written as float3x3[3][3] w, w[i_node][j_node] stands for Jacobian of energy gradient for i_node's position w.r.t j_node's position.
Write a few lines of code around line #140 in the pba-<username>/task07/task07/MyCloth.cs to compute hessian accurately.
- Make sure the window resolution to 300x300.
- Set up the
Recorderpackage for screenshot video (see the Lecture Material about Unity) - Capture the screen from 0th to 300th frame.
- Rename the screenshot image and place it as
pba-<username>/task07/problem1.gif
Write down the energy value at the 300th frame shown in the Debug output in the Console window
| energy at 300th frame |
|---|
| ??? |
In the previous step, you animate a mesh of cloth.
Play the Unity project for more than the 500th frame, then you will see pba-<username>/tas07/task07/Assets/MyCloth.obj.
Let's visualize the mesh nicely using Blender.
- Launch Blender.
- You will see a default cube in the
3D viewportwindow. Remove it byxkey or right click menuDelete. - Save the project somewhere outside the repository.
- See the image below for the name of the windows in Blender.
- In Blender, import the
pba-<username>/tas07/task07/Assets/MyCloth.objby selecting the menuFile > Import > Wavefront (.obj). - Make sure the
MyCloth.objis successfully imported and shown in the3D Viewportwindow.
- Select
Camerain theOutlinerwindow. - Select
Objecttab in thePropertywindow. - Set the camera transform as Location:
(X:0m, Y: 5m, Z: 1m), Rotation:(X:90deg, Y: 0deg, Z: 180deg), ModeXYZ Euler, Scale:(1.0, 1.0, 1.0). - Press
F12key to see the rendered result, making sure theMyCloth.objis rendered around the center of the image.
- Select
Outputtab in thePropertywindow. - Set the Resolution X as
400 px, Resolution Y as300 px. - Press
F12key to see the rendered result.
- Split the window into two. You can do this by dragging the corner of a window (see Blender how to split screen and remove split screen @ blenderrian ).
- In the right
3D Viewportwindow, press the buttonEditor typein the top-left corner, and select theShader Editor. - At the top of
Shader Editorwindow click a dropdown menu showingObject. Change the data fromObjecttoWorld. This is necessary to work with environmental textures.
- Go to Polyhaven (https://polyhaven.com/hdris), download HDR image such as https://polyhaven.com/a/golden_gate_hills. Download with 1k image with EXR format. Save it somewhere outside the repository.
- In the
Shader editornode, pressShift + Ato bring up theAddmenu. - Navigate to
Textureand then chooseEnvironment Texture. - The
Environment Texturenode is created, but it won't show anything unless you connect it to the shader system. - Connect the
Environment Texturenode to theBackground shadernode by clicking and dragging theoutputof theEnvironment Texturenode (the yellow dot) to theinput(the green dot) of theBackgroundshader node . - In the
Environment Texturenode, click theOpenbutton. - Select the HDR image you saved on your computer.
- If the instruction is difficult to follow, watch The ULTIMATE GUIDE to HDRI Lighting in Blender! @ CG Essentials.
- Select
MyClothin theOutlinerwindow. - Select
Materialtab in thePropertywindow - Select
Newin thePropertywindow. - Set
Base Coloras(Red: 1.0, Green: 0.0, Blue: 0.0),Metallicas0.3, andRoughnessaround0.2.
Finally, press F12 key to see the rendered result. In the Blender Render window, save the image as pba-<username>/task07/problem1.png.
The image needs to be shown below.
After modifying the code, push the code and submit a pull request.
- Please leave the project files under
pba-<username>/task07/task07/. The.gitignorewill ignore the unnecessary intermediate binaries. - The lecture do not explain detail of Unity and C#. Find your self on the internet or using chat AI (e.g., ChatGPT).
- Do not submit multiple pull requests. Only the first pull request is graded
- Do not close the pull request by yourself. The instructor will close the pull request
- If you mistakenly merge the pull request, it's OK, but be careful not to merge next time.












