color saturation filter in HLSL

Started by
4 comments, last by Ceoddyn 15 years, 8 months ago
i cant translate this effect to the HLSL, plz help me ps.1.1 def c0, 1.0, 1.0, 1.0, 1.0 def c1, 0.3, 0.59, 0.11, 0.5 tex t0 // sample the source image mov_x4_sat r0.rgb, t0_bx2 // saturate dp3_sat r1.rgba, r0, c0 // do we have any bright colors? dp3 r1.rgb, t0, c1 // greyscale lrp r0.rgb, r1.a, r0, r1 // interpolate between color and greyscale + mov r0.a, t0.a // output alpha
Advertisement
Never really worked with ps_1_1 asm, but from looking at the documentation I think the HLSL would look like this...

sampler2D texSampler : register (s0);static const float3 greyScaleConversion = {0.3f, 0.59f, 0.11f};float PS( in texCoord : TEXCOORD0 ) : COLOR0{	float4 sampleColor = tex2D(texSampler, texCoord)	float3 saturated = clamp(sampleColor.rgb * 4.0f);	float bright = saturate(saturated, float3(1, 1, 1));	float3 greyScale = dot(sampleColor.rgb, greyScaleConversion);	float3 lerped = lerp(saturated, greyscale, bright);	return float4(lerped, sampleColor.a);}
Quote:Original post by MJP
float3 saturated = clamp(sampleColor.rgb * 4.0f);

I think you need *8 - 4 to simulate the _BX2 modifier.

Quote:Original post by Namethatnobodyelsetook
Quote:Original post by MJP
float3 saturated = clamp(sampleColor.rgb * 4.0f);

I think you need *8 - 4 to simulate the _BX2 modifier.


Shoot, you're right. Nice catch.

what is saturate function do?

this function have any equivalent in the GLSL?
clamps the values range from 0 to 1

This topic is closed to new replies.

Advertisement