Shadertoy not update viewport correctly?


#1

Hey there,
I made a pyplug node with shadertoy for Blender Distort/Undistort. Everything works fine except this node doesn’t update viewport correctly. If I zoom in viwport 50% or less, it will show correct result, if I then zoom out to a degree, more than 50%, it will just show very weird distortion. Is that a bug in shadertoy node? or I did something wrong?

Zoom out viewport to see 100% ( very weird result)

Zoom in viewport 50%

Render result is correct.

I also have it on Github in case anyone wants to take a look.

Best,

Han


#2

You need to scale all spatial factors with iRenderScale (which is a vec2).
It indicates the current scale factor applied to the viewport. It is rounded to the nearest mipmap level:
e.g: 45% zoom level would be rounded to 50%, hence all coordinates in the image are multiplied by 0.5 and the iRenderScale passed would be 0.5


#3

Thanks MrKepzie,
I fixed it with iRenderScale. It’s now working probably.

Thanks again.