[Request] Shadertoy Conversion(MultiChannel) - Sample texture to use the color palette on a image

0 favourites
  • 4 posts
From the Asset Store
Get instant inspiration with this drum sample pack!
  • Hi Gigatron ,

    This shader can be done in COnstruct2?

    shadertoy.com/view/lsGBRK

    If i remember well, contruct 2 is not able to work with shaders with multiple channels/images as far as i know, i guess you told me the same but not sure now.

    What this shaders does is what we tried months ago, apply a color palete based on a texture to an image.

    Is possible?

    Also maybe R0J0hound , Ashley know if is possible?

    I tried with the Gigatron converter that gives me this:

    #ifdef GL_ES
    precision mediump float;
    #endif
    
    #extension GL_OES_standard_derivatives : disable
    
    //// START C2 UNIFORMS HEADER ////
    
    uniform sampler2D samplerBack;
    uniform sampler2D samplerFront;
    varying vec2 vTex;
    uniform vec2 destStart;
    uniform vec2 destEnd;
    uniform float seconds;
    uniform float pixelWidth;
    uniform float pixelHeight;
    vec2 iResolution = vec2( 1./pixelWidth, 1./pixelHeight);
    
    //// END C2 HEADER ////
    
    
    
    // samplerFront = source image
    // iChannel1 = palette image (should be 1-dimensional)
    
    #define BRIGHTNESS 1.0
    #define NUMCOLORS 16.0
    
    vec3 find_closest (vec3 ref) {	
    	vec3 old = vec3 (100.0*255.0);		
    	#define TRY_COLOR(new) old = mix (new, old, step (length (old-ref), length (new-ref)));	
     for (float i = 0.0; i < 1.0; i+=1.0/NUMCOLORS) {
     TRY_COLOR(texture2D(iChannel1, vec2(i,0.4)).rgb * BRIGHTNESS);
     }
     
    	return old ;
    }
    
    
    void main()
    {
    	vec2 uv = gl_FragCoord.xy / iResolution.xy;
    	vec3 tc = texture2D(samplerFront, uv).xyz;
    	gl_FragColor = vec4(find_closest(tc),1.0);		
    
    

    But lots of erros i can't solve :S

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can play with bg blend with here.

    You can not change the number of color on the fly.. when for loop is running

    the value must be constant..fixed ; advantage is writing less code

    but val must be constant .. or test every color like you made in the past.

    gigatron3k.free.fr/html5/C2/FX/cmp3.rar

    have fun

  • The solution for C2 is the first channel0 must be

    sprite1 image0

    channel 1 sprite1 image1

    channel 2 sprite2 image2

    channel 3 sprite3 image3

    like SamplerFront,SamplerFront1,SamplerFront2,SamplerFront3.

    etc....

  • CmapFX is a nice new addition to the effect lib.

    Thanks for sharing Gigatron!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)