3dstreet icon indicating copy to clipboard operation
3dstreet copied to clipboard

simple method for consistent texture scaling

Open kfarr opened this issue 1 year ago β€’ 2 comments

Issue: Textures appear too large, too small or squished in some cases for ground in building lots or ground for street segments.

Cause: When applying textures to ground box or segment box the repeat values are dependent upon the user supplied length, width, depth, etc. of the underlying geometry (plane or box)

Workaround: A user can manually modify assets.js material code to change texture repeat values.

Instead: we should have a mechanism for a-frame to define a texture for a geometry such that the material automatically sets a repeat value as to maintain the original aspect ratio and resolution of an image. (perhaps there is a new property that can be passed to specify the relative scaling from the original resolution as a number)

How would this be applied?

  • it could be a modified version of material such as magic-material component
  • a new component such as fixed-repeat that will listen to updates to geometry and automatically update the material repeat value

Current: <a-mixin shadow id="ground-parking-lot-material" material="src:#parking-lot-texture;repeat:.5 2;roughness:${surfacesRoughness}"></a-mixin>

Instead, example syntax: <a-mixin shadow id="ground-parking-lot-material" fixed-repeat material="src:#parking-lot-texture;roughness:${surfacesRoughness}"></a-mixin>

and the fixed-repeat component automatically calculates material repeat value based on dimensions of box or plane (no other geometry primitive value supported?)

kfarr avatar Nov 11 '23 19:11 kfarr

Here is an existing method that does this for separator type segments: https://github.com/3DStreet/3dstreet/blob/main/src/aframe-streetmix-parsers.js#L688

If done correctly the new component proposed in this ticket should be able to replace the use of repeat: ${repeatCount[0]} ${repeatCount[1]} within the streetmix json parsing function

kfarr avatar Nov 11 '23 19:11 kfarr

I did this option with repeat last year. So it will be easier for me to implement this method

Algorush avatar Nov 27 '23 22:11 Algorush