Control when shader graph is calculated

So I have a screen cutout shader that calculates uvs relative to the screen and then cuts it out onto a screen, but when I change the camera’s projection matrix, that changes the screen position calculations in a way I don’t like. If I could just control when the shader graph calculations are made, that would be great. If not, is there another way to calculate a screen position cutout through code?

Attached below is an image of my screen cutout shader. Don’t worry about the tiling and offset. There’s nothing wrong with the shader but is is possible to manually run the calculations instead of letting it automatically do so?

Can you give a bit more context of what you want to achieve? I have problem to imagine your usecase.
By the way I see alpha to be constant so I am not sure what does it cut.

It’s kind of hard to explain, but I’m trying to make it so that I can calculate the screen position as if the camera’s projection matrix never got stretched or anything. Basically I want to be able to somehow tell the shader to do the calculations through code instead, and I’m wondering if that’s possible. And when I said “screen cutout”, I mean for portals like in this video:

Well, it’s quite rough description - things like that can be done in many ways and I am not sure what is your exact goal.
It could be just alpha mask, stencil or completely custom matrix projection or something completely else.
Still not sure what means “tell the shader to do calculations”, but if you mean to just render/blit something with shader then just use render texture to do so.

So I’m using custom scissor rect code ( Scissor rectangle ), that crops the camera’s view changing its projection matrix and rect, but this messes up the screen position calculations. So I just want control of when the shader graph’s code is executed if that’s possible.

Still not sure whats the exact goal, but you can probably provide custom projection matrix to calculate position or instead of messing up with projection, just keep it as it is and discard/mask everyting around in shader.
If you use other camera to render texture just enable rendering whenever you want.

Are you trying to create portal?

Well I want to change the camera’s projection matrix to save space, but were you thinking that there’s a way to factor the projection matrix into the screen position? If so, how would that be done?

Sorry, never done that before, but you can construct your own and calculate whatever you want. For example I see this code has cam.ResetProjectionMatrix(), you can copy matrix before you override it and do something with that and send to shader. Anyway, you can’t just calculate new normalized screen position as it’s in screen space and it will be probably stretched, it must be mapped with clip space I guess.

If that is not secret, can you describe what are you trying to do? I mean something like “I want to render icons for inventory” or “create portal in first person game” - I might be able to help a bit more.

Okay well I have one question. Is it possible to be able to see what a node is outputting directly?

If you mean what code is generated, then yes. First source is documentation, there is often “possible” output, second one is the shader graph source itself, and third one is, you can click on node and see generated shader - there will be more than just this one node, but definitely you can see what’s there.

I meant during gameplay.

Shader code during gameplay? The result of running shader?

Yes. is that possible?

“Yes”, but which one xD

I assume you mean shader code. If you want to see it, then for sure it should be possible, but I don’t think it can be done out of the box as these things are compiled on build. The question is why would you need that, because you can’t just go change some line of code - you would need to compile this shader with all variants what takes time.

To be honest I still don’t know what “control when shader graph is calculated” exactly means, maybe you want something like shader keywords?