Search the Community
Showing results for tags 'uscale'.
Found 3 results
How To Tile Textures Perfectly?
Rolento posted a topic in Questions & AnswersHi All I am experimenting with textures and am having issues with tiling. I have created several complex (well not that compex) shapes that I am wanting to apply a tiled texture to. However, when I apply the texture it appears warped (i.e. stretched) which makes it appear really bad. What I want is for the texture to be applied/tiled using a predefined aspect ratio therefore ensuring the rendered textures appears clear and crisp. NOTE: I am aware of the uScale and vScale properties for a material - I can successfully experiment and configure their values to get the desired effect. However, this requires lots of tweaking (experimentation) and the result is not perfect, furthermore this is not going to work for me because the shapes in my scene will be added at runtime (hence I need an algorithm to set the uScale and vScale values). Here is a code snipplet I have created that illustrates the problem: http://www.babylonjs-playground.com/#RF9W9#398 If you uncomment lines 102 and 103 the rendition looks good - but I need to calculate these field values at runtime. If anyone can help with this issue I would appreciate it. Thanks Rolento
Hi there I've spent a few hours trying to look into changing the uScale and vScale of the texture on an object-by-object and I'm totally stuck. To give you a simplified example of what I'm trying to do: Let's say I have lots of planes that are supposed to represent tiled walls. The planes are all different sizes and shapes, e.g. one might be 1×1, another 1×2, another 4×3, ... and so on. The same tiles are used on all of the walls, and I'd like to use the same repeating texture. The texture needs to have the same relative size everywhere it is used; e.g. it would look weird if the tiles on a 1×2 wall had the same height but were twice as wide as the tiles on a 1×2 wall. This means that I will need to use a different uScale and vScale on each plane. However I have the problem that the uScale and vScale are set on the texture, not the planes they are applied to - changing the scale for one changes the scale for all. After a few hours of Googling, as far as I can tell, if I want to achieve the effect I am going for I have three options, none of them very good: Build all of the bigger walls out of 1×1 walls. Create a different material and a different texture for each combination of uScale and vScale that I need in the scene. Write my own custom shader material that has the options to set uScale and vScale independently for each object. (1) and (2) are doable but I'd worry they're inefficient. (3) would be efficient but I'm struggling to make my own shader material that has all of the features of Babylon's default shader material, and work out how to pass custom variables to it. Googling has uncovered various forum posts and tutorials that cover some of the steps needed to do this, but I can't find all of the documentation I need for the whole process. After being stuck for a few hours I thought I really ought to ask here to see if anyone knows something obvious I'm missing! Thanks for your help!
solved [Solved] Different uScale values for same material
yorke posted a topic in Questions & AnswersHi all, in order to improve the performance of a scene built dinamically, I'm facing this problem: is it possible to have one material, to which is applied one texture, using different uScale e vScale depending on the mesh to which that material is applied? I need this because I have a 3d model of a city with many street segments, each segment having quite different length from each others. Now, those segments are textured: if I use the same uScale for them all, the road texture would appear "stretched" or "shrinked" depending on the length of the segment on which the material is applied, while I want it to appear uniform. I can bypass this problem assigning one different material for every street segment and setting uScale according to its length, but in the end the amount of materials and textures grows dramatically and scene performance falls down at 3 - 4 fps. Any ideas of how reducing the number of materials? Those are the actual stats for a mid-sized city: Total meshes 7309 - Total vertices 170688 - Total materials 7309 - Total textures 3834 Any ideas on how to solve this? Thanks in advance, cheers