Shader Fallback Windows Store App

Hey guys,

I’m currently building a game for the windows store. I have a simple shader that always calls its FallBack shader once built into a Windows Store App. The shader works excellently in the editor and also on other devices but just not as a Windows Store App.

  • I have tried changing the the shader target model from 3.0 to both 4.0 & 5.0 with no results.

Shader “Reflective/Bumped Specular” {

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)
	_PatTex ("Base (RGB) RefStrGloss (A)", 2D) = "white" {}
	_Cube ("Reflection Cubemap", Cube) = "" { TexGen CubeReflect }
	_BumpMap ("Normalmap", 2D) = "bump" {}
}

SubShader {
	Tags { "RenderType"="Opaque" }
	LOD 400
	
	//CULL off
CGPROGRAM
#pragma surface surf BlinnPhong
#pragma target 3.0


sampler2D _PatTex;
sampler2D _BumpMap;
samplerCUBE _Cube;

fixed4 _Color;
fixed4 _ReflectColor;
half _Shininess;

struct Input {
	float2 uv_PatTex;
	float2 uv_BumpMap;
	float3 worldRefl;
	INTERNAL_DATA
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 tex = tex2D(_PatTex, IN.uv_PatTex);       	
   	
   	o.Albedo = lerp(_ReflectColor, tex.rgb, tex.a ).rgb;
   	
   	tex.a = 1.0f;
	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 * _Color.rgb;
	o.Alpha = reflcol.a * _Color.a;
}
ENDCG
}

FallBack "Reflective/Bumped Diffuse"

}

*** Any ideas?

My guess, is that the device you are testing it on may not actually support SM3 or higher… the default (and baseline requirement) for Windows Store Apps is SM2.0 4_0_level_9_1… or higher. And is therefore “falling back” to that which is probably compiled for everything under the sun.

So you probably will want to use the following pragma for testing:

#pragma only_renderers d3d11_9x d3d11
#pragma target 2.0

note: only_renderers is what I am currently using as I’ve restricted the shader only for windows devices (and in this case ARM [e.g.: surface RT]).

also, you can actually comment out the fallback while developing with that specific shader.

and finally, what you may need to do, (if you want to offer support for features in higher shader models), is to detect what the hardware actually supports that the game is running on and specify shaders at runtime.

hope that helps some.