~npisanti/rsk_tools

9ee95e959a219e79c421b7328a8d9ae098bcc09f — Nicola Pisanti 4 months ago 2764c64
returns to book of shaders syntax
5 files changed, 34 insertions(+), 27 deletions(-)

M cereal/process.frag
M eye/process.frag
M framescan/process.frag
M shader/main.lua
M tilecutter/process.frag
M cereal/process.frag => cereal/process.frag +7 -8
@@ 1,19 1,18 @@
#version 100

#ifdef GL_ES
precision highp float;
#endif

varying vec2 st;
uniform sampler2D texture0;
uniform float time;
uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D u_tex0;

void main(){

	vec2 stl = st;
	stl.x += 0.4;
    vec2 st = gl_FragCoord.xy/u_resolution;
    
	st.x += 0.4;
	
    vec4 source = texture2D( texture0, stl ); // for texture access
    vec4 source = texture2D( texture0, st ); // for texture access
    vec3 color = source.rgb;
    float luminance = color.r*0.299 + color.g*0.587 + color.b*0.114;	


M eye/process.frag => eye/process.frag +4 -4
@@ 1,13 1,14 @@
#version 100

#ifdef GL_ES
precision highp float;
#endif

varying vec2 st;
uniform sampler2D texture0;
uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D u_tex0;

void main(){
    vec2 st = gl_FragCoord.xy/u_resolution;
    
    //st.x = 1.0-st.x; // flip horizontally 
    //st.y = 1.0-st.y;  // flip vertically 


@@ 22,5 23,4 @@ void main(){
    float alpha = smoothstep( low, high, luminance );
    
    gl_FragColor = vec4( vec3(alpha), 1.0 );
    // gl_FragColor = vec4( 1.0, 1.0, 1.0, alpha );
}

M framescan/process.frag => framescan/process.frag +8 -9
@@ 1,23 1,22 @@
#version 100

#ifdef GL_ES
precision highp float;
#endif

varying vec2 st;
uniform sampler2D texture0;
uniform float time;
uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D u_tex0;

uniform float u_low;
uniform float u_high;

void main(){
    vec2 stl = st;
    vec2 st = gl_FragCoord.xy/u_resolution;
    
	st.x = 1.0 - st.x;
	st.y = 1.0 - st.y;

	stl.x = 1.0 - st.x;
	stl.y = 1.0 - st.y;

    vec4 source = texture2D( texture0, stl ); 
    vec4 source = texture2D( u_tex0, st ); 
    vec3 color = source.rgb;
    float luminance = color.r*0.299 + color.g*0.587 + color.b*0.114;	


M shader/main.lua => shader/main.lua +10 -1
@@ 9,9 9,18 @@ if args.count() > 0 then
    frag.load( args.get(0), "glsl" ) 
end    

window.size( 480, 480 )
local w = 480 
local h = 480

if args.count() > 2 then
	w = tonumber( args.get(1) )
	h = tonumber( args.get(2) )
end

window.size( w, h )
layer.create( "def" )


----------------------------------------------------
function loop()
    layer.open()

M tilecutter/process.frag => tilecutter/process.frag +5 -5
@@ 1,17 1,17 @@
#version 100

#ifdef GL_ES
precision highp float;
#endif

varying vec2 st;
uniform sampler2D texture0;
uniform float time;

uniform float u_low;
uniform float u_high;

uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D u_tex0;

void main(){
    vec2 st = gl_FragCoord.xy/u_resolution;

    vec4 source = texture2D( texture0, st ); // for texture access
    vec3 color = source.rgb;