Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Material Not Displaying Texture Onto C# Script Generated Mesh

Discussion in 'Shader Graph' started by MaxWWest, Jul 28, 2022.

  1. MaxWWest

    MaxWWest

    Joined:
    Jan 26, 2022
    Posts:
    2
    I'm working on a water mesh right now and I'm trying to put this pattern onto my mesh. For some reason the water ignores my 2D texture I've put into my shader graph. I think it has something to do with my UV generation but I'm really new to this stuff and unsure. I was following this guide for the mesh generation:
    . I've posted a photo of my UV generation code, my shader graph, and what the water looks like in game.
    Code (CSharp):
    1. private Vector2[] GenerateUVs(){
    2.        var uvs = new Vector2[mesh.vertices.Length];
    3.         for(int i = 0; i <= Dimension; ++i){
    4.             for(int j = 0; j <= Dimension; ++j){
    5.                 var vec = new Vector2((i / UVScale) % 2, (j / UVScale) % 2);
    6.                 uvs[index(i,j)] = new Vector2(vec.x <= 1 ? vec.x : 2 - vec.x, vec.y <= 1 ? vec.y : 2 - vec.y);
    7.             }
    8.         }
    9.         return uvs;
    10.     }
    problemShaderGraph.JPG water.JPG
     

    Attached Files:

    • code.JPG
      code.JPG
      File size:
      29.1 KB
      Views:
      133
  2. MaxWWest

    MaxWWest

    Joined:
    Jan 26, 2022
    Posts:
    2
    Turns out I had my UVScale at 0 so UVs weren't being created.