Components that take Transform values and output them to Custom Shader properties/Animator parameters?
Smash-ter
This is something that feels like has been lacking for a good while, but having components that could take vectors of a transform property and output them to either a custom string for either a material property or an animator parameter to use. The implementation would be similar to how Physbones allows creators to use custom strings to name parameters that the animator will use and output specific animation reactions depending on the value.
Example for the animator:
Rotation Offset:
- There's one feature that Blender has that Unity lacks, and that is using corrective shape keys. Corrective ShapeKeys is a thing in Blender that lets users use bone transform angles to correct deforming mesh based on the angle. So you could bend your elbow in a specific way without needing to redo your weight paints or mesh topology. You could limit the angle of influence of how far the rotation can go for the blendshape amount within the driver itself in Blender.
Positional Offset:
- Similar case to the above, you could also use a child of an empty game object to control how blendshapes look dependent on the child object's transform positional offsets relative to the parent object. If I say dragged a ball that was in world space to the left, I could make the face look angry, or make a character on the screen of a prop on my model move to the left.
Examples for shader properties:
Vectors, Floats, and Colors:
- Genshin Impact, love or hate it, is a decent game with an interesting shading style, especially with how they do their facial shadows. HoyoVerse uses SDFs to achieve this effect by getting the forward and right vectors of the head bone to determine the lighting angle along a gradient, and flip the gradient depending on specific conditions. The problem is the only method of doing this within Unity is to change the root bone of a skinned mesh renderer to the head bone rather than the hip bone, which is bad for those that want to have a consistent bounding box across all meshes and for shaders that manipulate the vertices of the skinned mesh. A way to solve for this would be to have a component that could output the forward, right, and even upward vectors to a custom string for a material property to read from and inherit the transform values of. Alternatively you could also output the transform positions for proper dissolve effects or for motion capture based systems that use colors to output, or to even give a good wobble effect/get the volume of a glass bottle for a liquid shader, or have it magically fill up.
If possible, this could also be an extension to the Avatar Dynamics, and it could also be implemented into PhysBones for the transforms, but having this be extended to other use cases like the ones mentioned would be extremely helpful and possibly more optimized than using lights + depth tricks, CRTs + Cameras on our avatars, or whatever jank and unoptimized methods we use for our creations.
Log In
Smash-ter
So I thought it over on how this would work on the editor side.
For Animator Parameters:
- The application would be similar to how Physbones and Contacts have a string input that will associate the string with a parameter along the lines of stringName + "_AssociatedValue";
- Rotation and Position Values are based on the offset relative to the bone or game object it's applied to at rest. 2 types will be associated for the animator in this scenario _RotXAtRestand_RotXOffestfor the X rotation value. These would be float parameters and do not require a sync parameter to work. This would be useful for replicating Driver functions from Blender, especially the Corrective Blendshape functions so avatars don't need to be high poly to have proper deforms.
- This should be applied to Rotation and Position values.
For Shader Properties:
- Similar to the function of Physbones or Contact but a tad stricter in application. For the string input it would have to be "_" + stringName + "_VRCPropertyName".
- The VRC Shader properties are applied relative to the offset of the root bone of the skinned mesh. If this were to be applied to the future VRC Constraints I'd recommend having it be tied to either the Parent Constraint or have it possibly be tied to a different component altogether.
- Functions available to the shaders relative to the source object would be:
-- (float3) _VRCForward (forward vector)
-- (float3) _VRCRight (right vector)
-- (float3) _VRCUp (up vector)
-- (float3) _VRCPosition (position values)
-- (float3x3) _VRCQuaternion (quaternion based rotation values)
-- (float3) _VRCEuler (euler rotation values)
-- (float3) _VRCScale (scale values, may or may not be as useful)
-- (float4x4) _VRCMatrix (full matrix values)
stereofoxmuviz
This would be so helpful to do lighter advanced shading effects without the need of cameras or grabpass, i really hope this gets added
Zеkk
This please please please. I am most interested in the use case for shaders. Being able to feed the shader a position value based on an arbitrary gameobject would be actually amazing.
As mentioned current workarounds are clunky, un-performant, and very limited.