How to code a Colorlize filter by shader?

Wrong.

A good approximation is:
brightness = 0.3*red + 0.6*green + 0.1*blue

No.
I already know that.....
But I don't want to get the brightness value of the pixel A.
I want to have another pixel B that have the same brightness as A.

-----------------------------------------
I have seen the codes of Ycocg from nvidia's site.
The code is simple, but no artist tools for convert dds file from rgb to ycocg.
 
Try this:

Code:
	float intensity = tex2D(intensitySampler, texcoords);
	float3 color = tex2D(colorSampler, texcoords);
	
	float3 hueAndSat = color - dot(color, float3(0.33333333, 0.3333333, 0.3333333));
	return float4(hueAndSat + intensity.xxx, 1);

It works by removing the intensity from the color texture and replacing it with the intensity texture. hueAndSat is the projection of the color onto the intensity=0 plane.
 
Thanks a lot.

First try to palette textures using texture lookup
I think it's easier than color space tricks.

//======================================
uniform sampler2D idx; // image in gray color as index
uniform sampler2D pal; // 256X4 Map as palletize map.
// It's a grad map , white to black,
// then colorize it in photoshop
varying vec2 UV;
void main(void)
{
float index = texture2D(idx, UV).y; //get index , a float between 0.0~1.0
vec2 newUV = vec2(1.0-index , 0.0); //use index as UV.x
newUV.x = clamp(newUV.x , 0.1 , 0.9);
vec4 color = texture2D(pal,newUV); //get palletize color
gl_FragColor = vec4(color.xyz, index.w); //done
}
//======================================
 
enemy engaged comanche vs hokum uses the method of a colorised grey texture for its terrain
its open source too
 
Back
Top