Error: Material doesn't have a texture property

I am trying to modify a built in shader to support my lightmap rendered outside of Unity.

I can’t get anywhere with this and would appreciate if someone could send me in the right direction.

I get an error that tells me LightMap does not have a texture property for starters and beyond that I’m not entirely sure how to make it blend.

Shader "Custom/reflection_bump_lightmap" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	//_SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
	_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
	_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
	_MainTex ("Base (RGB) RefStrGloss (A)", 2D) = "white" {}
	//_Cube ("Reflection Cubemap", Cube) = "" { TexGen CubeReflect }
	_BumpMap ("Normalmap", 2D) = "bump" {}
	_LightMap ("Lightmap (RGB)", 2D) = "gray" {}
	
}
SubShader {
	Tags { "RenderType"="Opaque" }
	LOD 400
CGPROGRAM
#include "UnityCG.cginc"
#pragma surface surf BlinnPhong
#pragma target 3.0

sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _LightMap;
samplerCUBE _Cube;
fixed4 _Color;
fixed4 _ReflectColor;
half _Shininess;

struct Input {
	float2 uv_MainTex;
	float2 uv_BumpMap;
	float2 uv2_LightMap;
	float3 worldRefl;
	INTERNAL_DATA
};

void surf (Input IN, inout SurfaceOutput o) {

	fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
	fixed4 c = tex * _Color;
	fixed4 lm = tex2D (_LightMap, IN.uv2_LightMap);

	o.Albedo = lm.rgb; //<< I added this line which screws evertyhing up :)
	//o.Albedo *= tex2D (_LightMap, IN.uv2_LightMap).rgb * 2;

	
	

	
	o.Gloss = tex.a;
	o.Specular = _Shininess;
	
	o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
	
	float3 worldRefl = WorldReflectionVector (IN, o.Normal);
	fixed4 reflcol = texCUBE (_Cube, worldRefl);
	reflcol *= tex.a;
	o.Emission = reflcol.rgb * _ReflectColor.rgb;

	o.Alpha = reflcol.a * _ReflectColor.a;
}
ENDCG
}

FallBack "Reflective/Bumped Diffuse"
}

The “doesn’t have material editor” error tends to be a side effect of another error. Unity just likes spamming the console with them to annoy us.

If you check the console, it should give a more helpful error in there.

1 Like

Okay, I got this from the console:

Shader error in 'Custom/reflection_bump_lightmap': Program 'frag_surf', cannot locate suitable resource to bind parameter "_ShadowCoord" at line 73

Keywords: DIRECTIONAL, LIGHTMAP_OFF, DIRLIGHTMAP_OFF, SHADOWS_SCREEN

There is no line 73

“doesn’t have (…)” tends to show up less if you don’t have an object selected that uses the shader.

Yeah, the location of the error also tends to be inaccurate. I think it refers to a compiled version of the code we don’t see.

“Cannot locate suitable resource to bind parameter”
It might have exceeded the maximum number of allowed interpolators/ semantics. (Do I remember that right?)

Yeah, you’re trying to pass to much data through the vertex shader. You get 8 interpolators and you’re using 9.

Of the stuff you’ve specified here;

struct Input {
    float2 uv_MainTex;
    float2 uv_BumpMap;
    float2 uv2_LightMap;
    float3 worldRefl;
    INTERNAL_DATA
};

INTERNAL_DATA breaks down into 3x float3 for transforming tangent-space to world-space.

Shadows and lighting require another 2 entries and are automatically added by Unity.

So once Unity’s finished with it, what it actually looks like is;

struct Input {
float2 uv_MainTex : TEXCOORD0;
float2 uv_BumpMap : TEXCOORD1;
float2 uv2_LightMap : TEXCOORD2;
float3 worldRefl : TEXCOORD3;
float3 TtoW1 : TEXCOORD4;
float3 TtoW2 : TEXCOORD5;
float3 TtoW3 : TEXCOORD6;
_LightCoord : TEXCOORD7;
_ShadowCoord : TEXCOORD8; < This one is too many for it to handle, you only get 8, which is 0-7.
}

So you need to find a way to remove one of those entries from the struct…

If you’re rolling your own vertex shader, you could combine your uv_MainTex and uv_BumpMap into one float4, rather than 2 float2s.

However, chances are that your normal map uses the same UVs as your diffuse map. So you can just remove
float2 uv_BumpMap;
from your struct and then sample the normal map using
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));