Jump to content
  • Advertisement
Sign in to follow this  
Pooya65

color saturation filter in HLSL

This topic is 3770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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);
}



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!