- Home /
Shader works in Editor Mode, breaks when running.
I have a shader that combines two textures based upon a projection matrix. This shader works fine in the editor but the uvs don't seem to map properly while the game is running. The texture is vertically compressed and tears at the bottom of the screen.
I rewrote the below shader as a cg shader and the effect was the same, vertically compressed and torn.
So what would cause a shader to behave differently in editor as opposed to in play mode in engine.
Shader "AngleCombine" {
Properties {
_MainTex ("Base (RGB) Gloss(A)", 2D) = "white" {}
_Other("Other", 2D) = "white" { }
}
Subshader {
Pass {
SetTexture[_MainTex] { combine texture }
SetTexture[_Other] {
matrix [_ProjMatrix]
combine texture * previous DOUBLE
}
}
}
Subshader {
Pass {
SetTexture [_MainTex] { combine texture }
}
}
}
Where are you setting _Proj$$anonymous$$atrix? Also, you don't ever need to use { combine texture }, if you care.
Answer by taoa · Apr 28, 2011 at 04:15 PM
It would look like your _ProjMatrix might be the only possible culprist.
How do you process it? How do you set it?
The _Proj$$anonymous$$atrix is set by a script that calculates it based upon the camera angle. It seems to calculate it properly because it displays properly in the the editor (it would be impossible for it to display like that without the _Proj$$anonymous$$atrix).
Answer by Fraser · Apr 28, 2011 at 05:12 PM
The issue was caused by the matrix not properly transforming at non-zero values. I still don't know why it behaved differently in editor than in game (as the object is static and never moves).