Generating a Mesh and Projectors

hey all…I am wondering about generating meshes. The scenario is a single generated mesh (a quad) and I have an object above it, projecting using the standard ‘light’ projector shader. The projection refuses to go onto my generated quad but will go on anything else in unity that I make from the menu such as the plane. Does this make sense?

I made some buildings in blender and set up a UV map and its fine. I don’t want to create a quad in blender!

eg I have terrain, the projection casts correctly, but not on the quad. A normal box with material? a plane with material? fine…but my plane with same material…no good?

I want to use my single quad code, so I can keep the poly count down

if I cant figure it out by the end of the day, I might end up using a plane, but I would rather figure it out then skip it :wink:
I might actually spit out all the values of the mesh from a plane and my generated mesh…i really need to work this out going forward.

using UnityEngine;
using System.Collections;

public class Person : MonoBehaviour {
	
	public Vector3[] 	newVertices;
	public Vector2[] 	newUV;
	public int[] 		newTriangles;
	public Texture2D[] 	textures;
	public float		fps;
	
	// Use this for initialization
	void Start() 
	{
		Mesh mesh = new Mesh();
		GetComponent<MeshFilter>().mesh = mesh;
		mesh.vertices = newVertices;
		mesh.uv = newUV;
		mesh.triangles = newTriangles;
		mesh.RecalculateNormals();
	}
	
	// Update is called once per frame
	void Update () 
	{
		int index =(int)(Time.time * fps);
		index = index % textures.Length;
		renderer.material.mainTexture = textures[index];
	}
}

is it possible using png 8 textures could cause it? - but my buildings work fine with png 8’s …nope - damn!

Do you even see this mesh on the screen?
It looks like you havent set up any coords for verts/tri/uv/renderer, looks like its all null.
Do you have other code we dont see here.

Code snipped from one of my classes
it makes a square with a square hole in it

These UV coords just point to a single point to get the color there.

 // verts for BRUSH1
  static Vector3[] verts = new Vector3[] { new Vector3(-.45f, .02f, .45f),
                                           new Vector3( .45f, .02f, .45f),
                                           new Vector3(-.25f, .02f, .25f),
                                           new Vector3( .25f, .02f, .25f),
                                           new Vector3(-.25f, .02f, -.25f),
                                           new Vector3( .25f, .02f, -.25f),
                                           new Vector3(-.45f, .02f, -.45f),
                                           new Vector3( .45f, .02f, -.45f)
                                          };

  static int[] tri = new int[] { 0,1,3,  3,2,0,
                                 1,7,5,  5,3,1,
                                 7,6,4,  4,5,7,
                                 6,0,2,  2,4,6
                                };

  static Vector2[] uv1;
  static Mesh mesh;
  static Vector3[] tempVerts; 


  static BrushFactory()
  {
    // Set up UV1 array
    uv1 = new Vector2[verts.Length];
    tempVerts = new Vector3[verts.Length];

    for (int v = 0; v < verts.Length; v++)
    {
      uv1[v] = new Vector2(.5f , .5f);
    }
  }

Thanks for your reply,

I’ll give a screen shot of whats going on.
I am filling in the values on the front screen through the gui in Unity:

In a nutshell a small 1x1 quad, uv mapping fully to cover the quad
So all this script does is generate the animated quad:

Using the same principle to create a large quad that I place a transparent road grid texture on I get the following results from my little projector ‘projecting’ onto the terrain and subsequent generated road quad sitting just above it.

It avoids projection onto my generated quads - that’s the problem right here:

Does that help explain it a bit more?
I am at work so later today I will grab your code and just try it and see what happens and if it ‘receives’ the projection

Thanks again

Hi all, for anyone watching just a quick update, turns out its to do with the material shaders - when I use a transparent/diffuse shader on my material and my texture, the projector does what my pictures show, if I use say a straight diffuse material, it reflects the projector correctly!

Does anyone know of this strange problem? Basically using the projector on transparent material? I will search the forums and reply with anything I find.

The Transparent/Diffuse shader has the IgnoreProjector tag set to True. Is there any reason why you’re using the transparent shader?

Looks like Kuba has got it.

Wow I’ve never seen anyone do all that in the inspector. :slight_smile:
But thats what its there for I guess.
I tend to do everything in code.

Hi guys, after much trial and error (and the projector ignoring transparency) it worked after I recently came back to it and changed the shader to transparent/diffuse/cutout. Unfortunate for me is I don’t know enough about shaders to understand why at this stage :slight_smile:
Thank you for your help, it is appreciated.

Hellaeon