Examples for version 1.3 (done with beta Construct r123-2, uses Platform plugin from C3 Runtime.)
C3 Runtime Example:
NormalMapTestC3Runtime.c3p
C2 Runtime:
High DPI breaks it (likely due to canvas vs WindowHeight mismatch.) Update - corrected this in the example by using LayerToCanvasX(0,ViewportRight(0),0) Instead of using WindowWidth. Also helped with zoomed in Viewports.
NormalMapTestC2Runtime.c3p
Unfortunately, right now this is Work In Progress, the current implementation is too fragile, windows x,y parameters must be changed based on runtime, OS, DPI settings, etc. looking for ways to make it more robust, suggestions welcome. With the above change, the C2 runtime version looks reasonably robust now (works on MacOS, Windows and iOS through remote preview). Still an issue with the C3 runtime version example because of the different behavior of WindowHeight/WindowWidth (which requires a code change between OSes.)
A quick description of the problems seen, in case it sparks some ideas:
C3 w/ C2 Runtime / MacOS / Windows:
Window Width WindowHeight matches System Canvas Size dimensions listed in C3 Debug inspector
WW, WH changes dynamically as preview window is manually scaled via mouse
C3 w/ C3 Runtime / MacOS:
WindowWidth, WindowHeight are fixed at Layout / Viewport sizes
Does not vary, does not match System Canvas Size dimensions listed in C3 Debug inspector.
Canvas size in debug inspector also does not match: LayoutToCanvasX(0, WindowWidth, 0), LayoutToCanvasY(0, 0, WindowHeight). The Canvas size in the inspector is 2X the LTCX/Y.
C3 w/ C3 Runtime / Windows:
WindowWidth, WindowHeight are fixed at Layout / Viewport sizes
Does not vary, does not match System Canvas Size dimensions listed in C3 Debug inspector.
Canvas size in debug inspector DOES match: LayoutToCanvasX(0, WindowWidth, 0), LayoutToCanvasY(0, 0, WindowHeight).
The reason this matters is I’m using a normal map effect and I need to pass in parameters to the shader for the location of the light on the layout (x,y) which I need to translate with LayerToCanvas and to scale the effect properly also, also need to pass in the overall canvas/window height and width.
There may be others way to do this (open to suggestions), but I am wondering why there is variability between C2 runtime, C3 runtime and OSes for WindowWidth/WindowHeight.
Bug Report