1)i have 13 temporary register and unity tell me he wants 12. i don’t want to go to shader 3.0, is there a solution?
i don’t really understand what is a temporary register but i try to delete, move, replacer some line but the shader effect is not what i want when i do that.
my shader contain 2 megatextures with red,green,blue . little textures are placed on a big plane according to each value of color of the big texture:
half 4 color Tex2D_MyBIGTEXTUREtoDISTRIBUTElittleTexture
Tex2D_1 * color.b + Tex2D_2 * color.r + Tex2D_3 * color.g
i tried : lerp( lerp(Tex2D_1,Tex2D_2,color.b) , Tex2D_3, color.g) but temporary register don’t decrease.
if i delete for example Tex2D_3 * color.g , it’s okay with temp register.
2)i need to use if else with a z index of the pixel with 3-4 steps:
if z<0 //color in black
if z>0 z<1 //color in red
if z>1 z<4 //color in whatyouwant
if z>4 //color in …
if there was only two, i could use lerp with z factor but i need clear steps and not smooth transition.
maybe i need to use something like : ?
lerp( lerp( lerp(red,black, z-index-2) , yellow, z-index-4 ) , blue, z-index-5 );
That’s not really Unity, that’s one of the shader compilers we use (Cg or HLSL or …) and it can’t figure out a way to fit your shader code into 12 temporary registers (which is the shader model 2.0 limit). One solution is to make the limit higher (shader model 3.0); another is to optimize or simplify your shader so it would use less registers.
Not sure I understood what you’re trying to achieve here at all.
for the problem of register, i see in a other shader that it’s maybe better to store in a variable like “albedo” before to send it with o.Albedo at the end
and using fixed3 albedo since i don’t use alpha is maybe lighter.
and that’s good for temp register!
for the z-index things, it’s just a Branch problem with 5 possibilities according to z-index and i think shader don’t like this type of branch.
i wonder if there was a better way to branch z-index.
now i have :
if( Worldpos.z <0) {
o.Albedo = tex2D_1
else if(Worldpos.z >0 Worldpos.z<10) {
o.Albedo = tex2D_2
else if(Worldpos.z >10) {
o.Albedo = tex2D_3
}
and i think it’s too heavy!
lerp would be good for that but i don’t know how to do it