I have searched for similar problems, but i couldnt see them fixing my issue. Thats the reason why iam posting this ques.
My requirement is mainly to write inside the cells(cell id). These cells were drawn according to the data from an excel sheet. When i tried it seems to be blurred.
var textureResolution = 256;
var textureGround = new BABYLON.DynamicTexture(“dynamic texture”, textureResolution, scene);
var textureContext = textureGround.getContext();
var materialGround = new BABYLON.StandardMaterial("Mat", scene);
materialGround.diffuseTexture = textureGround;
ground.material = materialGround;
var img = new Image();
img.src = "/textures/floor.jpg";
img.onload = function() {
//Add image to dynamic texture
textureContext.drawImage(this, 0, 0);
textureGround.update();
//Add text to dynamic texture
var font = "bold 5px Arial";
textureGround.drawText("Grass", 75, 135, font, "white", null, true, true);
textureGround.drawText("Grass11", 150, 135, font, "white", null, true, true);
}
Hi,
Possible to have a PG (repro)? To me, it looks like your ‘context’ does not do what it’s likely supposed to do.
The way I see it, you are projecting over the entire ground/scene a 256 resolution for drawText, which would likely give this result. I can’t be sure but it really looks like it.
OK, it’s not what I thought. It’s kind of more problematic. You will need to look for another method.
I first tried to isolate the dynamicTexture from the grass, did set the width and height to the full size (3200x4600pp) and got the exact same result. Didn’t understand why at first. Then I bounced on the 5px size of font. Created a same size image in photoshop 3200x4600 px at 72pp resolution and there goes, same result.
May be @JohnK has a trick to have this work with your method. I don’t, I’m sorry.
Else, the method above (see PG) would work even with 4096 resolution and low impact on performance, I believe. It would however require you to somewhat rework this part. May be wait to see if others have a better solution (that would not require so much work to redo)…
What am I checking? The are a number of issues you raise.
Let me try to answer the title ‘Letters blurred while using dynamic texture’.
Here is a very crude PG that shows that the larger the width and height of the dynamicTexture there are more pixels to write on so text remains clearer when shrunk to fit the ground.
Try different values for the parameters for createGroundAndTexture(index, fontSize, z)
Index set the power of 2 used (up to 8), fontSize as it says, z positions the ground
Have a read through the PG code and work out what each line is doing.
There is a limit to the size of the dynamicTexture as indicated by
Since in the PG the dynamicTexture is based on groundWidth and groundHeight by increasing these sizes 100 times you reach the limit when the index is 1.
In your project you need to find the best balance between ground width and height, the dynamicTexture width and height, and font size.
I was just wondering. Why not separate it from the actual ground texture/image and work it as an overlay.
Eventually split in 2 or 4? I guess that would work, wouldn’t it?