NasimiAsl Posted April 19, 2017 Share Posted April 19, 2017 On 4/18/2017 at 0:48 AM, MackeyK24 said: splatColor = getTileFromAtlasMap(albedoSampler, atlasRect1, atlasInfo1.xy, vTerrainUV) * baseColor1.r; if (atlasInfos > 1.0 && atlasRects > 1.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect2, atlasInfo2.xy, vTerrainUV) * baseColor1.g; } if (atlasInfos > 2.0 && atlasRects > 2.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect3, atlasInfo3.xy, vTerrainUV) * baseColor1.b; } // Second splat colors if (atlasInfos > 3.0 && atlasRects > 3.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect4, atlasInfo4.xy, vTerrainUV) * baseColor2.r; } if (atlasInfos > 4.0 && atlasRects > 4.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect5, atlasInfo5.xy, vTerrainUV) * baseColor2.g; } if (atlasInfos > 5.0 && atlasRects > 5.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect6, atlasInfo6.xy, vTerrainUV) * baseColor2.b; } // Third splat colors if (atlasInfos > 6.0 && atlasRects > 6.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect7, atlasInfo7.xy, vTerrainUV) * baseColor3.r; } if (atlasInfos > 7.0 && atlasRects > 7.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect8, atlasInfo8.xy, vTerrainUV) * baseColor3.g; } if (atlasInfos > 8.0 && atlasRects > 8.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect9, atlasInfo9.xy, vTerrainUV) * baseColor3.b; } // Final splat colors if (atlasInfos > 9.0 && atlasRects > 9.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect10, atlasInfo10.xy, vTerrainUV) * baseColor4.r; } if (atlasInfos > 10.0 && atlasRects > 10.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect11, atlasInfo11.xy, vTerrainUV) * baseColor4.g; } if (atlasInfos > 11.0 && atlasRects > 11.0) { splatColor += getTileFromAtlasMap(albedoSampler, atlasRect12, atlasInfo12.xy, vTerrainUV) * baseColor4.b; } i think this part make it to different color you append color in any step that maybe change your base color Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 19, 2017 Author Share Posted April 19, 2017 8 minutes ago, NasimiAsl said: i think this part make it to different color you append color in any step that maybe change your base color even when i use only one color... Still the same I will export you out a .babylon scene file with the terrain and the texture atlas images... plus the 0.1 normalized Rect info for where the texture is within the atlas... You should then be able to importMeshes for the terrain and use the rect info manually in your PG code Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted April 19, 2017 Share Posted April 19, 2017 make it with your textures too Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 19, 2017 Author Share Posted April 19, 2017 18 hours ago, NasimiAsl said: make it with your textures too I can get to load in play ground... Here is my scene file with just Candylan Terrain mesh: Terrains.babylon UPDATE The url to atlas image: http://mackey.cloud/files/terrains_atlas.png The atlas rect for splat 1: X: 0.0 Y: 0.5 Z: 0.5 (height) W: 0.25 (width) Tile X: 20 Tile Y: 20 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted April 19, 2017 Share Posted April 19, 2017 what is atlasInfos??? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 19, 2017 Author Share Posted April 19, 2017 15 minutes ago, NasimiAsl said: what is atlasInfos??? You must be looking at My UniversialShaderMaterial class ... Thats a combo class i use for all shaders: Check it out if need be... babylon.sceneshaders.ts AtlasInfos have the BabylonTexture.uScale and vScale (Tile.x and Tile.y) Just like the Babylon texture.ts sets level and texture coordinates in a uniform... For example: this._effect.setFloat2("vAlbedoInfos", this.albedoTexture.coordinatesIndex, this.albedoTexture.level); But in case of terrains: Vector4 atlasInfo = new Vector4(Tools.GetTerrainScale(info.TileSize.x), Tools.GetTerrainScale(info.TileSize.y), info.TileOffset.x, info.TileOffset.y); babylonTerrainMaterial.vectors4.Add("atlasInfo" + (ii + 1).ToString(), atlasInfo.ToFloat()); Each atlas texture get a atlas info that has the Tile Size And Offset... So gain.. basically Tile.x and Tile.y The Atlas Rects contains the texture atlas 'Packing Results" ... a Rect[] each... rect is the X,Y, height and width of the texture within the atlas... Already Normalized Vector4 atlasRect = new Vector4(albedoRect.x, albedoRect.y, albedoRect.height, albedoRect.width); babylonTerrainMaterial.vectors4.Add("atlasRect" + (ii + 1).ToString(), atlasRect.ToFloat()); Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 20, 2017 Author Share Posted April 20, 2017 Hey @NasimiAsl Just so you know... there is still a bit of blur issue as well... Know you are working on the artifact issue but i just wanted you you to be aware of that incase you need to address while your in there: Here is original shot using 9 copy and crop in unity editor: And this on in babylon using the 5.0 edgeUvFactor... looks a little blurry compared to unity's render of the same 9 copy crop image: Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted April 20, 2017 Author Share Posted April 20, 2017 @NasimiAsl here is a better atlas image to use: The url to atlas image: http://mackey.cloud/files/terrains_atlas.png and all textures in this atlas have been 9 copy and cropped and are png so keep BEST possible pixel precision. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.