2.5 BGE Texture distance fading

Hi, I was wandering if there is a way to make some sort of texture layers? so that when you get close to the object one texture fades in and the other fades out? Like fade the high detail texture in as you get closer to the object.
Thanks.

yes - using shaders ( through using python block attached to object ) and uniforms.

just though, found one bug - when shader is attached to object - material properties won’t be accessible in shader - so custom lightning would require uniforms or fix (for custom lightning see shadergen from here http://3dshaders.com/home/index.php?option=com_weblinks&catid=14&Itemid=34 for inspirations ).

Does this mean I’ll have to attach a script to every object in the game?

to my knowledge with current implementation - yes, though there was a work to develop custom shader materials, which could be set then to objects via interface, not blocks, but maybe someone who tried more might be more correct on the issue.

Edit: though of cause it is possible to iterate all objects in one script and set one shader to all objects

well you could do it also in material node editor.
Use camera distance as the mask for fading in/out the textures

Or use replaceMesh() with different objects that are the same except for the texture. That could work, as well, though the textures probably won’t hurt your FPS too much, so there’s not a huge need for it…

Its not for performance if that’s what your talking about. I need it so I can use more detailed textures and not see a repeat in the textures when your flying or something… so it still looks good when your at a distance.

Yes, I was referring to performance. Well, using the replaceMesh function (or Edit Object > Replace Mesh logic brick) would work as well, though you have to prepare the meshes for each individual object.

Ok thanks I will play with around with it :slight_smile: