well, I see...
Guck dir einfach mal an was ein
Function Plotter da ausgibt, wenn du deine Funktion:
(((x)-0.5)*1.2)+0.5*0.95
zusammen mit meiner
x^2*(3-2*x)
zeichnen lässt.
(Bereich zwischen 0 und 1 ist entscheident, alle Werte außerhalb werden auf 0 und 1 geclamped)
Wie du sehen kannst schneidet deine Funktion Werte ab bestimmten min und max Schwellen einfach ab
und verläuft auch nicht durch (0.5|0.5) sondern macht die Szene tendenziell dunkler (liegt am 0.95).
Wenns dir darum geht die Stärke einstellen zu können, kann ich dir noch folgendes anbieten:
texture TargetMap;
float fContrast=0.7;//between 0..1
sampler COLOR_SAMPLER = sampler_state { Texture = <TargetMap>; MinFilter = Linear; MagFilter = Linear; MipFilter = None;};
float3 local_contrast(float3 color)
{
return color*color*(3-2*color);
}
void PS(
in float2 Tex : TEXCOORD0,
out float4 COL : COLOR0
)
{
COL.rgb=tex2D(COLOR_SAMPLER,Tex).rgb;
float3 max_contrast_color=local_contrast(COL.rgb);
//max_contrast_color=local_contrast(max_contrast_color);//add even more contrast if needed
COL.rgb=lerp(COL.rgb,max_contrast_color,fContrast);//blend between original color and maximal contrast
COL.a=1;
}
technique Shading
{
pass one
{
PixelShader = compile ps_2_0 PS();
}
}