[SOLVED] How can I access the UV 1 of a CSGBox material with gdscript?

jamslamjamslam Posts: 3Member
edited July 25 in 3D

I have a CSGBox with a material using an ImageTexture. I want to be able to scale the box but have the texture remain the same size and repeat to fill the space. My idea was to multiply the UV 1 scale by the same number as the box's transform scale. My problem is that I can't figure out how to access the uv1 from code. How might I do this? Is there another way to scale the box without scaling the texture?

Best Answer

  • jamslamjamslam Posts: 3
    Accepted Answer

    SOLVED! I found what I was looking for on the page for SpatialMaterial. The property is "uv1_scale".
    So the code is just something like:
    var material = SpatialMaterial.new()
    material.uv1_scale = Vector3(num, num, num)

Answers

  • sent44sent44 Posts: 39Member

    CSG is intended for prototyping, with no UV support
    I think you can use get_meshes()[1] and modify with MeshDataTool, still there are no way to push mesh back to CSGBox (Might be some way tricky with with engine level)
    Better and easy ways are using shader script, creating box from blender or generating mash with ImmediateGeometry, ArrayMesh, MeshDataTool or SurfaceTool

  • jamslamjamslam Posts: 3Member
    Accepted Answer

    SOLVED! I found what I was looking for on the page for SpatialMaterial. The property is "uv1_scale".
    So the code is just something like:
    var material = SpatialMaterial.new()
    material.uv1_scale = Vector3(num, num, num)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file