📄 ps_cross.fx
字号:
float4 PS_CrossCtr(float2 pos: TEXCOORD0) : COLOR
{
float2 Tex = pos + float2(0.0019607843 , 0.0019607843);
float2 Rpos = tex2D(ColorMapSamplerRand,Tex + offset1).rg;
float4 pick = tex2D(ColorMapSamplerRand,Rpos * offset2 + offset1);
if(pick.r <= pCross)
{
Rpos = tex2D(ColorMapSamplerRand,Tex + offset1).ba;
pick.r = tex2D(ColorMapSamplerPos,Rpos * offset2).r;
}
else
{
pick.r = 24;
}
if(pick.g <= pCross)
{
Rpos = tex2D(ColorMapSamplerRand,Tex + offset1).rg;
pick.g = tex2D(ColorMapSamplerPos,Rpos + offset2).g;
}
else
{
pick.g = 24;
}
if(pick.b <= pCross)
{
Rpos = tex2D(ColorMapSamplerRand,Tex + offset2).rg;
pick.b = tex2D(ColorMapSamplerPos,Rpos * offset1).b;
}
else
{
pick.b = 24;
}
if(pick.a <= pCross)
{
Rpos = tex2D(ColorMapSamplerRand,Tex + offset2).ba;
pick.a = tex2D(ColorMapSamplerPos,Rpos + offset1).a;
}
else
{
pick.a = 24;
}
return pick;
}
technique TShader_CrossCtr
{
pass P0
{
Sampler[0] = (ColorMapSamplerRand);
Sampler[1] = (ColorMapSamplerPos);
PixelShader = compile ps_3_0 PS_CrossCtr();
}
}
float GetGene(float p, float x1, float x2)
{
float x = 0 ;
int j = 0 ;
float temp;
if(p >= 24.0 && p <= 0)
return x2;
else
{
for(j = 23 ; j >= p; j--)
{
temp = pow(2 , j);
if((x1 - temp) >= 0)
{
x += temp;
x1 -= temp;
}
if((x2 - temp) >= 0)
{
x2 -= temp;
}
}
for(j = p ; j >= 0 ; j-- )
{
temp = pow(2 , j);
if((x2 - temp) >= 0)
{
x += temp;
x2 -= temp;
}
}
return x;
}
}
float4 PS_Cross(float2 pos: TEXCOORD0) : COLOR
{
float2 Tex = pos + float2(0.0019607843 , 0.0019607843);
float4 CrossCtr = tex2D(ColorMapSamplerCrossCtr,Tex);
float4 x1 ;
float4 x2 ;
float4 Gene;
int i =( h * Tex.y + Tex.x) * w ;
if(i % 2 == 0)
{
x1 = tex2D(ColorMapSamplerGene,Tex + float2(dw,0));
x2 = tex2D(ColorMapSamplerGene,Tex);
}
else
{
x1 = tex2D(ColorMapSamplerGene,Tex);
x2 = tex2D(ColorMapSamplerGene,Tex + float2(-dw,0));
}
Gene.r = GetGene(CrossCtr.r , x1.r , x2.r);
Gene.g = GetGene(CrossCtr.g , x1.g , x2.g);
Gene.b = GetGene(CrossCtr.b , x1.b , x2.b);
Gene.a = GetGene(CrossCtr.a , x1.a , x2.a);
return Gene;
}
technique TShader_Cross
{
pass P0
{
Sampler[0] = (ColorMapSamplerGene);
Sampler[1] = (ColorMapSamplerCrossCtr);
PixelShader = compile ps_3_0 PS_Cross();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -