Tutorial Hue Rotation

GTR

New Member
Tutorial Author
Joined
Sep 23, 2020
So for next tutorial i give the code of the huerotator, please try to implement this.

Cerberus X:
/* Simple hue rotation filter based on article:
http://beesbuzz.biz/code/hsv_color_transforms.php
Author Daniil from shadertoy
GTR 2020  for CX
*/
uniform sampler2D Texture;

uniform float timer;
uniform float speed;
uniform float freq;
uniform float amp;
 
void shader(){

    //convert clip position to valid tex coords
 
    vec2 uv = (b3d_ClipPosition.st/b3d_ClipPosition.w)*0.5+0.5;
      
    
    float c = cos(timer*speed);
    float s = sin(timer*speed);
    
    mat4 hueRotation =   
                    mat4(      0.299,  0.587,  0.114, 0.0,
                             0.299,  0.587,  0.114, 0.0,
                             0.299,  0.587,  0.114, 0.0,
                                0.000,  0.000,  0.000, 1.0) +
        
                    mat4(     0.701, -0.587, -0.114, 0.0,
                            -0.299,  0.413, -0.114, 0.0,
                            -0.300, -0.588,  0.886, 0.0,
                              0.000,  0.000,  0.000, 0.0) * c +
        
                    mat4(     0.168,  0.330, -0.497, 0.0,
                            -0.328,  0.035,  0.292, 0.0,
                             1.250, -1.050, -0.203, 0.0,
                             0.000,  0.000,  0.000, 0.0) * s;
    
    vec4 pixel = texture2D(Texture, uv);

    
    
    
    
    //write output
    b3d_FragColor=vec4( pixel * hueRotation );
}
You must obtain this : http://gigatron3k.free.fr/html5/CX/huerotation/CerberusGame.html

I will edit this post soon with cxs code, until now good luck :)

Regards
 
Top Bottom