Shader_Minifier
Shader_Minifier copied to clipboard
Strip unused global functions and vars
Any chance of adding a separate option for this?
Input:
float f(){
float r = 1.;
return r;
}
vec2 pos = vec2(0.5);
void main(){
gl_FragColor = vec4(1.);
}
Current output:
float n(){return 1.;}vec2 r=vec2(.5);void main(){gl_FragColor=vec4(1.);}
Desired:
void main(){gl_FragColor=vec4(1.);}
Partially implemented in #182, more work is needed.
Also it should be extended to remove unused overloads
Input example:
#version 300 es
/*
contributors: [Stefan Gustavson, Ian McEwan]
description: modulus of 289
use: mod289(<float|vec2|vec3|vec4> x)
*/
// #ifndef FNC_MOD289
// #define FNC_MOD289
float mod289(const in float x) { return x - floor(x * (1. / 289.)) * 289.; }
vec2 mod289(const in vec2 x) { return x - floor(x * (1. / 289.)) * 289.; }
vec3 mod289(const in vec3 x) { return x - floor(x * (1. / 289.)) * 289.; }
vec4 mod289(const in vec4 x) { return x - floor(x * (1. / 289.)) * 289.; }
// #endif
in vec4 v_aaa;
out vec4 color;
void main(){
color = mod289(v_aaa);
}
Current output (1.3.6):
#version 300 es
float v(const float v)
{
return v-floor(v*(1./289.))*289.;
}
vec2 v(const vec2 v)
{
return v-floor(v*(1./289.))*289.;
}
vec3 v(const vec3 v)
{
return v-floor(v*(1./289.))*289.;
}
vec4 v(const vec4 v)
{
return v-floor(v*(1./289.))*289.;
}
in vec4 v_aaa;
out vec4 color;
void main()
{
color=v(v_aaa);
}