Texture mapping coordinates previews Bug in Rhino8 (Grasshopper) for Mesh

Hi, texture mapping coordinates in Rhino8 (Grasshopper) is disabled (For Mesh) by Custom previews Component
But in Rhino7 it is enabled (if you change Geometry to SubD in Rhino 8 it will also be enabled)
in Rhino7


in Rhino 8

private void RunScript(Mesh mesh, Box box, string path, double tr, ref object MeshMap, ref object Material)
  {
    Component.Name = "Texture Maping,Matrial";
    if(Component.Params.Input[1].VolatileDataCount != 0 && mesh != null){
      var text = TextureMapping.CreateBoxMapping(box.Plane, box.X, box.Y, box.Z, true);
      mesh.TextureCoordinates.SetTextureCoordinates(text);
      MeshMap = mesh;
      Material material = new Material();
      if (path != null)
      {
        material.SetBitmapTexture(path);
        material.Transparency = tr;
      }
      var m = RenderMaterial.CreateBasicMaterial(material, RhinoDoc.ActiveDoc);
      Material = new GH_Material(m);}

  }

texture Mapping.gh (7.5 KB)

Summary

This text will be hidden

TriangulationComponents.Component_VolumeVoronoi

(Is there Bug in Custom previews Component in Rhino8?)?
Also Report this:
https://discourse.mcneel.com/t/how-to-create-a-material-in-grasshopper-from-an-image/168044/6?u=rh-3d-p
@wim
@gijs

1 Like

@dale
@AndyPayne

@Jussi_Aaltonen
why not respond yet? anyone form mcneel?

Hi @Rh-3d-p

Thanks for pointing out this regression.

I filed this issue as:
RH-82042 Grasshopper Custom Preview component shows wrong UVs

1 Like

hi @Jussi_Aaltonen
It seems Unweld Mesh at Edges (before set the texture map on mesh) it is possible to show the texture / but it’s slow and don’t need it in Rhino7 to do this!
and no need to use mesh.TextureCoordinates.ReverseTextureCoordinates(1); mesh.TextureCoordinates.TransposeTextureCoordinates(); mesh.TextureCoordinates.NormalizeTextureCoordinates();

    private void RunScript(
	Mesh mesh,
	double present,
	ref object a,
	ref object count)
    {
       Mesh unweldedMesh = mesh.DuplicateMesh();
     
       Component.Name="Unweld all edges";
    var edge=  System.Linq.Enumerable.Range(0,(int)(unweldedMesh.TopologyEdges.Count*persent));
      count=edge;
            unweldedMesh.UnweldEdge( edge,true);
             a =unweldedMesh;
    }

texture Mapping ver 2.gh (101.7 KB)

Hi @Rh-3d-p

In your original texture Mapping.gh add the following line after the call to SetTextureCoordinates:
mesh.SetSurfaceParametersFromTextureCoordinates();

That will set up surface parameter data according to your texture coordinates so that the default texture mapping applied will give the right result in the preview.

1 Like