Welcome to Fractal Forums

Fractal Software => Fragmentarium => Topic started by: Patryk Kizny on August 03, 2015, 01:22:15 AM




Title: How to properly map a 2D map for tile rendering?
Post by: Patryk Kizny on August 03, 2015, 01:22:15 AM
Hey,

Probably that's simple, but can't seem to get it right.
I am loading a flat background image into a sampler2D.
The texture should serve as a background so it should be 2D mapped onto entire buffer.
I am using the following code:

Code:
vec3 bg = texture2D(gl_FragCoord.xy * PixelScale).xyz;

It renders properly in the main buffer and in highres rendering it renders fine if doing 1x1 tile.
But when there's more tiles involved, apparently background texture coordinate seem to restart every tile.
How should I be doing that properly?




Title: Re: How to properly map a 2D map for tile rendering?
Post by: Patryk Kizny on August 04, 2015, 03:46:25 PM
Anyone?


Title: Re: How to properly map a 2D map for tile rendering?
Post by: _revers_ on August 04, 2015, 04:33:47 PM
Try using:
Code:
varying vec2 coord;
varying vec2 viewCoord;
varying vec2 viewCoord2;
from 3D.frag, i.e.:

Code:
vec3 bg = texture2D(Texture, coord).xyz;
vec3 bg = texture2D(Texture, viewCoord).xyz;
vec3 bg = texture2D(Texture, viewCoord2).xyz;

One of them should work.


Title: Re: How to properly map a 2D map for tile rendering?
Post by: Patryk Kizny on August 04, 2015, 08:51:28 PM
vec2 pos = (viewCoord2+vec2(1.0))*0.5;

That's what worked for both main buffer and tile based rendering.
Huge thanks!