I have a 62 instruction, Pixel Shader 3, shader that for some reason is failing to compile in the Unity web player on my Nvidia 8600 GTS.
I’ve provided a RenderMonkey example with the same code that works on the same machine.
I’ll attach the error log from my web player.
I get the same error on two different NVIDIA graphics cards.
I’ll attach a sample project in the next post.
D3D shader create error for shader ps_3_0
124224–4654–$foursplatblendwireframeshader_208.zip (22.6 KB)
Make sure to log it trough the bug reporter as well if you want the best odds of getting this looked at by unity devs.
Bye, Lucas
For some reason the workaround is as follows.
The texture lookups must occur before returning the wireframe color.
It seems like a waste to do texture lookups when you don’t need to but this works.
Shader "FourSplatBlendWireframeShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_LineColor ("Line Color", Color) = (1,1,1,1)
_LineWidth ("Line Width", float) = 0.04
}
SubShader {
Pass {
CGPROGRAM
#pragma target 3.0
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float4 _LineColor;
uniform float _LineWidth;
struct appdata {
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
float4 color : COLOR;
};
struct v2f {
float4 pos : POSITION;
float4 texcoord : TEXCOORD0;
float4 color : COLOR;
};
v2f vert (appdata v) {
v2f o;
o.pos = mul(glstate.matrix.mvp, v.vertex);
o.texcoord = v.texcoord;
o.color = v.color;
return o;
}
float4 GetTileColor(float height, float intensity, float2 uvs)
{
int index = int(height * 15.99);
int col = (index % 4); // 0 to 3
int row = int(height * 3.99); // to 0 to 3
uvs.x = (col+uvs.x)*0.25;
uvs.y = (row+uvs.y)*0.25;
float4 color = tex2D(_MainTex, uvs);
return lerp(float4(0,0,0,0), color, intensity);
}
float4 frag(v2f i) : COLOR
{
//define the final splat color
float4 final;
//get the splat colors
float2 uv = float2(i.texcoord.x, i.texcoord.y);
float4 tile1Color = GetTileColor(i.color.r, (1-i.texcoord.x) * (1-i.texcoord.y), uv);
float4 tile2Color = GetTileColor(i.color.g, i.texcoord.x * (1-i.texcoord.y), uv);
float4 tile3Color = GetTileColor(i.color.b, (1-i.texcoord.x) * i.texcoord.y, uv);
float4 tile4Color = GetTileColor(i.color.a, i.texcoord.x * i.texcoord.y, uv);
if (i.texcoord.x < _LineWidth ||
i.texcoord.y < _LineWidth)
{
return _LineColor;
}
if ((i.texcoord.x - i.texcoord.y) < _LineWidth
(i.texcoord.y - i.texcoord.x) < _LineWidth)
{
return _LineColor;
}
//final = tile1Color;
//final = tile2Color;
//final = tile3Color;
//final = tile4Color;
final = tile1Color + tile2Color + tile3Color + tile4Color;
return final;
}
ENDCG
}
}
Fallback "SimpleWireframeShader", 1
}