Problems converting HLSL to Shadergraph. Trying to recreate a CRT monitor effect on a flat texture

  Kiến thức lập trình

I’m trying to create a CRT screen in Unity, that a player can interact with.

The “screen” is a rendertexture, projecting a 2d camera, looking at sprites out of the players view.Setup

I’m using a recreation video as reference, where the author has provided their code for the shader. Source shader code

So far I’ve managed to recreate the scanlines to my specifications, which work perfectly:
In game view

The problem lies with adding the curvature and vignette.

Based on the provided shader, I’ve tried converting the math, line by line, to shadergraph. I’ve added little red symbols (triangle, circle and square) to better show where each result is used.

The scanlines effect (which works)
Scanlines graph

Line 37 through 40
Curvature

Line 46 through 49
The vignette

Line 51 through 54
The combination

The result does not create curvature or a vignette.
Wrong result

I suspect the problem lies in my low understanding of the semantics and language of Shaders as a whole. I was hoping someone could point me towards where I’m going wrong or explain why this doesn’t work like in the breakdown provided further up.

I would appreciate any answers you can give me.

LEAVE A COMMENT