Hey guys… Does anybody out there know how to deal with a Bottom-Up texture.
I am trying to write my own Terrain Splatmap Shader… @nasimiasl is also working on (i think, i haven’t heard back from him in a bit). So i started working on my own splatmap shader code.
First i created a texture atlas for the splatmap:
Now the rectangle for the first splat is 0.0, 0.0, 0.5, 0.5
But the first splat (0,0) is in the BOTTOM-LEFT and not TOP-LEFT.
How do i transpose my uv texcoords to deal with bottom up images…
This is my little TextureAtlas code for fracting with scale/tile/wrapping and offset:
vec4 textureAtlas2D(sampler2D atlas, vec4 rect, vec2 scale, vec2 uv, vec2 offset, float lod) {
vec2 fractUV = fract(uv * scale);
vec2 atlasUV = vec2((fractUV.x * rect.w) + rect.x, (fractUV.y * rect.z) + rect.y);
vec2 tiledUV = atlasUV + offset;
return texture2DLodEXT(atlas, tiledUV, lod);
}
and when i wand the first splatmap frm the splatmap texture atlas (rect: 0, 0, 0.5, 0.5)
#ifdef SPLATMAPTEXTURES
float lod = 0.0; // TODO: Compute Mip Map Level
vec4 splatmapColor = textureAtlas2D(splatmapTextures, vec4(0.0, 0.0, 0.5, 0.5), vec2(1.0, 1.0), vUV, uvOffset, lod);
surfaceAlbedo = splatmapColor.rgb;
#endif
The problem is the shader is expecting TOP-DOWN… so my rect X and Y are off
i would need to use a rect: 0.0, 0.5, 0.5, 0.5
Sooo… How can i OFFSET or deal with the BOTTOM-UP texture atlas… Where i use the RECT of the texture in atlas to do all the fracting, scale and offset… the textureAtlas2D function from above…
Any help would be going towards the Unity Babylon Toolkit (Exporter) .