Напиши код для kotlin, который позволит запустить следующий шейдер: #ifdef…
- User
Напиши код для kotlin, который позволит запустить следующий шейдер: #ifdef GL_FRAGMENT_PRECISION_HIGH precision highp float; #else precision mediump float; #endif
uniform float time; uniform vec2 resolution;
void main( void ) { vec2 pos = -1. + 2.*gl_FragCoord.xy / resolution.xy; pos *= vec2(resolution.x / resolution.y, 1.) * 3.;
// The vibration of the fire if(pos.y>-2.4.2) { for(float baud = 1.; baud < 9.; baud += 1.) { pos.y += 0.2sin(4.20time/(1.+baud))/(1.+baud); pos.x += 0.1cos(pos.y/4.20+2.40time/(1.+baud))/(1.+baud); } pos.y += 0.04fract(sin(time*60.)); }
// Fire flame vec3 color = vec3(0.,0.,0.); float p =.004; float y = -pow(abs(pos.x), 4.2)/p; // The shape of the outer flame, note that the negative pos.x will be truncated float dir = abs(pos.y - y)sin(.3); // The size of the outer flame (expanding the gradient area) //float dir = abs(pos.y - y)(0.01*sin(time)+0.07); if(dir < 0.7) { color.rg += smoothstep(0.,1.,.75-dir); // outer flame color gradient color.g /=2.4; // minus green } color *= (0.2 + abs(pos.y/4.2 + 4.2)/4.2); // increase the contrast color += pow(color.r, 1.1); // add a little red color = cos(-0.5+pos.y0.4); // hide the color at the bottom
// Flame inside flame pos.y += 1.5; vec3 dolor = vec3(0.,0.,0.0); y = -pow(abs(pos.x), 4.2)/(4.2*p)*4.2; // The shape of the inner flame, the power of attention and the outer flame, the closer it is, the less likely it is to wear dir = abs(pos.y - y)*sin(1.1); // The size of the inner flame (expanding the gradient area) if(dir < 0.7) { dolor.bg += smoothstep(0., 1., .75-dir);// inner flame color gradient dolor.g /=2.4; } dolor *= (0.2 + abs((pos.y/4.2+4.2))/4.2); dolor += pow(color.b,1.1); // add some blue dolor = cos(-0.6+pos.y0.4); //dolor.rgb -= pow(length(dolor)/16., 0.5);
color = (color+dolor)/2.; gl_FragColor = vec4(vec3(color) , 1.0 );
}
- Assistant