Inhale as you lower yourself down and exhale as you pull yourself up.
User
hwo i can save current uv of obejct, but moving edges - blendshapes moving uvs with vertexies, i dont wanna that
i need uvs be like triplanar but to mesh itself
whats nodes of shaderr grap i need to creating that like pin effect?
Assistant
To achieve a "pinned" UV effect in Blender's Shader Graph (also known as the Shader Editor), where you want the UVs to stick to the geometry but not deform with the edges like in blendshapes, you can use a combination of nodes to simulate a triplanar mapping effect. Triplanar mapping projects textures based on the object's world orientation, usually on the X, Y, and Z axes, and blends between them.
Here's a step-by-step guide to creating this effect:
Open the Shader Editor:
Open Blender and select your object.
Go to the Shader Editor workspace.
Create a New Material:
Create a new material or select an existing one for your object.
Add Necessary Nodes:
Add the nodes to capture the triplanar effect.
Here is a basic node setup you can start with:
Nodes:
Texture Coordinates: Provides various coordinates for mapping.
Separate XYZ: Separates the XYZ components.
Absolute: Ensures positive values.
Less Than: Compares axes to determine dominant direction.
Mix: Blends textures based on the comparison.
Image Texture: Your texture of choice.
Vector Transform: Transforms vectors to various spaces.
Combine XYZ: Combines X, Y, Z coordinates back.
Workflow:
Add a Texture Coordinate Node:
Connect the Generated output to the Vector input of a Vector Transform node set to World.
Add Three Image Textures:
Each will represent the projection on the X, Y, and Z axes.
Set up Absolute Value Nodes:
Use Separate XYZ nodes to separate the X, Y, and Z coordinates from the transformed coordinates.
Connect each output to an Absolute node to get the absolute coordinates.
Compare Dominant Axis:
Use Greater Than or Less Than nodes to compare X vs. Y, Y vs. Z, and Z vs. X to determine the dominant axis.
Blend Textures:
Use Mix Shader or Mix RGB nodes to blend between the three textures based on the dominant axis comparisons.
Example Node Setup:
Texture Coordinates Node:
Connect Object output to separate XYZ.
Separate XYZ:
Separate the coordinates, then use Absolute nodes to ensure positive values.
Image Textures:
Load your texture three times for X, Y, and Z projections.
Vector Math Node (Dot Product):
Use to blend between projections.
Combine XYZ and Use Mix Nodes:
Combine the projections using Mix nodes accordingly.
This will give a basic triplanar map visual. You can refine it by adding more detailed blending factors, smooth step nodes, and adjusting how the axis comparisons blend together for a seamless texture application.
Remember to tweak the blend settings to reduce visible seams, and test the node graph by viewing it in the material preview. This approach simulates UV sticking to the mesh like pinned, without deformation.
User
i need it in unityy
Assistant
In Unity, to achieve a similar effect to pinned UVs where the UVs do not deform with the mesh, you can use Shader Graph to implement a triplanar mapping technique. Here’s how you can set this up in Unity using Shader Graph:
Steps to Create Triplanar Mapping in Unity's Shader Graph:
Create a New Shader Graph:
Right-click in the Assets folder.
Select Create > Shader > Universal Render Pipeline > Lit Shader Graph (or the appropriate shader for your render pipeline).
Name your shader and double-click it to open it in the Shader Graph Editor.
Add a Texture Sample:
Add a Sample Texture 2D node and hook it up to the main nodes.
Texture Coordinates:
Use object space coordinates to project the texture onto the object. Add a Position node and set its space to Object.
Connect the Position node to three separate Split nodes for the X, Y, and Z coordinates.
Mask and Blend Functions:
Use Absolute nodes on each of these splits to ensure the values are positive.
Utilize Step functions to blend between axes. This will help in determining the dominant direction.
Sample Textures on Multiple Axes:
Duplicate the Sample Texture 2D node three times, one for each projection (X, Y, Z).
For each Sample Texture 2D node, modify the UV input:
For X projection, use the YZ coordinates.
For Y projection, use the XZ coordinates.
For Z projection, use the XY coordinates.
Blend the Results:
Use Lerp nodes to blend between each texture sample based on the dominant direction.
Calculate blending factors using comparisons (Greater Than) and mix the three samples accordingly.
Example Node Setup:
Position Node:
Set Coordinates to Object.
Separate XYZ Components:
Use node to extract X, Y, and Z.
User
no, u dont understand me at all
i have deformed meshs mouth by blendshapes, but moving edges and vertexeis with blendshapes moving uvs with vertexies, i wanna uv stay same world to that mesh like
for example exist world position node, but its not what i want, i want like
whats nodes of shaderr grap i need to creating that like pin effect?
Assistant
Got it, you want the UVs to remain consistent relative to the mesh in world space regardless of vertex deformation by blend shapes. You can achieve this through shader graph techniques by using the object’s world position instead of its UV coordinates. This effect can be thought of as "pinning" the texture to the mesh’s world position, ensuring that the texture does not warp with the geometry.
Here's how to achieve this in Unity Shader Graph:
Steps to Create "Pinned" UV Effect in Unity Shader Graph
Create a New Shader Graph:
Create a new Shader Graph in Unity by right-clicking in the Assets folder and selecting Create > Shader > Universal Render Pipeline > Lit Shader Graph (or the appropriate shader for your render pipeline).
Name your shader and double-click it to open it in the Shader Graph Editor.
Use World Position:
Add a Position Node and set the Space to World.
This node provides the object's world position, which will serve as the stable coordinate system for the texture.
Scale the World Position:
If necessary, use a Multiply node to scale the world position by some factor to adjust the texture tiling.
You can add a Vector3 property to control this scaling factor from the inspector if needed.
Sample Texture 2D:
Add a Sample Texture 2D node.
Connect the scaled World Position output to the UV input of the Sample Texture 2D node.
Output to Base Color:
Connect the RGBA output of the Sample Texture 2D node to the Base Color input of the PBR Master node (or equivalent in HDRP).
Example Node Setup in Shader Graph:
Position Node:
Set Space to World.
Multiply Node (Optional):
Connect the World Position output to a Multiply node.
Use a Vector3 property to control scaling (tiling of the texture).
User
no,i i just want that uv stayed same, on mesh, that vertexies dont change it
Assistant
I understand now - you want the UVs to remain static relative to the mesh, so that they do not move with vertex deformation caused by blendshapes. Essentially, you want to create a kind of "sticky" or "pinned" UV mapping that is independent of vertex positions.
You can achieve this in Unity’s Shader Graph by using the object’s original state and project the texture accordingly. This can be done using the object space position or using a method similar to triplanar projection but locked to the UVs in the object's local space.
Here's how to achieve this:
Steps to Pin UVs in Unity Shader Graph
Create a New Shader Graph:
Create a new Shader Graph in Unity by right-clicking in the Assets folder and selecting Create > Shader > Universal Render Pipeline > Lit Shader Graph (or the appropriate shader for your render pipeline).
Name your shader and double-click it to open it in the Shader Graph Editor.
Use Object Position:
Add a Position Node and set the Space to Object.
This node provides the object's local position, which will serve as the stable coordinate system for the texture.
Scale and Offset the Position:
Use a Multiply node to scale the object position to control the tiling of the texture if necessary.
Use an Add node to apply any offset as needed.
Sample Texture 2D:
Add a Sample Texture 2D node.
Connect the scaled and offset Object Position output to the UV input of the Sample Texture 2D node.
Output to Base Color:
Connect the RGBA output of the Sample Texture 2D node to the Base Color input of the PBR Master node (or equivalent).
Example Node Setup in Shader Graph:
Position Node:
Set Space to Object.
Multiply Node (Optional for Scaling):
Connect the Object Position output to a Multiply node.
User
This method ensures that your texture remains “pinned” to the object’s original local coordinates, making it unaffected by vertex deformations or blend shapes. The texture will follow the object’s local space but won’t distort with the vertex positions
yes, its what i wanna
but its not workin
there exist vertex inputs and fragments input
i paste sample texture node to base color input
its workin like typical material, blendshapes still moves uv
Assistant
To ensure the UVs remain "pinned" to the object and do not move with vertex deformations caused by blendshapes, you need to use the object’s world position (or a similar attribute that remains constant during vertex movements) rather than using its UV coordinates. Let's set this up properly in Unity’s Shader Graph.
Here’s an explicit and detailed guide using Unity’s Shader Graph to achieve the desired "pinned" UV effect:
Steps to Pin UVs in Unity Shader Graph
Create a New Shader Graph:
Create a new Shader Graph in Unity by right-clicking in the Assets folder and selecting Create > Shader > Universal Render Pipeline > Lit Shader Graph (or the appropriate shader for your render pipeline).
Name your shader and double-click it to open it in the Shader Graph Editor.
Use Object’s World Position:
Add a Position Node and set the Space to World.
This node provides the object's position in world space, which remains consistent during vertex deformation.
Convert World Position to Object Space:
Since world space can cause unwanted transformations due to object movements, use the Transform node to convert world space to object space.
Add a Transform node, set From as World and To as Object.
Scale the Position (Optional):
If needed, use a Multiply node to scale the object position to control the tiling of the texture.
This is optional but allows for better control over how the texture maps to the object.
Sample Texture 2D:
Add a Sample Texture 2D node.
Connect the transformed and possibly scaled position output to the UV input of the Sample Texture 2D node.
Output to Base Color:
Connect the RGBA output of the Sample Texture 2D node to the Base Color input of the PBR Master node (or any equivalent final output node, depending on your render pipeline).
Example Node Setup in Shader Graph:
Node Configuration:
User
okk previous answerr works, but my uv is like not exist
my local mesh was having own uv, not its broken, but local tiling workin
i use just position node - object
paste it to sample texture 2d uv
then sample texture 2d to base color
works, but original uv not showngs
Assistant
Great, I understand the issue now. When you connect the object position directly to the UV input, it effectively bypasses the original UVs set in your 3D modeling software. What you need is to use the original UVs for the base texture mapping while using the object position to alter it in a stable manner.
To achieve this, you can blend the original UVs with the object position. Here's how you can set this up in Unity Shader Graph:
Steps to Use Original UVs with Object Position for Stability
Start with the Base Shader Graph Setup:
Open your Shader Graph.
Retrieve Original UV Coordinates:
Add a UV node which will give you the original UV coordinates of your mesh. This way, the original texture mapping is preserved.
Retrieve Object Position in Object Space:
Add a Position Node and set the Space to Object.
Combine Original UVs with Object Position:
Use a Lerp node (a type of linear interpolation node) to mix the original UV coordinates and the object position. This way, you can control the influence of both the UVs and the object's stable local coordinates.
Scale and Offset the Object Position (Optional):
If needed, use a Multiply node to scale the object position coordinates for better control.
Add an Add node to apply any offset if necessary.
Sample Texture 2D:
Add a Sample Texture 2D node and connect the output of the interpolation to the UV input of this node.
Output to Base Color:
Connect the RGBA output of the Sample Texture 2D node to the Base Color input of the PBR Master node.
Example Node Setup in Shader Graph:
Node Configuration:
UV Node:
Provides the mesh's original UV coordinates.
Position Node:
Set to Object space to provide stable object-based coordinates.
User
yea
again vertexies move uv
lerp broke its
Assistant
I understand that the Lerp approach is not working as intended and that the vertex deformation is still affecting the UVs. Let's simplify the approach and ensure the UVs remain stable by using only the object's local or world position for UV mapping without any blending. This method will ensure that the UVs are entirely independent of vertex movement.
Here's the correct setup in Unity Shader Graph:
Correct Setup to Pin UVs with Object/World Position
Create a New Shader Graph:
Create a new Shader Graph in Unity by right-clicking in the Assets folder and selecting Create > Shader > Universal Render Pipeline > Lit Shader Graph (or the appropriate shader for your render pipeline).
Name your shader and double-click it to open it in the Shader Graph Editor.
Use Object's World Position:
Add a Position Node and set the Space to World.
This node provides the object's position in the world space, which does not change with vertex deformation.
Adjust Position for Tiling (Optional):
If you need to control the tiling of the texture, use a Multiply Node.
Add a Float Node or Vector3 Node (depending on your need for uniform or non-uniform scaling) to control the tiling.
Connect the Multiply Node to the Position Node output and the Float or Vector3 Node (tiling factor).
Sample Texture 2D:
Add a Sample Texture 2D Node.
Connect the output of the Multiply Node (if used) or the Position Node directly to the UV input of the Sample Texture 2D Node.
Output to Base Color:
Connect the RGBA output of the Sample Texture 2D Node to the Base Color input of the PBR Master Node (or equivalent final output node).
Example Node Setup in Shader Graph:
Node Configuration:
Position Node:
Set Space to World.
Not yet included in a published release.
Split
Absolute Values:
Use Absolute node on each component.
Sample Texture 2D for Each Axis:
Three Sample Texture 2D nodes with their UVs modified:
For X: (Y, Z)
For Y: (X, Z)
For Z: (X, Y)
Mask Functions and Step Nodes:
Calculate blending masks using Step or similar comparison nodes.
Lerp Nodes:
Use Lerp nodes to blend between the three sampled textures based on the blending masks.
Final Assembly:
After setting up the respective nodes for projection and blending, connect the final color output from the Lerp node to the Base Color input of the PBR Master node (or equivalent).
This setup simulates triplanar texturing in Unity's Shader Graph, projecting the texture from three orthogonal directions and blending them seamlessly to avoid deformation during mesh modifications.
Unity Shader Graph Example:
plaintext
Position (Object) > Split (X, Y, Z)
X > Absolute
Y > Absolute
Z > Absolute
Separate X > Sample Texture2D (YZ UV)
Separate Y > Sample Texture2D (XZ UV)
Separate Z > Sample Texture2D (XY UV)
Compare X, Y, Z for mask, then blend using Lerp
Connect blend result to PBR Master Base Color
Make sure to tweak the blending factors and adjust seams to achieve a seamless texture projection across your object. This method essentially "pins" the UVs to the object's space like a triplanar projection.
Sample Texture 2D Node:
Connect the Multiply node output (or directly the World Position output if no scaling) to the UV input of Sample Texture 2D.
PBR Master (or equivalent):
Connect the RGBA output of the Sample Texture 2D to the Base Color.
Visual Representation:
plaintext
(World Position in World Space) --> [Multiply (optional, for scaling)] --> UV of [Sample Texture 2D] --> Base Color of [PBR Master]
Detailed Node Setup:
Position Node:
Add a Position Node.
Set the Space dropdown to World.
Multiply Node (for scaling):
Add a Multiply Node (Vector3 * Vector3).
Connect the Position Node output to the first input of the Multiply Node.
Create a Vector3 Property for scaling and connect it to the second input of the Multiply Node.
Sample Texture 2D:
Add a Sample Texture 2D Node.
Connect the Multiply Node output (or directly the Position Node output if not scaling) to the UV input of the Sample Texture 2D Node.
PBR Master (or equivalent):
Connect the Sample Texture 2D output (RGBA) to the Base Color.
This setup ensures that your texture remains "pinned" to the object’s world coordinates, making it unaffected by vertex animations or blend shapes. The texture will follow the object's transformations but won't distort with deformations. This is particularly useful for mesh deformations driven by blend shapes where you want the texture to stay stable relative to the world orientation.
Use a Vector3 property to control scaling (tiling of the texture).
Add Node (Optional for Offset):
Connect the Multiply node output to an Add node.
Use a Vector3 property to control offset, or directly use the result from Multiply if no offset is needed.
Sample Texture 2D Node:
Connect the Add node output (or the Multiply node output if no offset) to the UV input of Sample Texture 2D.
PBR Master (or equivalent):
Connect the Sample Texture 2D output (RGBA) to the Base Color.
Visual Representation:
plaintext
(Object Position in Object Space) --> [Multiply (optional, for scaling)] --> [Add (optional, for offset)] --> UV of [Sample Texture 2D] --> Base Color of [PBR Master]
Detailed Node Setup:
Position Node:
Add a Position Node.
Set the Space dropdown to Object.
Multiply Node (for Scaling, if needed):
Add a Multiply Node (Vector3 * Vector3).
Connect the Position Node output to the first input of the Multiply Node.
Create a Vector3 Property for scaling and connect it to the second input of the Multiply Node.
Add Node (for Offset, if needed):
Add an Add Node (Vector3 + Vector3).
Connect the Multiply Node output to the first input of the Add Node.
Create a Vector3 Property for offset and connect it to the second input of the Add Node.
If no offset is necessary, use the output from Multiply node directly.
Sample Texture 2D:
Add a Sample Texture 2D Node.
Connect the Add node output (or the Multiply node output if no offset) to the UV input of Sample Texture 2D.
PBR Master (or equivalent):
Connect the Sample Texture 2D output (RGBA) to the Base Color.
This method ensures that your texture remains "pinned" to the object's original local coordinates, making it unaffected by vertex deformations or blend shapes. The texture will follow the object's local space but won’t distort with the vertex positions.
Position Node:
Add a Position Node.
Set the Space dropdown to World.
Transform Node:
Add a Transform node.
Set From to World and To to Object.
Connect the Position node output to the Transform node input.
Multiply Node (Optional for Scaling):
(Optional) Add a Multiply Node.
Connect the Transform node output to the first input of Multiply node.
Create a Vector3 Property for scaling and connect it to the second input of Multiply node.
You can skip this step if no scaling is needed.
Sample Texture 2D Node:
Add a Sample Texture 2D Node.
Connect the Transform node output (or Multiply node output if scaling is used) to the UV input of Sample Texture 2D.
PBR Master (or equivalent):
Connect the RGBA output of the Sample Texture 2D node to the Base Color input of the PBR Master node (or other relevant output node in HDRP).
Detailed Setup in Unity Shader Graph Editor:
Add Nodes:
In the Shader Graph Editor, right-click and add the following nodes in sequence:
Position node.
Transform node.
Multiply node (if needed).
Sample Texture 2D node.
PBR Master node.
Configure and Connect Nodes:
Connect the Position node (World) to the Transform node (World to Object).
Connect the Transform node output to the Multiply node if scaling is needed, otherwise directly to the Sample Texture 2D node.
Connect the Multiply node output to the Sample Texture 2D (if used).
Connect the Sample Texture 2D output (RGBA) to the Base Color of the PBR Master.
This configuration will ensure that your UVs remain static relative to the object's original local space, effectively pinning the texture in place and preventing it from being affected by vertex deformation due to blendshapes.
Lerp Node:
Interpolates between the original UV coordinates and the object position.
Multiply and Add Nodes (Optional):
Scale and offset the object position if needed.
Sample Texture 2D Node:
Uses the blended UVs for texture sampling.
PBR Master (or equivalent):
Outputs the final color.
Detailed Setup in Unity Shader Graph Editor:
Add and Configure Nodes:
Right-click in the Shader Graph Editor and add the following nodes:
UV node for original UVs.
Position node set to Object space for stable coordinates.
Lerp node to blend UVs and object position.
Multiply node for scaling (optional).
Add node for offsetting (optional).
Sample Texture 2D node for sampling the texture.
PBR Master node for outputting the result.
Connect Nodes:
Connect the UV node to the first input of the Lerp node.
Connect the Position node (set to Object space) to the second input of the Lerp node.
If desired, use Multiply and Add nodes between Position and Lerp for additional control.
Connect the output of the Lerp node to the UV input of the Sample Texture 2D node.
Connect the RGBA output of the Sample Texture 2D node to the Base Color input of the PBR Master node.
Visual Representation:
plaintext
[Original UVs (UV Node)] -----------------> Lerp -+
|
[Transformed Object Position (Position Node)] ---|
|
Sample Texture2D
|
Base Color of PBR Master
Simplified Node Workflow:
UV Node:
Original UV coordinates.
Position Node:
Object-space position coordinates.
Lerp Node:
A input: Original UV coordinates.
B input: Object-space position.
T input (Alpha): A floating-point property to control blending (e.g., set value to 1 for pure object position use).
Sample Texture 2D:
UV: Output of the Lerp node.
PBR Master:
Base Color: Output of the Sample Texture 2D.
This setup will blend the original UV mapping with the object position, ensuring that your texture remains stable and "pinned" while reflecting the original UV layout of your mesh. Adjust the interpolation factor (T input of the Lerp node) to balance between the original UVs and the stable object-space coordinates.
Multiply Node (for Tiling, if needed):
Optional: Scale the world position coordinates to control texture tiling.
Add a Multiply Node and connect the Position Node output to it.
Use a Float or Vector3 Property for tiling and connect it to the other input of the Multiply Node.
Sample Texture 2D Node:
Connect the Multiply Node output (or Position Node output if no tiling) to the UV input of Sample Texture 2D.
PBR Master (or equivalent):
Connect the Sample Texture 2D output (RGBA) to the Base Color.
Detailed Setup in Unity Shader Graph Editor:
Add and Configure Nodes:
In the Shader Graph Editor, right-click to add the following nodes:
Position Node set to World space.
Multiply Node (if tiling is required).
Float or Vector3 Node (for tiling factor).
Sample Texture 2D Node.
PBR Master Node.
Connect Nodes:
Position Node (set to World space) provides stable coordinates.
Connect the Position Node output to the Multiply Node if tiling is needed, otherwise, directly to the Sample Texture 2D Node UV input.
Connect the tiling factor (either a Float or Vector3 Node) to the other input of the Multiply Node.
Connect the Multiply Node output (or Position Node output if no tiling) to the UV input of the Sample Texture 2D Node.
Connect the Sample Texture 2D output (RGBA) to the Base Color of the PBR Master Node.
Visual Representation:
plaintext
[World Position (Position Node)] --> [Multiply (optional, for tiling)] --> UV of [Sample Texture 2D] --> Base Color of [PBR Master]
Simplified Node Workflow:
Position Node:
Provides the world position of the object.
Multiply Node (Optional for Tiling):
Scales the world position coordinates.
Sample Texture 2D Node:
Uses the stable world position coordinates for UV mapping.
PBR Master:
Outputs the final base color.
By directly using the World Position node, you ensure that the UVs are stable and entirely independent of vertex deformation caused by blendshapes. The texture mapping will remain constant relative to the object's position in the world space, thus achieving the desired "pinned" effect. This way, the original UVs are not needed, and the texture will not warp with vertex movements.