How to modify output uv in the graph

Hey, I want to modify the output uvs, however I can’t find how to do it in shadergraph.

Here’s what I want to do:

4678076--440579--upload_2019-6-23_19-55-39.png

so in the last line, as you can see, I want to clamp uv.y between two values.

Please help!

Use a UV, split, clamp, then vector2 node?

This seems to clamp uvs in the fragment shader, produces totally different result

Ah, you specifically want to clamp the UVs in the vertex shader. Not possible in Shader Graph. You’ll have to find another way to achieve the effect, or modify the generated shader code by hand.

found my way over here because i’m wanting to modify the UVs in the vertex shader part of my shadergraph, before deforming the vertex position. i hadn’t realized that UVs couldn’t be modified at the vertex stage of the shadergraph!

i’m trying to alter the UVs so that they are based on the screen space position of the vertices before i then deform the vertex positions.

@bgolus i wonder if you have any suggestions for how to achieve something like this. i thought maybe i could put my altered UVs in the tangent coordinates, but that gets transformed on its way into the frag shader. could I do some kind of inverse matrix multiplication to get them back to how I put them in?

otherwise, the best idea i’ve got is to run the mesh through a compute shader to set the UVs before then rendering with my shadergraph, but that seems like a pretty complex setup :confused:

Aaron-Meyers i feel your pain)

You could store a duplicate vertex position in an extra UV channel, then do the transforms in Shader Graph to that position.

that is a good idea. thank you!

@bgolus so I’m trying to get this working now and so I find myself needing to recreate the functionality of the Shader Graph Screen Position node so that I can calculate the screen position based on the vertex position I have stuffed into UV1. Easier said than done! But lo & behold, in my searching, I came across another thread where you saved the day: What is the equivalent of UnityObjectToClipPos inside Shader Graph??

I recreated your Shader Graph from that thread and yet somehow it doesn’t look correct. Here is a sphere at (0,0,0) using a Shader Graph that ought to just be using the derived screen position to sample Scene Color, but it’s misaligned somehow:

Do you have any inclination as to what might be going wrong? If just multiply the world position by the ViewProjection matrix, the sky part is on the bottom, so your Shader Graph additions are at least flipping it properly, but if everything we working as intended, the sphere would be imperceivable because it would just be passing the background through.