Created
July 15, 2018 18:49
-
-
Save Andersama/68181d4ec9b22414e705769c9de4a434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform float4x4 ViewProj; | |
uniform texture2d image; | |
uniform float elapsed_time; | |
uniform float2 uv_offset; | |
uniform float2 uv_scale; | |
uniform float2 uv_pixel_interval; | |
sampler_state textureSampler { | |
Filter = Linear; | |
AddressU = Border; | |
AddressV = Border; | |
BorderColor = 00000000; | |
}; | |
sampler_state textureSampler_H { | |
Filter = Linear; | |
AddressU = Wrap; | |
AddressV = Border; | |
BorderColor = 00000000; | |
}; | |
sampler_state textureSampler_V { | |
Filter = Linear; | |
AddressU = Border; | |
AddressV = Wrap; | |
BorderColor = 00000000; | |
}; | |
struct VertData { | |
float4 pos : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
VertData mainTransform(VertData v_in) | |
{ | |
VertData vert_out; | |
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj); | |
vert_out.uv = v_in.uv * uv_scale + uv_offset; | |
return vert_out; | |
} | |
#define PI 3.141592653589793238462643383279502884197169399375105820974 | |
#define PIO3 1.047197551196597746154214461093167628065723133125035273658 | |
#define PI2O3 2.094395102393195492308428922186335256131446266250070547316 | |
float melScale(float freq){ | |
return 2595 * log10 (1 + freq / 700.0); | |
} | |
float hertzFromMel(float mel) { | |
return 700 * (pow(10, mel / 2595) - 1); | |
} | |
uniform texture2d audio <bool is_audio_source = true; bool is_fft = true; string window = "blackmann_harris";>; | |
uniform bool vertical; | |
float4 mainImage(VertData v_in) : TARGET | |
{ | |
float2 px; | |
float4 color; | |
if(vertical){ | |
px = float2((1 - distance(v_in.uv.y, 0.5) * 2), v_in.uv.x); | |
color = audio.Sample(textureSampler_V, px); | |
return color; | |
} else { | |
px = float2((1 - distance(v_in.uv.x, 0.5) * 2), v_in.uv.y); | |
color = audio.Sample(textureSampler_H, px); | |
return color; | |
} | |
} | |
technique Draw | |
{ | |
pass p0 | |
{ | |
vertex_shader = mainTransform(v_in); | |
pixel_shader = mainImage(v_in); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment