18 lines
6.0 KiB
Plaintext
18 lines
6.0 KiB
Plaintext
{
|
|
"ver": "1.0.27",
|
|
"uuid": "a6c19db7-43a2-469e-8162-b76b5c2d7b0f",
|
|
"importer": "effect",
|
|
"compiledShaders": [
|
|
{
|
|
"glsl1": {
|
|
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nattribute vec2 a_uv0;\nvarying vec4 v_color;\nvarying vec2 v_uv0;\nvoid main () {\n vec4 pos = vec4(a_position, 1.0);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n gl_Position = pos;\n v_color = a_color;\n v_uv0 = a_uv0;\n}",
|
|
"frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\nvarying vec4 v_color;\nvarying vec2 v_uv0;\nuniform sampler2D texture;\nuniform vec4 uvRect;\nuniform vec4 water;\nuniform float uvRotated;\nvoid main () {\n vec2 uv = (v_uv0 - uvRect.xy) / max(uvRect.zw, vec2(0.00001));\n if (uvRotated > 0.5) uv = vec2(uv.y, 1.0 - uv.x);\n vec4 base = vec4(1.0);\n {\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n base.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n base.a *= texture_tmp.a;\n #else\n base *= texture_tmp;\n #endif\n }\n float phase = uv.x * 7.5 - water.y * 1.8;\n float envelope = 4.0 * uv.y * (1.0 - uv.y);\n vec2 drift = vec2(0.0, 0.75 * sin(phase + uv.y * 3.0));\n vec2 flowingUV = clamp(uv + drift * water.z * envelope, vec2(0.001), vec2(0.999));\n if (uvRotated > 0.5) flowingUV = vec2(1.0 - flowingUV.y, flowingUV.x);\n vec4 flowing = vec4(1.0);\n {\n vec4 texture_tmp = texture2D(texture, uvRect.xy + flowingUV * uvRect.zw);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, uvRect.xy + flowingUV * uvRect.zw + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n flowing.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n flowing.a *= texture_tmp.a;\n #else\n flowing *= texture_tmp;\n #endif\n }\n vec4 color = vec4(mix(base.rgb, flowing.rgb, flowing.a), base.a);\n float amplitude = water.z * smoothstep(0.0, 0.08, water.x)\n * smoothstep(0.0, 0.08, 1.0 - water.x);\n float wave = amplitude * sin(phase);\n float surface = water.x + wave;\n float height = 1.0 - uv.y;\n float distanceToSurface = height - surface;\n float feather = water.w;\n #if CC_SUPPORT_standard_derivatives\n feather = max(0.75 * fwidth(distanceToSurface), 0.00001);\n #endif\n if (water.x <= 0.0) {\n color.a = 0.0;\n } else if (water.x < 1.0) {\n color.a *= 1.0 - smoothstep(-feather, feather, distanceToSurface);\n float rim = 1.0 - smoothstep(0.0, feather, abs(distanceToSurface));\n color.rgb = mix(color.rgb, vec3(1.0, 0.98, 0.88), rim * 0.08);\n }\n color *= v_color;\n #if USE_BGRA\n gl_FragColor = color.bgra;\n #else\n gl_FragColor = color;\n #endif\n}"
|
|
},
|
|
"glsl3": {
|
|
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nin vec2 a_uv0;\nout vec4 v_color;\nout vec2 v_uv0;\nvoid main () {\n vec4 pos = vec4(a_position, 1.0);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n gl_Position = pos;\n v_color = a_color;\n v_uv0 = a_uv0;\n}",
|
|
"frag": "\n#if CC_SUPPORT_standard_derivatives\n #extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\nin vec4 v_color;\nin vec2 v_uv0;\nuniform sampler2D texture;\nuniform WaterProperties {\n vec4 uvRect;\n vec4 water;\n float uvRotated;\n};\nvoid main () {\n vec2 uv = (v_uv0 - uvRect.xy) / max(uvRect.zw, vec2(0.00001));\n if (uvRotated > 0.5) uv = vec2(uv.y, 1.0 - uv.x);\n vec4 base = vec4(1.0);\n {\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n base.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n base.a *= texture_tmp.a;\n #else\n base *= texture_tmp;\n #endif\n }\n float phase = uv.x * 7.5 - water.y * 1.8;\n float envelope = 4.0 * uv.y * (1.0 - uv.y);\n vec2 drift = vec2(0.0, 0.75 * sin(phase + uv.y * 3.0));\n vec2 flowingUV = clamp(uv + drift * water.z * envelope, vec2(0.001), vec2(0.999));\n if (uvRotated > 0.5) flowingUV = vec2(1.0 - flowingUV.y, flowingUV.x);\n vec4 flowing = vec4(1.0);\n {\n vec4 texture_tmp = texture(texture, uvRect.xy + flowingUV * uvRect.zw);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, uvRect.xy + flowingUV * uvRect.zw + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n flowing.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n flowing.a *= texture_tmp.a;\n #else\n flowing *= texture_tmp;\n #endif\n }\n vec4 color = vec4(mix(base.rgb, flowing.rgb, flowing.a), base.a);\n float amplitude = water.z * smoothstep(0.0, 0.08, water.x)\n * smoothstep(0.0, 0.08, 1.0 - water.x);\n float wave = amplitude * sin(phase);\n float surface = water.x + wave;\n float height = 1.0 - uv.y;\n float distanceToSurface = height - surface;\n float feather = water.w;\n #if CC_SUPPORT_standard_derivatives\n feather = max(0.75 * fwidth(distanceToSurface), 0.00001);\n #endif\n if (water.x <= 0.0) {\n color.a = 0.0;\n } else if (water.x < 1.0) {\n color.a *= 1.0 - smoothstep(-feather, feather, distanceToSurface);\n float rim = 1.0 - smoothstep(0.0, feather, abs(distanceToSurface));\n color.rgb = mix(color.rgb, vec3(1.0, 0.98, 0.88), rim * 0.08);\n }\n color *= v_color;\n #if USE_BGRA\n gl_FragColor = color.bgra;\n #else\n gl_FragColor = color;\n #endif\n}"
|
|
}
|
|
}
|
|
],
|
|
"subMetas": {}
|
|
} |