Danke für deinen Input scheichs, womöglich hast du recht. Nur ich glaube das Portieren wäre nicht so eine einfache Geschichte, wissen tue ich das nicht. Vermutlich fange ich besser bei null an mit einem neuen Projekt. Meine Tech ist schon arg limitierend, aber es ist halt was ich habe. Ziel ist es in zwei Monaten das Ding rauszuhauen, sonst wird es zu nem Endlosprojekt. Aufregen werde ich mich genug in der Zeit, hoffentlich gibts auch ein paar Jubelschreie :lol:
Ich rede mir manchmal gut zu und sage: Es gibt erfolgreiche Projekte die eine fixe Framerate von 30 haben (nuclear throne).
Interessant an meinem jetztigen Problem ist allerdings, dass ich mit der GPU kämpfe. Der Einfachheit halber hat es noch ein paar Branches im Shader, eventuell könnten die ein Teil vom Problem sein.
Ich schäme mich etwas für den code :P aber kann es ja mal posten. Warscheinlich lacht ihr euch einen ab :D
Code: Alles auswählen
//bg_1
precision mediump float;
uniform vec2 u_resolution;
uniform float u_time;
uniform float u_sandtime;
uniform float u_sandscale;
uniform float u_sandopacity;
uniform float u_sandoffset;
uniform vec4 u_sandpos;
uniform vec4 u_sandbump;
uniform vec4 u_sandcol;
uniform vec4 u_enva;
uniform vec4 u_envm;
varying vec2 v_tex;
varying vec2 v_coord;
varying vec2 v_size;
varying float v_mode;
varying vec2 v_pos;
uniform vec2 u_imagesize;
uniform sampler2D u_image;
uniform sampler2D u_fb;
vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main(void) {
//mode bestimmt wie ein poly gezeichnet wird
float stp = step(0.0,v_mode);
float mode = mix(-(v_mode+1.0), v_mode, stp);
vec2 pos = v_coord + v_tex * v_size;
//hässlicher branch
if(mode>53000.0) {
//sand code, wird ausgeführt wenn der framebuffer aufs canvas gezeichnet wird
float dune = 0.0;
float base = 1.0;
if (u_sandopacity != 0.0) {
float opacity = abs(u_sandopacity);
float time = u_sandtime;
float offset = u_sandoffset;
float choice = sign(u_sandopacity) * 0.5 + 0.5;
vec4 tpos = mix(u_sandbump, u_sandpos, choice);
dune = (0.4 + 0.4*texture2D(u_image, (tpos.ba + mod((pos-time*0.0037)*tpos.rg*2.288*u_sandscale,tpos.rg))/u_imagesize).r)
* (offset + opacity*texture2D(u_image, (tpos.ba + mod((pos-time*0.0227)*tpos.rg*4.8*u_sandscale,tpos.rg))/u_imagesize).r
//* (texture2D(u_image, (tpos.ba + mod((pos+time*0.00061)*tpos.rg*0.2*u_sandscale,tpos.rg))/u_imagesize).r*2.0)-0.25)
* (texture2D(u_image, (tpos.ba + mod((pos+time*0.01187)*tpos.rg*1.31*u_sandscale,tpos.rg))/u_imagesize).r*1.5)-0.25)
+ texture2D(u_image, (tpos.ba + mod((pos-time*0.12327)*tpos.rg*11.8*u_sandscale,tpos.rg))/u_imagesize).r*0.06;
//dune *= v_tex.x;
base = mix(max(0.0, 1.0-dune), 1.0-dune, choice);
}
vec4 c = texture2D(u_fb, pos);
c = c*base + dune*u_sandcol;
if(u_envm.r>0.0) c.rgb = c.rgb * u_envm.rgb + u_enva.rgb;
gl_FragColor = c;
}
else
{
//code für splatter effekte die auf den hintergrund gezeichnet werden (unter sand)
vec4 c = texture2D(u_image, pos);
float dec = floor(mode);
mode = fract(mode);
float smode = fract(mode*10.0);
float sat = mix( u_envm.a, u_enva.a, stp);
float nmode = 1.0-smode;
//0.9<mode additive blending
c.a *= (mode>0.9) ? nmode : 1.0;
//0.8<mode<=0.9 saturation
sat *= (mode>0.8 && mode<=0.9) ? smode : 1.0;
//0.6<mode<=0.7 make red
c.rgb = (mode>0.6 && mode<=0.7) ? c.rgb*nmode + vec3(min(c.r+c.g+c.b,1.0)*smode* c.a, 0.0, 0.0) : c.rgb;
//0.4<mode<=0.5 brightness
c.rgb *= (mode>0.4 && mode<=0.5) ? (1.0+c.a*9.0)*max(smode-0.1,0.0) : 1.0;
float cen = mod(dec,1000.0);
float d = (dec/1000.0);
float alpha = floor(d)/50.0;
if(alpha>0.0){
c.rgba *= alpha;
}
float condition = float(cen>=500.0);
float l = min(min(c.r,c.g),c.b);
vec3 lvec = vec3(l,l,l);
vec3 lcol = c.rgb-lvec;
float m = mix(1.0,c.r-l,condition);
vec3 ref = mix(lcol,vec3(1.0,0.0,0.0),condition);
vec3 hsv = rgb2hsv(ref);
float hue = fract(cen/100.0);
hsv.x += hue;
//hsv.z *= huez; //könnte auch zum abdunkeln verwendet werden
hsv.y*=sat;
//abdunkeln, 5 stufen 500 weiss - 900 schwarz
float dark = mod(cen,500.0);
float gray = 1.25-(dark/400.00);
vec3 tmp = mix(hsv2rgb(hsv),vec3(gray,gray,gray),(1.0-mod(hue*33.0,1.0))*condition);
tmp *= mix(1.0,gray,float(cen>=100.0));
c.rgb = vec3(l,l,l) + tmp*m;
gl_FragColor = c;
}
}