Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [WIP] Texture Splatting Shader (texture bleeding problem)

Author
Message
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 10th Aug 2018 03:50 Edited at: 13th Aug 2018 14:31
Recently I tried to finish some old shaders that I started building earlier, in order to post them on the shader board.
I came across a texture splatting shader that has quite a potential, but was never finished by myself.
It was build for the AppGameKit RTS project, that has an own thread somewhere, but work hit me hard, and I had to put the shader development in idle state.
(EDIT: RTS Thread: https://forum.thegamecreators.com/thread/218835)

The biggest twist is, that this shader is actually based on only two texture atlas images (I attached them, so you can take a quick look if you need)
and has a scaleable amount of textures, that can be added.
For example, it can support a terrain with 64 unique textures, the only limitation on today's machines and phones is the image size you can use.


As you see, there is some texture bleeding in the atlas, that I can't get rid of. I tried everything I knew.
I think the problem is some sort of mental barrier inside me, based on some sort of paradigm

Some sources on this problem:
https://gamedev.stackexchange.com/questions/46963/how-to-avoid-texture-bleeding-in-a-texture-atlas
https://www.opengl.org/discussion_boards/showthread.php/165688-Texture-Atlas-edge-artifacts-how-to-fix
https://0fps.net/2013/07/09/texture-atlases-wrapping-and-mip-mapping/

Has anyone an idea to get this terrain shader to work?
After the bleeding problem has been solved, it would be easy to overwork some calculations and add full scalable splatting AppGameKit support, including native shadow, fog and lighting, but we have to stop the bleeding first.



I have attached the whole project as zip, media included.

Cheers, Jack

[/url]

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 10th Aug 2018 07:21 Edited at: 10th Aug 2018 07:23
Im not 100% sure on what texture bleeding means - is it those rectangular boxes around those image tiles?

Try

SetImageMagFilter(img, 0)

and
SetImageMinFilter(img, 0)

on those images - just throwing something in

Or maybe something to do with mipmapping and the UVs are just not 10000% correct in the % of each texture on the image atlas

https://gamedev.stackexchange.com/questions/46963/how-to-avoid-texture-bleeding-in-a-texture-atlas
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 10th Aug 2018 08:15 Edited at: 10th Aug 2018 08:16
I already tried:
SetImageMagFilter(img, 0)
SetImageMinFilter(img, 0)
It does change the appearance, but does not solve the problem.

I bet it has something to do with UV and mipmapping, Iam just looking in cImage.cpp from the AppGameKit rep, in order to clear things up.
The mipmapping part is about line 1013.

[/url]
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Aug 2018 08:45
Try SetImageWrapU and SetImageWrapV. Should fix it.
Using AppGameKit V2 Tier 1
Freddix
AGK Developer
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: France
Posted: 10th Aug 2018 08:56
Use wider Texture Atlas where you don't use the textures on borders ?
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Aug 2018 11:34 Edited at: 10th Aug 2018 11:39
Hi, I know those seams just to well
Its because of the mipmapping doesnt fit the texture size...I guess you also try the glsl “frac“ funktion.
You could maybe get rid of it by adding borders around the maintexture, so mipmapping has enough space for errors.
If you disable mipmapping they will be gone, but thats not the purpose of splatmapping
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 10th Aug 2018 14:39 Edited at: 10th Aug 2018 15:28
Force your UV coords to never choose 0 or 1 by using clamp. 0 and 1 are sampled twice, since those are the border pixels. That is why we see bleeding.

You may need to play around with the .5 number. I was still seeing some faint slight bleeding on the cracked ground texture at certain camera angles.

Add this code in the main agk so it is using the nearest pixel.



Just update these functions in the shader to use clamp so we never sample the 0 or 1 UV coordinates.



Source: http://download.nvidia.com/developer/NVTextureSuite/Atlas_Tools/Texture_Atlas_Whitepaper.pdf



Very cool shader. Would love to see an explanation how you're assigning the splatmap color channels with that many textures. I couldn't figure it out.

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 10th Aug 2018 14:46
Yikes - thats scary code lol
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 11th Aug 2018 00:02
You use texturegrad instead of texture2d.
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 11th Aug 2018 04:58 Edited at: 11th Aug 2018 05:23
Thank you Golelorn!
It was the clamp in combination with using the nearest pixel!

Quote: "
Force your UV coords to never choose 0 or 1 by using clamp. 0 and 1 are sampled twice, since those are the border pixels. That is why we see bleeding."

This was the paradigm I was looking for!

In order to improve the quality if we go near the textures, we also need to be able to modify the mipmapping like mentioned here:
https://0fps.net/2013/07/09/texture-atlases-wrapping-and-mip-mapping/

This is the current.ps file: (Iam gonna update the full project soon)



How it works:

It is based on two previous shaders.
First, the animated billboard shader, that I posted in the ultimate shader thread. This shader just plays a sequence of atlas images in a row. I learned about the incredible use of " mod(,); " there.
The second shader is a simple two textures and alpha map shader, in order to skin texture 2 over texture 1 based on the alpha map location.

My target was to build a new terrain shader to allow as much terrain textures as possible without using all texture slots AppGameKit provides.
I saw a lot of terrain shaders here, but they all used most of the texture slots and where not expandable.

So we have a 4x4 Texture atlas like this:

This means we have 16 Textures in it and we also need 16 Alpha maps in order to apply each texture to the terrain.

I figured out, that it can be done by using all image channels (RGBA) and an atlas for the alpha.


This image contains four atlas tiles and four color channels (You dont see the alpha channel here in this pic,just imagine another color there somewhere for alpha), so it can represent 16 alpha channels for the texture.
I draw the first texture as a main texture over the whole plane, and then apply the rest to it, so I do actually only use 15 alpha maps from the alpha atlas.
The algorythm gets the first atlas tile from the alpha atlas first. Then it will use the RGBA channels there. Then it jumps to the next tile to do the same and so on...


Well that said, I actually not use the Alpha channel of the alpha atlas right now, but I will implement it right away, so the whole method works

texel[i]*texel.a is the part where I have to work out a solution.
float Magic05 = 0.5; // I have to find out what it is meaning
I also have this magic 0.5 there where I have to figure out what it is doing in detail (its long ago I did it)

Once done, I create a simple one-liner to apply it in AppGameKit!

@jambo
As you already figured out the XAudio2, and can compile AppGameKit, please try to add custom mipmapping functionality in cImage.cpp, based on this ressource mentioned above
I would like to see this shader in your shader-pack!

[/url]

Attachments

Login to view attachments
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 11th Aug 2018 15:42
Thank you, Jack. I also use the billboard shader you provided in my current project!
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 11th Aug 2018 15:44
Jack, I also have a shader that uses atlasas and can handle as many textures as you want, and blends etc, but I've found it actuly quite slow in a real world example due to redraw. What kind of benchmarking have you managed on this?
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 11th Aug 2018 15:54
Hi I'm new here! I've been looking for a demo like this for a while now. Could you possibly release this "that uses atlases and can handle as many textures as you want, and blends" demo please? I would love to beta test it if it helps build it into a cool shader to use! Thanks alot!
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Aug 2018 00:23
Icerion.....I posted an early demo somewhere before, search for landscape shader.

But IronJacks looks really good, and his source code is here
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 12th Aug 2018 03:31 Edited at: 12th Aug 2018 03:38
Santman,

Do you find this slower than a terrain shader with multiple images? How do some of the unity MegaSplat shaders operate without effecting performance? ( perhaps this is because they use texture arrays, which is not available in ES 2.0? )

https://assetstore.unity.com/packages/tools/terrain/megasplat-76166

Could having a large plane with no meshes instead of multiple meshes be the cause of performance issues? Would using a createobjectfromheightmap() with just a flat surface have better performance, since we could break it up into many meshes?

I can't use my current terrain shader on mobile, because it lowers FPS to 17.

I am curious to test this, along with multiple meshes instead of 1 enormous mesh that is never culled. If you have tested this already, I would appreciate your knowledge in that area.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 12th Aug 2018 08:25
How about addin a vertex attribute to the mesh called textureID
It wont be blended based on fragments but between two vertices and you can save a lot more ID's in the attribute.
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 12th Aug 2018 14:56
@Santman
I can't see an impact on my windows machine, maybe someone should try it on a mobile phone in order to see results.
I tried to build the shader as efficient as possible, but I think there is still room to improve the quality.
It should also be no problem to add bump/specular to the terrain, but I would prefer the PBR technique.

@Icerion
Shure, I am about to clear the last problems in the shader. Then I will upload a new project including an simple AppGameKit interface, like mentioned in my last post.

@jambo
What do you mean by this?
I can imagine a performance boost while accepting a trade-off in design capabilities.

In order to compare the difference:
Santman's terrain shader can be found here:
https://forum.thegamecreators.com/thread/221599

[/url]
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Aug 2018 19:05
Jack / Golelorn,

This is a screen of the solution I used (screen.jpg) - not perfect (far from it) but if you then lower the scale you can't see the join line any more. The problem is always when tiling is too low and the machine zooms in.....but I got there with a far easier solution. Essentially all I did was work out that the sampling needs to happen only in the middle of the texture, so I used a hack for want of a better phrase.....I sample to only 0.998% of the texture then use an approximation to remove the blend at the start (which for me is roughly 0.0002165 for a 4x4 texture atlas). The result is ok, and is done with far, far fewer calculations - trade of for speed against quality, hence the speed question. I also worked out that a 4x4 texture to the GPU is no different to a 1x16 texture, which means we need only address the vertial seams, which seem to be easier to correct. Bare in mind I'm only targetting PCs. Will have to look into your solution though, see if it's quicker. I also handle my blending a completely different way, in that I just belnd based on alterable heights with a detail overlay on top.

The issue though for me is that on a plane it's no problem, even with normal and specular active, but when in a real word test (screen 2) what happens is all that sampling occurs for the distant hills, which is then replaced with the hills in front - so we end up with a TON of overdraw and that is hammering the frame rates - this only gets 104FPS at 4K now. So I'm spending a bit of time right now looking at solutions to this - an LOD model that changes the texture resolution, tiling etc, even reducing to solid colours only where the fog comes in.

It's fun and frustrating in equal measures trying to keep speed up.

Attachments

Login to view attachments
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 12th Aug 2018 19:20 Edited at: 12th Aug 2018 19:22
As I said you need to add a seamless border to your Tiles and sampling only a part of the original texture is pretty much what I sugested but with different seams as your first try...
Sorry but I had to point that out
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Aug 2018 19:48
Lol, Janbo I know. But I didn't bother adding the extra line in, you just reduce the scale of the tiling and it cant be seen under almost all circumstances. You coukd easily add the extra line, that would remove the problem altogether.

I'm abandoning the 3d world though, moving into some thing else.
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 12th Aug 2018 19:52
@Santman
Pretty good trade-off if you ask me I would actually be fine with that smooth line in order to keep mipmapping at near-stage.

Do you have tried to bake the texture and the re-applied it to the distant hill without any special shader?
I mean, distant hills do not need such a complicated shader, like we use.


https://forum.thegamecreators.com/attachment/82185
If we take a look at this plane, its like an Terrain segment. Let them be 64x64 Segments per terrain.
At lower angles or greater distance there is no difference if we use a single, baked Texture, so the shader could actually create an own LOD level system, where distant parts will be rendered with prebaked stuff with no atlas at all. Although It would require one new texture stage for the shader.
Quite complicated, but still faster than an AppGameKit based LOD System.

[/url]
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Aug 2018 20:46 Edited at: 12th Aug 2018 20:47
Jack,

The code that powers mine is just this then:



though you need only use the ypos variable if you stack the textures in a column - then for Xpos you can just use uvVarying as normal.

Baking the textures......I literally never thought of that, despite already doing it for shadows and paths....doh! I'm thinking of it from the perspective of the editor, where changes can be made tot he landscape itself. Perhaps I shall look at it again now.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Aug 2018 20:48
Though actually I was going to say, I was exploring an idea of identifying when it was in the inner or outer borders, then using texelfetch to get the raw colour data and mixing it back together to smooth out that line too.
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 12th Aug 2018 22:14
@Jack : Wonderful news indeed! When do you plan on releasing it if I may ask?

Thanks!
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 12th Aug 2018 22:24
This runs at 8 FPS in landscape mode on my mobile vs 17 FPS using GameGuru's terrain shader with 4 seperate textures plus the splatmap image.
puzzler2018
User Banned
Posted: 12th Aug 2018 22:38 Edited at: 12th Aug 2018 22:40
I agree - FPS with such apps like this will make your CPU and GPU scream STOP!!!! pleeeeese lol

Multi-threading maybe wise - but thats not compatible with AppGameKit Tier 1 (as yet) unfortunately
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 12th Aug 2018 22:54 Edited at: 12th Aug 2018 22:58
Hi, @Jack! Just wanted to show you an issue I may have found.

As you can see in the attached photo, I tested out with my own 1024x1024 texture set to the entire atlas as opposed to 256 x 256 texture tiles here :



Here is my main.agc :



Here is my floor.ps code :



And I see a huge seam issue with it. Is there any way to fix this?

Also would be great to be able to control the repeat size of each texture in the Texture Atlas!

Thanks!

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 12th Aug 2018 23:01
Take a look at the minecraft one im doing. the seams is just cause the textures are not aligning right and use Magfilter and minfilter off.

You can see from that texture that its way off balance. and doesnt flow anyway - sort that on the texture then things might just be ok

Make the texture flow through out






Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 12th Aug 2018 23:05 Edited at: 12th Aug 2018 23:08
That's cool bro, but I don't want my textures pixelated. I just want to be able to have a nice, lush terrain with no seams & controllable texture repeats. That's all. I find HUGE value in this wonderful shader!

Thanks!
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Aug 2018 23:16
Icerion.

You can change the size in the shader, you just multiply the uv coords. Actually, almost everything you can do in agk you can do in the shader natively.

In your texture you'd need to alter the code to allow for a single texture, it's repeating the top quarter from what I can see.....so the texture doesn't loop so it's gonna have bad seems. For a single texture it's not an atlas, you wouldn't do anything.
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 00:03
Okay guys, I was able to test it on a Samsung S8 smartphone and found some technical problems there.

I got some crashes because I initialized some variables outside the main loop, once I moved the definitions inside the main loop I got some performance breakdowns to about 40fps. The solution to this one is: Real-Time shader creation by AppGameKit code, in order to fill this variables with constant values, then save it as .ps file and load it as shader or directly from string... I don't think that it would be necessary to change the atlas resolution in real time, so its okay.

Once I replaced all variables with constants, it worked up to 59.97 FPS.
I think the Samsung S8 is a bad platform for debugging bottlenecks as it is pretty fast.


This is the most time consuming part in the shader:


It's a loop for each texture in the texture atlas.

[/url]
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 13th Aug 2018 00:25
Hi Jack! Great find! I wouldn't mind beta testing it on my S6 if you want! I love testing new demos & code!

Thank You!
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 00:44 Edited at: 13th Aug 2018 01:37
If you want to give a try on the S6, here is the current project file.
As I mentioned the S8 can't show any speed difference on this one.
(If I render an empty scene, I get the same speeds as with a plane and this shader)

Maybe it is possible to create some sort of image bake functionality to this shader, so
the rendering part will only run once and then keep the rendered image for all the other cycles, so it's still a lot of work until we
come to the best performance.


I think this explains one problem better:

As you see, there are some textures missing based on the alpha channel of the alpha map.
(Also, Texture 15 is wrong)

[/url]

Attachments

Login to view attachments
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 02:01 Edited at: 13th Aug 2018 02:28
Does the following shader run faster on your machines?
It does the calculation only once and not every frame.
This should break your 8FPS limit at least a little bit, I think.


[/url]
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 13th Aug 2018 02:17
Jack

Not sure if you updated all the files? I am not seeing the 1-16 in the zip file. Still getting 7 FPS on my cheap 100 dollar 2GB RAM phone. 9 FPS on my ASUS tablet and Kindle Fire. I am shocked the S8 is that powerful. Wow.

When my wife gets home I can test it on the iPhone.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 13th Aug 2018 02:22
Updated the shader, and same results. Portrait mode I am getting about 22 FPS. Landscape it plummets to 7FPS on my phone and 9FPS on my tablets.
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 03:22 Edited at: 13th Aug 2018 03:27
It seems that somewhere my code gets ignored

bool runvar = true;
...

if(runvar)
{
do this

runvar = false;
}
else
{
do that.
}

- I do never reach "do that". This actually explains your 8 fps performance very good.

Well, a similar structure with Ints instead of bools is used by me quite often in shaders... creepy.
suggestions?

Something like that:
https://www.opengl.org/discussion_boards/showthread.php/198353-Boolean-Branches-in-shader

[/url]
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 13th Aug 2018 11:48
Right ! branching is expensive.
You could generate/insert a preprocessor variable into the shader string and use #ifdef if you dont want to write several shaders.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Aug 2018 12:39
To navigate this issue, I use a texture size of 480x480, which is tileable, and I then pad that out to 512, so around the texture is a 16 pixel border of repeated image. So, the actual border in the atlas avoids bleeding, as the textures can safely repeat over 480x480 inside that 512x512 range.

I mean, I have a similar terrain system with no bleeding. The only way to get around this is to do the above, there is nothing else you can do - trust me! - you need those pixels so that mip maps don't betray you. A fractional offset won't help, the texture still has to atlas and repeat, and it's simply better to allow the texture to do that within a 0.0-1.0 range. Like, when the UV is at the extremes it only has adjoining textures to blend into, it needs a border of itself if you know what I mean, so the texture can repeat inside that 512x512 range.

Has to repeat?
Has to repeat without bleed?
Has to have that border

I use a AppGameKit function to load up a texture, make into memblock and build the atlas image, I wouldn't want to try this with an art package - raw seamless repeating textures as source, put the effort into handy code functions and not messing around in art packages. Plus, when you want to add a normal map or combine channels to limit texture usage, then image memblocks are damn useful. I mostly use 2 textures per material - a diffuse with the roughness in alpha, and a normal with the height in alpha. So I can have PBR pretty much with just 2 textures.
The code is dark and full of errors
puzzler2018
User Banned
Posted: 13th Aug 2018 12:46
Just remember - All textures for wrapping and UV work are required to be power of 2.

16x16
32x32
64x64
128x128
256x256
512x512
1024x1024
2048x2048


Etc

If textures are much smaller than indeed pad it out to the next power


Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Aug 2018 13:25
Yeah, the atlas image is always big and power 2, like 4096x4096 - padding from 480 to 512 is just for the repeated border to allow the seams to blend properly.
The code is dark and full of errors
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Aug 2018 13:36
I'll have to look at this shader, as it looks like it might play along with an idea I've been cooking up for a fog-of-war effect
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 14:25 Edited at: 13th Aug 2018 14:37
@janbo
I am going to try it without a preprocessed variable, if it does not work, multiple shader would be better

@Van B
smooth idea.
Maybe I also do atlas creation in AppGameKit, as I may also need to recompile the .ps file for every special use.

@Phaelax
This is the link to the RTS project, I already done some sort of fog of war shader. I think the last one Ive posted is not working anymore, but I got a new working fow system with way better performance, if you need it. Would be great tough, if we could exchange contributions to an AppGameKit RTS project, in order to speed things up for all of us.
https://forum.thegamecreators.com/thread/218835

[/url]
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 13th Aug 2018 14:50
I got about 40+/- FPS on beta test Would be great to add height based on heightmap for proper terrain.
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 15:05 Edited at: 13th Aug 2018 15:06
I am working on the speed issue right now. I found an old S3 phone and can now benchmark on older mobiles.

I do not plan to add a heightmap coloring system, because Santman did it well.
Although you can create your alpha atlas stages in order to fit a heightmap to get the same results.


[/url]
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 13th Aug 2018 15:05
Tanks Van B thats what im talking about the whole time
Is your memblock code somewhere to try ?
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 15:15 Edited at: 13th Aug 2018 15:17
Quote: "Tanks Van B thats what im talking about the whole time"

I missed the idea to create it without having too much work on the design level,
I'm sorry janbo
We have to keep in mind, that not everyone is able to create such altas in an image design software,
but if we do it in code, it will work well.

[/url]
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th Aug 2018 15:23 Edited at: 13th Aug 2018 15:39
I will post something today, I am sure I took the time to make it neat, like call a function with the image file and the grid X Y where you want the texture to go.

The atlas doesn't need to mess with the texture borders, but I've not explained that very well.

I create an atlas image, maybe 2048x2048, to hold 4x4 textures.
I then load in 512x512 textures, tileable, and scale them down to 480x480.
Then, the texture is repeated over the 512x512 area, reducing its resolution a little, the image is effectively at 106%, and the 3% border on each texture is there to eat up that edge line... it should keep it away even with mipmapping, or rather make it difficult to notice. The 106% texture is copied onto the atlas at 512x512.

I do have a couple of other tricks that I can post that might help with this stuff, like being able to load in a greyscale image and apply it to a single channel, for replacing alpha channels etc. I will see what I have that I can make neat, and post up some code tonight - at the least I'll post up the atlas compiler code. The 6% border technique would be a nightmare to get right in an art package, so that was never an option, I tried that and all it did was make me love memblocks all the more
The code is dark and full of errors
Icerion
5
Years of Service
User Offline
Joined: 3rd Aug 2018
Location:
Posted: 13th Aug 2018 15:33
@Jack : Where did @Santman do a height based on Heightmap demo?
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 13th Aug 2018 15:45 Edited at: 13th Aug 2018 15:45
@Icerion
In order to compare the difference:
Santman's terrain shader can be found here:
https://forum.thegamecreators.com/thread/221599

This thread goes lightspeed

[/url]

Login to post a reply

Server time is: 2024-04-18 10:59:36
Your offset time is: 2024-04-18 10:59:36