Jump to content
  • Advertisement
Sign in to follow this  
wesleybobato

Chroma key source code - user Digitalfragment

This topic is 915 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

Hello guys
 
 I found an error in this code because manhattanDistance need 2 parameter
 what would be the second parameter (RGB1 and RGB2)
 
 float dist = smoothstep (0, threshold, manhattanDistance (chromakeyColor, ??????));
 
 
 float manhattanDistance (float3 RGB1, RGB2 float3)
 {
 float3 dist3 = abs (RGB 1-RGB2);
 return dot (dist3, float3 (1,1,1));
 }
 
 float4 chromakey (float3 pixelrgb, float3 chromakeyColor, float threshold)
 {
 float dist = smoothstep (0, threshold, manhattanDistance (chromakeyColor));
 float alpha = 1.0 - saturate (dist);
 return float4 (pixelrgb, alpha);
 }
 
 Thanks for listening.

Share this post


Link to post
Share on other sites
Advertisement


what would be the second parameter (RGB1 and RGB2)

float dist = smoothstep (0, threshold, manhattanDistance (chromakeyColor, ??????));

 

It should be 'pixelrgb', as the whole idea of chroma key is to compare pixel color against selected color key.

Share this post


Link to post
Share on other sites


You have something to Chroma Key to please help me?

Sorry, I don't get what you're asking.

If you need material to test your sw, ask google about  "green screen".

There was a lot of samples, including Van Damme pretending shooting, Shia LaBeouf yelling "do it", etc.

Share this post


Link to post
Share on other sites
A Help With My Code does not work

 

please

 

float4 main(float2 uv : TEXCOORD) : COLOR
 {
  float4 color = tex2D( inputSampler, uv ); //Capture image Colors...
  color.rgb    = RGBtoHSL( color );
  
  float3 colordistance = chromaKey( color.rgb, RGBtoHSL( float3( 0.47, 0.98, 0.00 ) ) , 0 ); 

  if ( all( abs( color.rgb - colordistance.rgb ) < ( Tolerance ) ) )
   color.rgba = 0;

  color.rgb = HSLtoRGB( color ); //Convert HSV to RGB...
  return color;
 }

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!