📄 ps_mutation.fx
字号:
float GetGene(float x1, float2 pos)
{
float x = 0 ;
int j = 0 ;
float RandValue;
float2 Rpos;
for(j = 23 ; j >= 0; j--)
{
Rpos = tex2D(ColorMapSamplerRand,pos + offset2 * j / 23.0).rg;
RandValue = tex2D(ColorMapSamplerRand,Rpos * offset2 + offset1 * j / 23.0).b;
if(RandValue < pMutation)
{
if((x1 - pow(2 , j)) < 0)
{
x += pow(2 , j);
}
else
{
x1 -= pow(2 , j);
}
}
else
{
if((x1 - pow(2 , j)) >= 0)
{
x += pow(2 , j);
x1 -= pow(2 , j);
}
}
}
return x;
}
float4 PS_Mutation(float2 pos: TEXCOORD0) : COLOR
{
float2 Tex = pos + float2(0.0019607843 , 0.0019607843);
float2 pickPos;
float4 x = tex2D(ColorMapSamplerGene,Tex);
float4 Gene;
pickPos = tex2D(ColorMapSamplerRand,Tex + offset2).ba;
Gene.r = GetGene(x.r,pickPos);
pickPos = tex2D(ColorMapSamplerRand,Tex + offset2).rg;
Gene.g = GetGene(x.g,Tex);
pickPos = tex2D(ColorMapSamplerRand,Tex + offset1).ba;
Gene.b = GetGene(x.b,Tex);
pickPos = tex2D(ColorMapSamplerRand,Tex + offset1).rg;
Gene.a = GetGene(x.a,Tex);
return Gene;
}
technique TShader_Mutation
{
pass P0
{
Sampler[0] = (ColorMapSamplerRand);
Sampler[1] = (ColorMapSamplerGene);
PixelShader = compile ps_3_0 PS_Mutation();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -