shader_effects["Wolkenmaske"] = {shader=basic_fsh..[[
uniform float daytime;
const vec2 ar = vec2(1.6, 0.9); //ASPECT RATIO
float cloudspeed = 0.0075;
vec2 cloudsize = vec2(0.33);
float cloudsoftness = 2.3-texcoord.x*2;
vec2 cloudmoveA = vec2(0.5, 0.0) * time * cloudspeed;
vec2 cloudmoveB = vec2(-0.2, 0.0) * time * cloudspeed;
vec2 Versatz = vec2(0.75,0.75);
void main()
{
vec2 uv = cloudsize * texcoord.xy;
vec4 colA = texture2D(iChannel0, fract(vec2(1.00) * uv.xy +cloudmoveA ) );
vec4 colB = texture2D(iChannel0, fract(vec2(1.11) * uv.xy +cloudmoveB +Versatz ) );
//ALTERNATIVELY CLAMP TEXTURE-COORDINATES -- very imperfect workaround...
// vec4 colA = texture2D(iChannel0, clamp( fract( vec2(1.00) * uv.xy +cloudmoveA ) ,0.0,0.99928) );
// vec4 colB = texture2D(iChannel0, clamp( fract( vec2(1.11) * uv.xy +cloudmoveB +Versatz ) ,0.0,0.99928) );
float wolkentransparenz = ((1.0+cos(daytime*0.5*3.142)) );
float subtraction = clamp(colA.r-colB.r, 0.0, 1.0) * wolkentransparenz;
vec4 finalColor = vec4( vec3(1.0) , pow( subtraction , cloudsoftness) );
float w = (0.75 - texcoord.x) *4;
float h = ( (daytime-0.21) - texcoord.y) *1;
float Sun = 2* pow( 1.0 - clamp( (sqrt(pow(w,2)+pow(h,2))/(0.5)), 0.0,1.0) , 10);
finalColor.a = abs(finalColor.a - Sun);
gl_FragColor = finalColor;
}
]]}
-----------------------------
local eff="Wolkenmaske"
local obj = "TestClouds"
local id = 2
-----------------------------
shaderAddEffect(eff)
shaderRemoveEffect(eff)
shader_effects[eff].num.strength=1
bind(eff, "time", field("shader_iTime"))
bind(eff, "daytime", field("Values.Daytime.Int"));
function updateWeltbildsonne()
shader_effects[eff].num.daytime = Values.Daytime.Int * 0.0125;
end
shaderSetOptions({{shader = shader_effects[eff].num(), comp_dst=5, comp_src=4 }}, id)
Objects[obj].ShaderSet = id
registerEventHandler("mainLoop", "updateWeltbildsonne")
local eff="Wolkenmaske"
local obj = "TestClouds"
local id = 2
-----------------------------
shaders[eff] = shader(eff, Shaders["ShaderName"].Compiled)
shaderAddEffect(eff)
shaderRemoveEffect(eff)
shader_effects[eff].num.strength=1
bind(eff, "time", field("shader_iTime"))
bind(eff, "daytime", field("Values.Daytime.Int * 0.0125"));
Objects[obj].ShaderSet = id
#ifdef GL_ES
precision lowp float;
precision lowp int;
#endif
uniform sampler2D texel;
varying vec2 uvVarying;
const float pi = 3.1415926535897932384626433832795;
uniform float daytime;
void main ()
{
float x = daytime;
float R = (0.75+sin((x-3.0)*0.5*pi + cos((x-3.0)*0.5*pi))*0.25);
float G = (0.75+0.125+cos(x*0.5*pi)*0.125);
float B = (0.75+0.125+cos(x*1.0*pi)*0.125);
vec3 col = vec3(R,G,B);
gl_FragColor = vec4(texture2D(texel, uvVarying.xy).rgb * col, 1.0);
}
local eff = "daynight"
shaders[eff] = shader(eff, Shaders[eff].Compiled)
shaderAddEffect(eff)
bind(eff, "daytime", field("Values.Daytime.Int"))
function updateDaynight()
shader_effects[eff].num.daytime = Values.Daytime.Int * 0.0125
end
registerEventHandler("mainLoop", "updateDaynight")
local eff = "Daynight"
shader_effects[eff] = { shader = Shaders[eff].Compiled }
shaderAddEffect(eff)
bind(eff, "daytime", field("getTime() * 0.00125"))
(P.S.: I know it is a little bizarre that I keep up the English in a Dialogue between two German-Speakers, but in Case other People encounter the same Problems, I think the Problems and their Solutions should be available to every User on the Forum, so I prefer to keep it up.)