Problem: Projector texture (artifacts / repeating)

EDIT: Solution

I got a projector set up with a shader to do additive blending (its a customized blob-shadow shader), alpha-only falloff texture and RGBA cookie texture. It all works with just a minor problem: The projected texture repeats infinately outside the projection cone.

Here’s a pic:

Whats going on?

Here is the shader code:

Shader "FX/Projector Add" { 
	Properties {
		_ShadowTex ("Cookie", 2D) = "gray" { TexGen ObjectLinear }
		_FalloffTex ("FallOff", 2D) = "white" { TexGen ObjectLinear	}
	}

	Subshader {
		Pass {
			ZWrite Off
			// Offset -1, -1

			Fog { Color (1, 1, 1) }
			AlphaTest Greater 0
			ColorMask RGB
			Blend One One
			SetTexture [_ShadowTex] {
				combine texture, ONE - texture
				Matrix [_Projector]
			}
			SetTexture [_FalloffTex] {
				constantColor (0,0,0,0)
				combine previous lerp (texture) constant
				Matrix [_ProjectorClip]
			}
		}
	}
}

Any ideas?

You presumably just need to select the offending texture in the Project pane and set it to Clamp instead of Repeat in the inspector.

That almost did it, yet there are still some odd artifacts. I tried painting a black edge around the projected texture… that dimmed the streaks a bit but didn’t remove them entirely. Also the streaks in the projector’s YZ plane aren’t going away.

Clamping stops the texture at the edge pixels, then stretches those pixels off in all directions. Make sure your texture has a single colour border around it to avoid that.

EDIT: oops, I see you tried that. What about a thicker border?

EDIT 2: does it help if you remove AlphaTest Greater 0?

1 Like

It helps to make the border wider and set aniso higher.

Leaves only the artifacts in the YZ plane.

Turn off mipmaps in the import settings? I vaugley remember Nicholas giving me this advice and it worked great.
HTH
AC

Edit: or it was Turn off border mipmaps-try that

Thanks, now it works.

So for all who come after me here is a summary:

To make a custom Projector:

  • Set all involved textures to “Clamp”
  • Depending on your blend mode, draw a white/black/transparent border around your texture. 1+ pixels wide.
  • import the textures with “Border Mipmaps ON”.

I think ideally you’d still want mipmaps, so try the turn off border mipmaps option. Hows that looking?
AC