Thursday, 7 November 2024

VR Project Week 3

Getting the Thematic Hand Pose to work

    Finally went ahead and put in the thematic pose for Megara's hands and it wasn't as bad as I was expecting. 
    First you have to create an input action asset for both hands. 


 Its a digital bool for the value type, I don't think I changed anything else from here. Next you have to go into one of the IMCs (input mapping controls), I should have done this in hands but I did it in Default. Add them both to the mappings and make sure to add the buttons you want from the occulus to work with it. This is what maps the action to the buttons. 

    Now we can go into the VRPawn blueprint. In the event graph type in the name you gave to the input action. it should pop up like this:
    Now we need to set up our animation blueprint to play the animations. Since my thematic pose used all of the joints in the hand, I just used a blend node instead of a layered blend per node to make it easier.
    
    
    Now, depending on which buttons you choose to map the pose to, you may have to create two different variables in your animation blueprint. Since I had mapped it to the A and X button, the controls only returned a 0 or a 1, on when you press the button, off when you release. So we need to create a blend for it to interpolate smoothly to the new pose. This is what the template blueprint was doing with the index point and the thumb up pose in the event graph. 

    In the VRPawn, it sets the variable 'pose alpha thumb up' to 0 or 1 depending on the context. With that, we use a FInterp To node to smoothly interpolate another variable, 'current pose alpha thumb up', to 0 or 1. 

    For me I made two variables, the Pose Theme and the Current Pose Theme. 
The VRPawn blueprint sets the Pose Theme variable, and we use that to set the Current Pose Theme variable for the animation blueprint. 
    The VRPawn Blueprint is set up like how we have the previous hand animations, casting to the animation blueprint, and then setting the variable. I used specifically the triggered event to set it to 1, and then the canceled or completed event set it to 0. 
    That's all there is to it. 

 Breaking Vases

 Resources that I used to figure this out:
    Real-time destruction with Houdini and Unreal by Simon Houdini Part 1 (Part 2 is here) NOTE: these videos are specifically for Unreal's realtime destruction plugin, apex destruction. However, this plugin has been replaced in UE5 by Chaos destruction. Ultimately we decided against this, instead we're doing all the simulations within Houdini exporting that out, and then playing those animations inside of unreal depending on a collision box hit. 
    Pre-Baked Destruction in Unreal Engine by Simon Houdini NOTE: this is the one that helped out t
    
    Had to edit the base geometry of the vases so there were no holes. Started out with adjusting it to a smaller scale for better performance, and then created a remesh node to increase the amount of vertices. I noticed when I used it it caused some of the smaller details like the lip of the vase to be softened, so I added a group node, grouped by 'include by edges' and adjusted the min edge angle so I'd get only hard edges. 
GroupNode settings, named it hard_edges


    Then in the remesh node I added the group I made to the hard edges group attribute. From there I added a uv_transfer node along with a normals node to finish readying up the mesh for fracturing. 

Needed to add the uv_transfer node so uvs were preserved from the remesh

    For the fracturing, there are three ways of doing it (found by Simon Houdini's tutorial). 
    First way is just using the rbd material fracture node. This is the one I used here since it was the simplest and worked well for what I needed. I kept the noise type as Perlin Noise. Beyond-FX's tutorial goes further to use the detail> Edge Detail to make the inside faces similar to how rocks would break open with noise. I didn't need this since it was a vase and the insides should be smoother. 
    The next way is to use a scatter node with a voronoi fracture node to create fractures. I didn't use this one since the fractures did look like voronoi cells. There are ways to adjust this, such as using an attribute paint node, painting in a mask for the scatter node (disable for total count, and turn on density attribute and change it to the name you use for the attribute paint). I didn't need to go to indepth for this so this wasn't necessary. But it is cool.
    For the third way: you can use a drawing node to make lines, fuse points on that lines to make it smoother, add a sweep node to make a ribbon geometry, and then use a boolean fracture node to cut pieces into the geometry. 
From Simon's real time destruction part 2 video
    Afterwards I needed to quickly UV the inside faces the fracture made, so I just used a uv auto seam, uv flatten, and then uv layout node. Make sure the group for the uv flatten and layout is 'inside' (the rbd material fracture node automatically makes 'inside' and 'outside' groups for you). Uv flatten node's flattening constraints make sure to have 'seams' inside of the Seams attribute. 


    Next creating two materials for the inside and outside faces. This one isn't entirely necessary since we have our own materials inside of Unreal but I included it anyway. 

    Next an assemble node. Make sure that 'create packed primitives' is checked on. This makes it so the fractures are now points instead of geometry, which helps speed up processing (more on packed geometry here). Add a rbd bullet solver node, turn on a ground plane (Collision>ground collision), and you can simulate. I added a transform node to get it back to scale and then a Null node to make it easier when exporting. 

    Now this creates a very basic simulation of a vase falling apart. We can change which direction the vase falls by using a sphere, generating point normals, and then multiplying those normals by a parameter we create called 'speed' and assign that to the velocity attribute (this was taken from the Simon Houdini tutorial with prebaked simulations).
The add node was just used for visualizing the geometry as points, you don't need it in the end

    First create a sphere node, change it to a polygon and increase frequency to get more faces. This sphere will be used to get normals that point outward from a single point. Then I added a transform node to translate and rotate where I want my 'explosion' to occur. Then add a normal node, make sure 'add normals to' = 'points'. 


    Then add an attribute transfer node to transfer these normals to the geometry, then add an attribute wrangle node. Add the VEXpression:
 @v = @n *ch("speed")*rand(@ptnum);
    The @ptnum expression is the point number, using it with a random function will make it so that each piece won't fall at exactly the same speed. 

    Putting this into the rbd bullet solver will change the way the simulation goes. This makes it easier to control where the fractures fall from. 
    After the rbd bullet solver I also added a labs retime node because looking at it in real time it seemed a bit slow in the beginning. 
Used the round option for the ramp
Note: when importing into Unreal, make sure that normal import method is 'import normals and tangents'.
    Putting it into a blueprint was easy, just play animation upon collision. I had experimented with only playing the animation if a spear touched it, but I'd rather anything be able to break it.


Simulating the vase on top of a pillar

    We have a couple vases on top of pillars for players to throw spears at. Because of this I have to set up the simulation for the column to be a collision object, as well as have the vases above the ground so the pieces can fall. For this I imported an fbx of the pillar I wanted to use to sim, scaled and rotated to the correct sizr.

Because we have pillars with varying heights, I have to simulate this several times with the varying heights of the pillars. But for now, I'm going to focus on the smallest pillar. I wanted to create a set up so that I could plug in any pillar of any height, and houdini will procedurally move the vase to the correct height. For this, I used a VEX expression that took the height of the pillar's bounding box, and then added that to the position of the vase.




        I also used this expression with the normals sphere that controls the direction the pieces explode in. Then when the simulation is done. I use the same expression, except subtract the height from the vase so it starts at the origin. This makes it easier to place in the Unreal level. I also added the pillar as a collision object in the rbdbulletsolver node. 

Updated Hercules Rig


    Went ahead and updated the hercules skeleton with controls to make it easier to animate. Also went ahead and animated an idle and a test reactive pose for him, as well as made the animBP and BP for it.

    Also went and fixed Megara's hands by filling the hole in her forearm that lets you see inside the hands.


No comments:

Post a Comment

Shader Tool Week 4 - Post Processing

     Happens after we've rendered the main image.      A render target is a memory buffer. It's a place that you can render an image...