How to match TD GLSL mat viewer to render output?

Hard to come up with a good title for this thread, but let me explain with a screenshot an example.

When I build custom GLSL Materials, often times what I see in the render output is correct, but things in the geometry COMP viewer and even more so in the glsl MAT viewer are wrong or very wrong.

Some of this makes sense, custom lighting implementations are not going to translate well, scale of the default torus may be small, but scene scale very large, etc.

However, it would be really nice if there was (or could be) a #define that exists that we can use in #ifdef #endif blocks to conditionally setup the viewers render slightly differently to the geo COMP’s viewer, and the render viewer.

For example, in a converted phong or pbr mat we always get this #define:

Does this already exist? Is there any clever hacks to determine this? Or could be added?

I wouldn’t signify that with an #ifdef, since I wouldn’t want to compile another set of shaders for the viewers vs the render top, if not needed. The only way right now (almost) would be to look at the uTDGeneral.viewport member. The ‘x’ and ‘y’ components will be 0 in the Render TOP, while they will be > 0 unless the viewer is exactly at the edge of the window in the network editor. With the playbar in the network editor keeping things higher than at the bottom edge, looking at ‘y’ is likely the safer one.

The y trick sounds like a fair solution for me, doesn’t need to be ironclad, just robust enough to make looking at the node preview somewhat usable for custom stuff.

Thanks Malcolm!