This commit is contained in:
2025-02-07 17:04:43 -06:00
parent 33fd7ddf72
commit 8eec81c7f4
2249 changed files with 75331 additions and 685 deletions

View File

@@ -0,0 +1,553 @@
{
"version" : 1,
"replacementkey" : "fluidsimulation",
"name" : "ui_editor_effect_advanced_fluid_simulation_title",
"description" : "ui_editor_effect_advanced_fluid_simulation_description",
"group" : "interactive",
"performance" : "veryexpensive",
"preview" : "preview/project.json",
"passes" :
[
{
"material" : "materials/effects/fluidsimulation_curl.json",
"target" : "_rt_SmokeCurl",
"bind" :
[
{
"name" : "_rt_SmokeVelocity1",
"index" : 0
}
]
},
{
"material" : "materials/effects/fluidsimulation_vorticity.json",
"target" : "_rt_SmokeVelocity2",
"bind" :
[
{
"name" : "_rt_SmokeVelocity1",
"index" : 0
},
{
"name" : "_rt_SmokeCurl",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_divergence.json",
"target" : "_rt_SmokeDivergence",
"bind" :
[
{
"name" : "_rt_SmokeVelocity2",
"index" : 0
}
]
},
{
"material" : "materials/effects/fluidsimulation_clear.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokePressure1",
"index" : 0
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_gradientsubtract.json",
"target" : "_rt_SmokeVelocity1",
"bind" :
[
{
"name" : "_rt_SmokePressure1",
"index" : 0
},
{
"name" : "_rt_SmokeVelocity2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_advection.json",
"target" : "_rt_SmokeVelocity2",
"bind" :
[
{
"name" : "_rt_SmokeVelocity1",
"index" : 0
},
{
"name" : "_rt_SmokeVelocity1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_advection_dye.json",
"target" : "_rt_SmokeDye2",
"bind" :
[
{
"name" : "_rt_SmokeVelocity2",
"index" : 0
},
{
"name" : "_rt_SmokeDye1",
"index" : 1
},
{
"name" : "previous",
"index" : 2
}
]
},
{
"material" : "materials/effects/fluidsimulation_normal.json",
"target" : "_rt_SmokeNormal",
"bind" :
[
{
"name" : "_rt_SmokeDye2",
"index" : 0
}
],
"conditions" :
[
{
"LIGHTING" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_combine.json",
"bind" :
[
{
"name" : "_rt_SmokeDye2",
"index" : 0
},
{
"name" : "previous",
"index" : 1
},
{
"name" : "_rt_SmokeNormal",
"index" : 2,
"conditions" :
[
{
"LIGHTING" : 1
}
]
},
{
"name" : "_rt_SmokeVelocity2",
"index" : 4,
"conditions" :
[
{
"RENDERING" : 3
}
]
}
]
},
{
"command" : "swap",
"source" : "_rt_SmokeVelocity1",
"target" : "_rt_SmokeVelocity2"
},
{
"command" : "swap",
"source" : "_rt_SmokeDye1",
"target" : "_rt_SmokeDye2"
}
],
"fbos" :
[
{
"name" : "_rt_SmokeVelocity1",
"fit" : 256,
"format" : "rg1616f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeVelocity2",
"fit" : 256,
"format" : "rg1616f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokePressure1",
"fit" : 256,
"format" : "r16f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokePressure2",
"fit" : 256,
"format" : "r16f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeDivergence",
"fit" : 256,
"format" : "r16f",
"unique" : true
},
{
"name" : "_rt_SmokeCurl",
"fit" : 256,
"format" : "r16f",
"unique" : true
},
{
"name" : "_rt_SmokeDye1",
"scale" : 2,
"format" : "rgba_backbuffer",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeDye2",
"scale" : 2,
"format" : "rgba_backbuffer",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeNormal",
"scale" : 2,
"format" : "rgba8888",
"conditions" :
[
{
"LIGHTING" : 1
}
]
}
],
"functions" : {
"clearVelocity" : {
"action" : "clear",
"fbos" : [ "_rt_SmokeVelocity1", "_rt_SmokeVelocity2" ]
},
"clearDye" : {
"action" : "clear",
"fbos" : [ "_rt_SmokeDye1", "_rt_SmokeDye2" ]
}
},
"dependencies" :
[
"materials/effects/fluidsimulation_advection.json",
"materials/effects/fluidsimulation_advection_dye.json",
"materials/effects/fluidsimulation_clear.json",
"materials/effects/fluidsimulation_combine.json",
"materials/effects/fluidsimulation_curl.json",
"materials/effects/fluidsimulation_divergence.json",
"materials/effects/fluidsimulation_gradientsubtract.json",
"materials/effects/fluidsimulation_pressure.json",
"materials/effects/fluidsimulation_vorticity.json",
"materials/effects/fluidsimulation_normal.json",
"shaders/effects/fluidsimulation_advection.frag",
"shaders/effects/fluidsimulation_advection.vert",
"shaders/effects/fluidsimulation_clear.frag",
"shaders/effects/fluidsimulation_clear.vert",
"shaders/effects/fluidsimulation_combine.frag",
"shaders/effects/fluidsimulation_combine.vert",
"shaders/effects/fluidsimulation_curl.frag",
"shaders/effects/fluidsimulation_curl.vert",
"shaders/effects/fluidsimulation_divergence.frag",
"shaders/effects/fluidsimulation_divergence.vert",
"shaders/effects/fluidsimulation_gradientsubtract.frag",
"shaders/effects/fluidsimulation_gradientsubtract.vert",
"shaders/effects/fluidsimulation_pressure.frag",
"shaders/effects/fluidsimulation_pressure.vert",
"shaders/effects/fluidsimulation_vorticity.frag",
"shaders/effects/fluidsimulation_vorticity.vert",
"shaders/effects/fluidsimulation_normal.frag",
"shaders/effects/fluidsimulation_normal.vert",
],
"gizmos" :
[
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 1
}
},
"vars" :
{
"center" : "emitterPos0",
"angle" : "emitterAngle0",
"size" : "emitterSize0",
"speed" : "emitterSpeed0"
}
},
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 2
}
},
"vars" :
{
"center" : "emitterPos1",
"angle" : "emitterAngle1",
"size" : "emitterSize1",
"speed" : "emitterSpeed1"
}
},
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 3
}
},
"vars" :
{
"center" : "emitterPos2",
"angle" : "emitterAngle2",
"size" : "emitterSize2",
"speed" : "emitterSpeed2"
}
},
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 4
}
},
"vars" :
{
"center" : "emitterPos3",
"angle" : "emitterAngle3",
"size" : "emitterSize3",
"speed" : "emitterSpeed3"
}
},
{
"type" : "EffectLineEmitter",
"condition" :
{
"LINEEMITTER" : {
"op" : "ge",
"value" : 1
}
},
"vars" :
{
"p0" : "lineEmitterPosA0",
"p1" : "lineEmitterPosB0",
"angle" : "lineEmitterAngle0",
"size" : "lineEmitterSize0",
"speed" : "lineEmitterSpeed0"
}
},
{
"type" : "EffectLineEmitter",
"condition" :
{
"LINEEMITTER" : {
"op" : "ge",
"value" : 2
}
},
"vars" :
{
"p0" : "lineEmitterPosA1",
"p1" : "lineEmitterPosB1",
"angle" : "lineEmitterAngle1",
"size" : "lineEmitterSize1",
"speed" : "lineEmitterSpeed1"
}
},
{
"type" : "EffectLineEmitter",
"condition" :
{
"LINEEMITTER" : {
"op" : "ge",
"value" : 3
}
},
"vars" :
{
"p0" : "lineEmitterPosA2",
"p1" : "lineEmitterPosB2",
"angle" : "lineEmitterAngle2",
"size" : "lineEmitterSize2",
"speed" : "lineEmitterSpeed2"
}
},
{
"type" : "EffectPerspectiveUV",
"condition" :
{
"PERSPECTIVE" : 1
},
"vars" :
{
"p0" : "point0",
"p1" : "point1",
"p2" : "point2",
"p3" : "point3"
}
}
]
}

View File

@@ -0,0 +1,12 @@
{
"passes": [{
"shader": "effects/fluidsimulation_advection",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull",
"constantshadervalues" : {
"dissipation" : 0.2
}
}]
}

View File

@@ -0,0 +1,15 @@
{
"passes": [{
"shader": "effects/fluidsimulation_advection",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull",
"constantshadervalues" : {
"dissipation" : 0.4
},
"combos": {
"DYE" : 1
}
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_clear",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_combine",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_curl",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_divergence",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_gradientsubtract",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_normal",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_pressure",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_vorticity",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,543 @@
{
"version" : 1,
"replacementkey" : "fluidsimulation",
"name" : "ui_editor_effect_advanced_fluid_simulation_title",
"description" : "ui_editor_effect_advanced_fluid_simulation_description",
"group" : "interactive",
"performance" : "veryexpensive",
"preview" : "preview/project.json",
"passes" :
[
{
"material" : "materials/effects/fluidsimulation_curl.json",
"target" : "_rt_SmokeCurl",
"bind" :
[
{
"name" : "_rt_SmokeVelocity1",
"index" : 0
}
]
},
{
"material" : "materials/effects/fluidsimulation_vorticity.json",
"target" : "_rt_SmokeVelocity2",
"bind" :
[
{
"name" : "_rt_SmokeVelocity1",
"index" : 0
},
{
"name" : "_rt_SmokeCurl",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_divergence.json",
"target" : "_rt_SmokeDivergence",
"bind" :
[
{
"name" : "_rt_SmokeVelocity2",
"index" : 0
}
]
},
{
"material" : "materials/effects/fluidsimulation_clear.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokePressure1",
"index" : 0
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure2",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_pressure.json",
"target" : "_rt_SmokePressure1",
"bind" :
[
{
"name" : "_rt_SmokeDivergence",
"index" : 0
},
{
"name" : "_rt_SmokePressure2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_gradientsubtract.json",
"target" : "_rt_SmokeVelocity1",
"bind" :
[
{
"name" : "_rt_SmokePressure1",
"index" : 0
},
{
"name" : "_rt_SmokeVelocity2",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_advection.json",
"target" : "_rt_SmokeVelocity2",
"bind" :
[
{
"name" : "_rt_SmokeVelocity1",
"index" : 0
},
{
"name" : "_rt_SmokeVelocity1",
"index" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_advection_dye.json",
"target" : "_rt_SmokeDye2",
"bind" :
[
{
"name" : "_rt_SmokeVelocity2",
"index" : 0
},
{
"name" : "_rt_SmokeDye1",
"index" : 1
},
{
"name" : "previous",
"index" : 2
}
]
},
{
"material" : "materials/effects/fluidsimulation_normal.json",
"target" : "_rt_SmokeNormal",
"bind" :
[
{
"name" : "_rt_SmokeDye2",
"index" : 0
}
],
"conditions" :
[
{
"LIGHTING" : 1
}
]
},
{
"material" : "materials/effects/fluidsimulation_combine.json",
"bind" :
[
{
"name" : "_rt_SmokeDye2",
"index" : 0
},
{
"name" : "previous",
"index" : 1
},
{
"name" : "_rt_SmokeNormal",
"index" : 2,
"conditions" :
[
{
"LIGHTING" : 1
}
]
},
{
"name" : "_rt_SmokeVelocity2",
"index" : 4,
"conditions" :
[
{
"RENDERING" : 3
}
]
}
]
},
{
"command" : "swap",
"source" : "_rt_SmokeVelocity1",
"target" : "_rt_SmokeVelocity2"
},
{
"command" : "swap",
"source" : "_rt_SmokeDye1",
"target" : "_rt_SmokeDye2"
}
],
"fbos" :
[
{
"name" : "_rt_SmokeVelocity1",
"fit" : 256,
"format" : "rg1616f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeVelocity2",
"fit" : 256,
"format" : "rg1616f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokePressure1",
"fit" : 256,
"format" : "r16f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokePressure2",
"fit" : 256,
"format" : "r16f",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeDivergence",
"fit" : 256,
"format" : "r16f",
"unique" : true
},
{
"name" : "_rt_SmokeCurl",
"fit" : 256,
"format" : "r16f",
"unique" : true
},
{
"name" : "_rt_SmokeDye1",
"scale" : 2,
"format" : "rgba_backbuffer",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeDye2",
"scale" : 2,
"format" : "rgba_backbuffer",
"clear" : "0 0 0 0",
"unique" : true
},
{
"name" : "_rt_SmokeNormal",
"scale" : 2,
"format" : "rgba8888",
"conditions" :
[
{
"LIGHTING" : 1
}
]
}
],
"dependencies" :
[
"materials/effects/fluidsimulation_advection.json",
"materials/effects/fluidsimulation_advection_dye.json",
"materials/effects/fluidsimulation_clear.json",
"materials/effects/fluidsimulation_combine.json",
"materials/effects/fluidsimulation_curl.json",
"materials/effects/fluidsimulation_divergence.json",
"materials/effects/fluidsimulation_gradientsubtract.json",
"materials/effects/fluidsimulation_pressure.json",
"materials/effects/fluidsimulation_vorticity.json",
"materials/effects/fluidsimulation_normal.json",
"shaders/effects/fluidsimulation_advection.frag",
"shaders/effects/fluidsimulation_advection.vert",
"shaders/effects/fluidsimulation_clear.frag",
"shaders/effects/fluidsimulation_clear.vert",
"shaders/effects/fluidsimulation_combine.frag",
"shaders/effects/fluidsimulation_combine.vert",
"shaders/effects/fluidsimulation_curl.frag",
"shaders/effects/fluidsimulation_curl.vert",
"shaders/effects/fluidsimulation_divergence.frag",
"shaders/effects/fluidsimulation_divergence.vert",
"shaders/effects/fluidsimulation_gradientsubtract.frag",
"shaders/effects/fluidsimulation_gradientsubtract.vert",
"shaders/effects/fluidsimulation_pressure.frag",
"shaders/effects/fluidsimulation_pressure.vert",
"shaders/effects/fluidsimulation_vorticity.frag",
"shaders/effects/fluidsimulation_vorticity.vert",
"shaders/effects/fluidsimulation_normal.frag",
"shaders/effects/fluidsimulation_normal.vert",
],
"gizmos" :
[
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 1
}
},
"vars" :
{
"center" : "emitterPos0",
"angle" : "emitterAngle0",
"size" : "emitterSize0",
"speed" : "emitterSpeed0"
}
},
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 2
}
},
"vars" :
{
"center" : "emitterPos1",
"angle" : "emitterAngle1",
"size" : "emitterSize1",
"speed" : "emitterSpeed1"
}
},
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 3
}
},
"vars" :
{
"center" : "emitterPos2",
"angle" : "emitterAngle2",
"size" : "emitterSize2",
"speed" : "emitterSpeed2"
}
},
{
"type" : "EffectPointEmitter",
"condition" :
{
"POINTEMITTER" : {
"op" : "ge",
"value" : 4
}
},
"vars" :
{
"center" : "emitterPos3",
"angle" : "emitterAngle3",
"size" : "emitterSize3",
"speed" : "emitterSpeed3"
}
},
{
"type" : "EffectLineEmitter",
"condition" :
{
"LINEEMITTER" : {
"op" : "ge",
"value" : 1
}
},
"vars" :
{
"p0" : "lineEmitterPosA0",
"p1" : "lineEmitterPosB0",
"angle" : "lineEmitterAngle0",
"size" : "lineEmitterSize0",
"speed" : "lineEmitterSpeed0"
}
},
{
"type" : "EffectLineEmitter",
"condition" :
{
"LINEEMITTER" : {
"op" : "ge",
"value" : 2
}
},
"vars" :
{
"p0" : "lineEmitterPosA1",
"p1" : "lineEmitterPosB1",
"angle" : "lineEmitterAngle1",
"size" : "lineEmitterSize1",
"speed" : "lineEmitterSpeed1"
}
},
{
"type" : "EffectLineEmitter",
"condition" :
{
"LINEEMITTER" : {
"op" : "ge",
"value" : 3
}
},
"vars" :
{
"p0" : "lineEmitterPosA2",
"p1" : "lineEmitterPosB2",
"angle" : "lineEmitterAngle2",
"size" : "lineEmitterSize2",
"speed" : "lineEmitterSpeed2"
}
},
{
"type" : "EffectPerspectiveUV",
"condition" :
{
"PERSPECTIVE" : 1
},
"vars" :
{
"p0" : "point0",
"p1" : "point1",
"p2" : "point2",
"p3" : "point3"
}
}
]
}

View File

@@ -0,0 +1,13 @@
{
"passes" :
[
{
"blending" : "translucent",
"cullmode" : "nocull",
"depthtest" : "disabled",
"depthwrite" : "disabled",
"shader" : "genericimage2",
"textures" : [ "effectpreview" ]
}
]
}

View File

@@ -0,0 +1,6 @@
{
"clampuvs" : true,
"format" : "rgba8888",
"nomip" : true,
"nonpoweroftwo" : true
}

View File

@@ -0,0 +1,12 @@
{
"passes": [{
"shader": "effects/fluidsimulation_advection",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull",
"constantshadervalues" : {
"dissipation" : 0.2
}
}]
}

View File

@@ -0,0 +1,15 @@
{
"passes": [{
"shader": "effects/fluidsimulation_advection",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull",
"constantshadervalues" : {
"dissipation" : 0.4
},
"combos": {
"DYE" : 1
}
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_clear",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_combine",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_curl",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_divergence",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_gradientsubtract",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_normal",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_pressure",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,9 @@
{
"passes": [{
"shader": "effects/fluidsimulation_vorticity",
"blending": "normal",
"depthtest": "disabled",
"depthwrite": "disabled",
"cullmode": "nocull"
}]
}

View File

@@ -0,0 +1,4 @@
{
"autosize" : true,
"material" : "materials/effectpreview.json"
}

View File

@@ -0,0 +1,19 @@
{
"file" : "scene.json",
"general" :
{
"properties" :
{
"schemecolor" :
{
"order" : 0,
"text" : "ui_browse_properties_scheme_color",
"type" : "color",
"value" : "0 0 0"
}
}
},
"title" : "preview",
"type" : "scene",
"version" : 0
}

View File

@@ -0,0 +1,229 @@
{
"camera" :
{
"center" : "0.00000 0.00000 -1.00000",
"eye" : "0.00000 0.00000 0.00000",
"up" : "0.00000 1.00000 0.00000"
},
"general" :
{
"ambientcolor" : "0.30000 0.30000 0.30000",
"bloom" : false,
"bloomhdrfeather" : 0.1,
"bloomhdriterations" : 8,
"bloomhdrscatter" : 1.619,
"bloomhdrstrength" : 2.0,
"bloomhdrthreshold" : 1.0,
"bloomstrength" : 2.0,
"bloomthreshold" : 0.64999998,
"camerafade" : true,
"cameraparallax" : false,
"cameraparallaxamount" : 0.5,
"cameraparallaxdelay" : 0.1,
"cameraparallaxmouseinfluence" : 0.0,
"camerapreview" : true,
"camerashake" : false,
"camerashakeamplitude" : 0.5,
"camerashakeroughness" : 1.0,
"camerashakespeed" : 3.0,
"clearcolor" : "0.70000 0.70000 0.70000",
"clearenabled" : true,
"farz" : 10000.0,
"fov" : 50.0,
"hdr" : false,
"nearz" : 0.0099999998,
"orthogonalprojection" :
{
"height" : 256,
"width" : 256
},
"skylightcolor" : "0.30000 0.30000 0.30000",
"zoom" : 1.0
},
"objects" :
[
{
"alignment" : "center",
"alpha" : 1.0,
"angles" : "0.00000 0.00000 0.00000",
"brightness" : 1.0,
"color" : "1.00000 1.00000 1.00000",
"colorBlendMode" : 0,
"copybackground" : true,
"depth" : 1,
"effects" :
[
{
"file" : "effects/fluidsimulation/effect.json",
"id" : 18,
"name" : "",
"passes" :
[
{
"id" : 19
},
{
"combos" :
{
"LINEEMITTER" : 1,
"POINTEMITTER" : 0
},
"constantshadervalues" :
{
"curl" : 30.0,
"cursorinfluence" : 4,
"emitterAngle0" : 0.0,
"emitterPos0" : "0.48154 0.82457",
"emitterSize0" : 0.05,
"emitterSpeed0" : 100.0,
"lineEmitterAngle0" : 0.012310771,
"lineEmitterPosA0" : "0.13692 0.91527",
"lineEmitterPosB0" : "0.91070 0.91681",
"lineEmitterSize0" : 0.035330743,
"lineEmitterSpeed0" : 1261.6055
},
"id" : 21
},
{
"id" : 22
},
{
"constantshadervalues" :
{
"emitterPos0" : "0.48154 0.82457",
"lineEmitterAngle0" : 0.012310771,
"lineEmitterPosA0" : "0.13692 0.91527",
"lineEmitterPosB0" : "0.91070 0.91681",
"lineEmitterSize0" : 0.035330743,
"lineEmitterSpeed0" : 1261.6055,
"pressure" : 0.8
},
"id" : 23
},
{
"id" : 24
},
{
"id" : 25
},
{
"id" : 26
},
{
"id" : 27
},
{
"id" : 28
},
{
"id" : 29
},
{
"id" : 30
},
{
"id" : 31
},
{
"id" : 32
},
{
"id" : 33
},
{
"combos" :
{
"LINEEMITTER" : 1,
"POINTEMITTER" : 0
},
"constantshadervalues" :
{
"dissipation" : 0.2,
"emitterPos0" : "0.48154 0.82457",
"forcedirection" : 3.141593,
"forcestrength" : 0.0,
"lifetime" : 0.32,
"lineEmitterAngle0" : 0.012310771,
"lineEmitterPosA0" : "0.13692 0.91527",
"lineEmitterPosB0" : "0.91070 0.91681",
"lineEmitterSize0" : 0.035330743,
"lineEmitterSpeed0" : 1261.6055,
"viscosityfactor" : 2.29
},
"id" : 34
},
{
"combos" :
{
"DYE" : 1,
"LINEEMITTER" : 1,
"POINTEMITTER" : 0
},
"constantshadervalues" :
{
"dissipation" : 0.4,
"dissipationfactor" : 1.0,
"emitterPos0" : "0.48154 0.82457",
"emitterSize0" : 0.05,
"lifetime" : 0.32,
"lineEmitterAngle0" : 0.012310771,
"lineEmitterPosA0" : "0.13692 0.91527",
"lineEmitterPosB0" : "0.91070 0.91681",
"lineEmitterSize0" : 0.035330743,
"lineEmitterSpeed0" : 1261.6055
},
"id" : 35
},
{
"constantshadervalues" :
{
"depth" : 0.5,
"emitterPos0" : "0.48154 0.82457",
"lineEmitterAngle0" : 0.012310771,
"lineEmitterPosA0" : "0.13692 0.91527",
"lineEmitterPosB0" : "0.91070 0.91681",
"lineEmitterSize0" : 0.035330743,
"lineEmitterSpeed0" : 1261.6055
},
"id" : 36
},
{
"combos" :
{
"BLENDMODE" : 0
},
"constantshadervalues" :
{
"brightness" : 1.0,
"emitterPos0" : "0.48154 0.82457",
"feather" : 0.68,
"hue" : 0.0,
"lineEmitterAngle0" : 0.012310771,
"lineEmitterPosA0" : "0.13692 0.91527",
"lineEmitterPosB0" : "0.91070 0.91681",
"lineEmitterSize0" : 0.035330743,
"lineEmitterSpeed0" : 1261.6055,
"opacity" : 1.0
},
"id" : 37
}
],
"visible" : true
}
],
"id" : 38,
"image" : "models/effectpreview.json",
"ledsource" : false,
"locktransforms" : false,
"name" : "",
"origin" : "128.00000 128.00000 0.00000",
"parallaxDepth" : "1.00000 1.00000",
"perspective" : false,
"scale" : "1.00000 1.00000 1.00000",
"size" : "256.00000 256.00000",
"solid" : true,
"visible" : true
}
],
"version" : 0
}

View File

@@ -0,0 +1,191 @@
// [COMBO] {"material":"ui_editor_properties_point_emitter_count","combo":"POINTEMITTER","type":"options","default":1,"options":[0,1,2,3]}
// [COMBO] {"material":"ui_editor_properties_line_emitter_count","combo":"LINEEMITTER","type":"options","default":0,"options":[0,1,2,3]}
// [COMBO] {"material":"ui_editor_properties_rendering","combo":"RENDERING","type":"options","default":0,"options":{"ui_editor_properties_gradient":0,"ui_editor_properties_emitter_color":1,"ui_editor_properties_background_color":2,"ui_editor_properties_distortion":3}}
uniform float g_Frametime;
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
uniform sampler2D g_Texture2; // {"hidden":true}
uniform sampler2D g_Texture3; // {"label":"ui_editor_properties_collision_mask","mode":"opacitymask","combo":"COLLISIONMASK","paintdefaultcolor":"0 0 0 1","painttexturescale":1,"require":{"DYE":0}}
uniform sampler2D g_Texture4; // {"label":"ui_editor_properties_dye_emitter","mode":"rgbmask","combo":"DYEEMITTER","paintdefaultcolor":"0 0 0 1","painttexturescale":1,"require":{"DYE":1}}
uniform vec4 g_Texture0Resolution;
uniform float u_Dissipation; // {"material":"dissipationfactor","label":"ui_editor_properties_dissipation","default":1.0,"range":[0.01, 10.0],"group":"ui_editor_properties_simulation"}
uniform float u_Viscosity; // {"material":"viscosityfactor","label":"ui_editor_properties_viscosity","default":1.0,"range":[0.0, 20.0],"group":"ui_editor_properties_simulation"}
uniform float m_Dissipation; // {"hidden":true,"material":"dissipation","label":"ui_editor_properties_dissipation","default":1.0,"range":[0.0, 1.0],"group":"ui_editor_properties_simulation"}
uniform float u_Lifetime; // {"material":"lifetime","label":"ui_editor_properties_high_pass","default":0.1,"range":[0.1, 1.0],"group":"ui_editor_properties_simulation"}
uniform float u_Saturation; // {"material":"saturation","label":"ui_editor_properties_saturation","default":1.0,"range":[0.0, 1.0]}
varying vec2 v_TexCoord;
uniform float u_ConstantVelocityAngle; // {"material":"forcedirection","label":"ui_editor_properties_direction","default":3.141593,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_gravity"}
uniform float u_ConstantVelocityStrength; // {"material":"forcestrength","label":"ui_editor_properties_strength","default":0.0,"range":[0,100.0],"group":"ui_editor_properties_gravity"}
#if DYE
uniform vec2 m_EmitterPos0; // {"material":"emitterPos0","default":"0.5 0.5"}
uniform float m_EmitterSize0; // {"material":"emitterSize0","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor0; // {"material":"emitterColor0","label":"ui_editor_properties_color","default":"1 0 0","group":"ui_editor_properties_point_emitter_1","type":"color"}
uniform vec2 m_EmitterPos1; // {"material":"emitterPos1","default":"0.5 0.7"}
uniform float m_EmitterSize1; // {"material":"emitterSize1","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor1; // {"material":"emitterColor1","label":"ui_editor_properties_color","default":"0 1 0","group":"ui_editor_properties_point_emitter_2","type":"color"}
uniform vec2 m_EmitterPos2; // {"material":"emitterPos2","default":"0.7 0.7"}
uniform float m_EmitterSize2; // {"material":"emitterSize2","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor2; // {"material":"emitterColor2","label":"ui_editor_properties_color","default":"0 0 1","group":"ui_editor_properties_point_emitter_3","type":"color"}
uniform vec2 m_EmitterPos3; // {"material":"emitterPos3","default":"0.7 0.5"}
uniform float m_EmitterSize3; // {"material":"emitterSize3","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor3; // {"material":"emitterColor3","label":"ui_editor_properties_color","default":"1 1 0","group":"ui_editor_properties_point_emitter_4","type":"color"}
uniform vec2 m_LineEmitterPosA0; // {"material":"lineEmitterPosA0","default":"0.1 0.1"}
uniform vec2 m_LineEmitterPosB0; // {"material":"lineEmitterPosB0","default":"0.4 0.1"}
uniform float m_LineEmitterSize0; // {"material":"lineEmitterSize0","default":0.02}
uniform vec3 m_LineEmitterColor0; // {"material":"lineEmitterColor0","label":"ui_editor_properties_color","default":"0 1 1","group":"ui_editor_properties_line_emitter_1","type":"color"}
uniform vec2 m_LineEmitterPosA1; // {"material":"lineEmitterPosA1","default":"0.1 0.2"}
uniform vec2 m_LineEmitterPosB1; // {"material":"lineEmitterPosB1","default":"0.4 0.2"}
uniform float m_LineEmitterSize1; // {"material":"lineEmitterSize1","default":0.02}
uniform vec3 m_LineEmitterColor1; // {"material":"lineEmitterColor1","label":"ui_editor_properties_color","default":"1 1 0","group":"ui_editor_properties_line_emitter_2","type":"color"}
uniform vec2 m_LineEmitterPosA2; // {"material":"lineEmitterPosA2","default":"0.1 0.3"}
uniform vec2 m_LineEmitterPosB2; // {"material":"lineEmitterPosB2","default":"0.4 0.3"}
uniform float m_LineEmitterSize2; // {"material":"lineEmitterSize2","default":0.02}
uniform vec3 m_LineEmitterColor2; // {"material":"lineEmitterColor2","label":"ui_editor_properties_color","default":"1 0 1","group":"ui_editor_properties_line_emitter_3","type":"color"}
#endif
#if PERSPECTIVE == 1
varying vec3 v_TexCoordPerspective;
#endif
vec4 AddEmitterColor(vec2 texCoord, float amt, vec4 currentColor, vec3 emitterColor)
{
#if RENDERING == 2
vec4 prevColor = texSample2D(g_Texture2, texCoord);
return mix(currentColor, prevColor, amt);
#endif
#if RENDERING == 1
emitterColor *= amt;
return min(currentColor + vec4(mix(g_Frametime, 1.0, u_Saturation) * emitterColor, amt), max(CAST4(1.0), vec4(emitterColor, amt)));
//return mix(currentColor, vec4(emitterColor, 1), amt);
#endif
// Clamp to max injected color for proper HDR behavior?
return min(currentColor + CAST4(amt), CAST4(1.0));
}
vec4 EmitterColor(vec2 texCoord, float aspect, vec4 currentColor, vec2 position, float size, vec3 emitterColor)
{
vec2 delta = position - texCoord;
delta.y *= aspect;
float amt = smoothstep(size, 0.0, length(delta));
return AddEmitterColor(texCoord, amt, currentColor, emitterColor);
}
vec4 LineEmitterColor(vec2 texCoord, vec2 linePosA, vec2 linePosB, float aspect, vec4 currentColor, float size, vec3 emitterColor)
{
vec2 lineDelta = linePosB - linePosA;
float distLineDelta = length(lineDelta) + 0.0001;
lineDelta /= distLineDelta;
float distOnEmitterLine = dot(lineDelta, texCoord - linePosA);
distOnEmitterLine = max(0.0, min(distLineDelta, distOnEmitterLine));
vec2 posOnEmitterLine = linePosA + lineDelta * distOnEmitterLine;
vec2 delta = texCoord - posOnEmitterLine;
delta.y *= aspect;
float amt = smoothstep(size, 0.0, length(delta));
return AddEmitterColor(texCoord, amt, currentColor, emitterColor);
}
void main() {
vec2 vUv = v_TexCoord;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
float dt = min(1.0/20.0, g_Frametime);
vec2 coord = vUv - dt * texSample2D(g_Texture0, vUv).xy * texelSize;
vec4 result = texSample2D(g_Texture1, coord);
#if DYE
float decayFactor = u_Dissipation;
float boundaryMask = step(0.0, coord.x) *
step(coord.x, 1.0) *
step(0.0, coord.y) *
step(coord.y, 1.0);
#else
float decayFactor = u_Viscosity;
#endif
float decay = 1.0 + decayFactor * m_Dissipation * dt;
//float lowPass = smoothstep(1.0, 0.00001, length(result.rgb)) * 0.5;
float lowPass = step(length(result.rgb), u_Lifetime) * 0.5;
#if DYE
result *= boundaryMask;
#endif
gl_FragColor = result / (decay + lowPass);
float aspect = g_Texture0Resolution.y / g_Texture0Resolution.x;
#if DYE
vec2 emitterUV = v_TexCoord;
#if PERSPECTIVE == 1
emitterUV = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
#endif
// Add color
#if POINTEMITTER >= 1
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos0, m_EmitterSize0, m_EmitterColor0);
#endif
#if POINTEMITTER >= 2
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos1, m_EmitterSize1, m_EmitterColor1);
#endif
#if POINTEMITTER >= 3
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos2, m_EmitterSize2, m_EmitterColor2);
#endif
#if POINTEMITTER >= 4
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos3, m_EmitterSize3, m_EmitterColor3);
#endif
#if LINEEMITTER >= 1
gl_FragColor = LineEmitterColor(emitterUV, m_LineEmitterPosA0, m_LineEmitterPosB0, aspect, gl_FragColor, m_LineEmitterSize0, m_LineEmitterColor0);
#endif
#if LINEEMITTER >= 2
gl_FragColor = LineEmitterColor(emitterUV, m_LineEmitterPosA1, m_LineEmitterPosB1, aspect, gl_FragColor, m_LineEmitterSize1, m_LineEmitterColor1);
#endif
#if LINEEMITTER >= 3
gl_FragColor = LineEmitterColor(emitterUV, m_LineEmitterPosA2, m_LineEmitterPosB2, aspect, gl_FragColor, m_LineEmitterSize2, m_LineEmitterColor2);
#endif
#if DYEEMITTER
vec4 dyeEmitterSample = texSample2D(g_Texture4, v_TexCoord);
dyeEmitterSample.rgb *= dyeEmitterSample.a;
gl_FragColor = min(gl_FragColor + vec4(dyeEmitterSample.rgb * u_Saturation,
saturate(dot(dyeEmitterSample.rgb, CAST3(g_Frametime)) * dyeEmitterSample.a)),
CAST4(1.0));
#endif
#else
vec2 constantSpeed = vec2(sin(u_ConstantVelocityAngle), -cos(u_ConstantVelocityAngle)) * u_ConstantVelocityStrength;
constantSpeed.y *= aspect;
gl_FragColor.xy += constantSpeed * g_Frametime;
#if COLLISIONMASK
vec2 emitterUV = v_TexCoord;
#if PERSPECTIVE == 1
emitterUV = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
#endif
vec4 collisionColor = texSample2D(g_Texture3, emitterUV);
float solid = collisionColor.r * collisionColor.a;
gl_FragColor.xy = mix(gl_FragColor.xy, vec2(0, 0), solid);
#endif
#endif
}

View File

@@ -0,0 +1,27 @@
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
#include "common_perspective.h"
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
#if PERSPECTIVE == 1
uniform vec2 g_Point0; // {"hidden":true,"material":"point0","label":"p0","default":"0 0"}
uniform vec2 g_Point1; // {"hidden":true,"material":"point1","label":"p1","default":"1 0"}
uniform vec2 g_Point2; // {"hidden":true,"material":"point2","label":"p2","default":"1 1"}
uniform vec2 g_Point3; // {"hidden":true,"material":"point3","label":"p3","default":"0 1"}
varying vec3 v_TexCoordPerspective;
#endif
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
#if PERSPECTIVE == 1
mat3 xform = squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3);
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), xform);
#endif
}

View File

@@ -0,0 +1,8 @@
uniform sampler2D g_Texture0; // {"hidden":true}
varying vec3 v_TexCoord;
void main() {
gl_FragColor = v_TexCoord.z * texSample2D(g_Texture0, v_TexCoord.xy);
}

View File

@@ -0,0 +1,15 @@
uniform float g_Frametime;
uniform float u_Pressure; // {"material":"pressure","label":"ui_editor_properties_pressure","default":0.8,"range":[0.0, 1.0],"group":"ui_editor_properties_simulation"}
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec3 v_TexCoord;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord.xy = a_TexCoord.xy;
v_TexCoord.z = pow(u_Pressure, 60 * g_Frametime);
}

View File

@@ -0,0 +1,129 @@
// [COMBO] {"material":"ui_editor_properties_blend_mode","combo":"BLENDMODE","type":"imageblending","default":31}
// [COMBO] {"material":"ui_editor_properties_rendering","combo":"RENDERING","type":"options","default":0,"options":{"ui_editor_properties_gradient":0,"ui_editor_properties_emitter_color":1,"ui_editor_properties_background_color":2,"ui_editor_properties_distortion":3}}
// [COMBO] {"material":"ui_editor_properties_opaque_background","combo":"OPAQUE","type":"options","default":0}
// [COMBO] {"material":"ui_editor_properties_write_alpha","combo":"WRITEALPHA","type":"options","default":1}
#include "common_pbr.h"
#include "common_blending.h"
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
uniform sampler2D g_Texture2; // {"hidden":true}
uniform sampler2D g_Texture3; // {"label":"ui_editor_properties_gradient_map","default":"gradient/gradient_fire","require":{"RENDERING":0}}
uniform sampler2D g_Texture4; // {"hidden":true}
uniform float u_Brightness; // {"material":"brightness","label":"ui_editor_properties_brightness","default":1.0,"range":[0.01, 5]}
uniform float u_Alpha; // {"material":"opacity","label":"ui_editor_properties_opacity","default":1.0,"range":[0.01, 1]}
uniform float u_Feather; // {"material":"feather","label":"ui_editor_properties_feather","default":1.0,"range":[0.01, 1]}
uniform float u_HueShift; // {"material":"hue","label":"ui_editor_properties_hue","default":0.0,"range":[0.0, 1.0]}
varying vec2 v_TexCoord;
uniform vec4 g_Texture0Resolution;
uniform vec4 g_Texture1Resolution;
#if PERSPECTIVE == 1
varying vec3 v_TexCoordPerspective;
#endif
#if LIGHTING
uniform float u_Roughness; // {"material":"roughness","label":"ui_editor_properties_roughness","default":0.5,"range":[0,1],"group":"ui_editor_properties_material"}
uniform float u_Metallic; // {"material":"metallic","label":"ui_editor_properties_metallic","default":0.5,"range":[0,1],"group":"ui_editor_properties_material"}
uniform vec4 g_LightsColorPremultiplied[3];
uniform vec3 g_LightAmbientColor;
varying vec4 v_Light0DirectionL3X;
varying vec4 v_Light1DirectionL3Y;
varying vec4 v_Light2DirectionL3Z;
#endif
void main() {
vec2 fxCoords = v_TexCoord.xy;
float fxMask = 1.0;
#if PERSPECTIVE == 1
fxCoords = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
fxMask *= step(abs(fxCoords.x - 0.5), 0.5);
fxMask *= step(abs(fxCoords.y - 0.5), 0.5);
#endif
vec4 albedo = texSample2D(g_Texture0, fxCoords.xy);
float refAlpha = albedo.a;
#if RENDERING == 0
vec4 gradientColor = texSample2D(g_Texture3, vec2(albedo.r, 0.5));
vec3 hsv = rgb2hsv(gradientColor.rgb);
hsv.x += u_HueShift;
albedo.rgb = hsv2rgb(hsv) * u_Brightness;
albedo.a *= gradientColor.a;
#endif
#if RENDERING == 1
albedo.rgb *= u_Brightness;
#endif
#if RENDERING == 2
albedo.rgb *= u_Brightness;
albedo.rgb /= albedo.a + 0.00001;
#endif
albedo.a = smoothstep(0.0, u_Feather, albedo.a);
#if RENDERING == 3
#if LIGHTING
vec2 velocity = texSample2D(g_Texture2, fxCoords.xy).xy * CAST2(2.0) - CAST2(1.0);
#else
float pressure = texSample2D(g_Texture4, fxCoords.xy).x;
vec2 velocity = vec2(ddx(pressure), ddy(pressure));
velocity = sign(velocity) * smoothstep(CAST2(0.01), CAST2(10.0), abs(velocity));
#endif
vec2 uvOffset = velocity;
vec4 prevDistorted = texSample2D(g_Texture1, v_TexCoord.xy - uvOffset);
albedo.rgb = prevDistorted.rgb;
albedo.a = 1;
#endif
albedo.a *= fxMask;
#if LIGHTING
vec3 normal = normalize(texSample2D(g_Texture2, fxCoords.xy).rgb * CAST3(2.0) - CAST3(1.0));
float metallic = u_Metallic;
float roughness = u_Roughness;
vec3 f0 = CAST3(0.04);
f0 = mix(f0, albedo.rgb, metallic);
vec3 normalizedViewVector = vec3(0, 0, 1);
vec3 light = ComputePBRLight(normal, v_Light0DirectionL3X.xyz, normalizedViewVector, albedo.rgb, g_LightsColorPremultiplied[0].rgb, f0, roughness, metallic);
light += ComputePBRLight(normal, v_Light1DirectionL3Y.xyz, normalizedViewVector, albedo.rgb, g_LightsColorPremultiplied[1].rgb, f0, roughness, metallic);
light += ComputePBRLight(normal, v_Light2DirectionL3Z.xyz, normalizedViewVector, albedo.rgb, g_LightsColorPremultiplied[2].rgb, f0, roughness, metallic);
light += ComputePBRLight(normal, vec3(v_Light0DirectionL3X.w, v_Light1DirectionL3Y.w, v_Light2DirectionL3Z.w),
normalizedViewVector, albedo.rgb,
vec3(g_LightsColorPremultiplied[0].w, g_LightsColorPremultiplied[1].w, g_LightsColorPremultiplied[2].w),
f0, roughness, metallic);
vec3 ambient = max(CAST3(0.001), g_LightAmbientColor) * albedo.rgb;
albedo.rgb = CombineLighting(light, ambient);
#endif
#if OPAQUE
albedo.a = 1;
#else
vec4 prev = texSample2D(g_Texture1, v_TexCoord.xy);
#if BLENDMODE == 0
albedo = mix(prev, albedo, saturate(albedo.a) * u_Alpha);
#else
albedo.rgb = ApplyBlending(BLENDMODE, prev.rgb, albedo.rgb, albedo.a * u_Alpha);
#endif
albedo.a = saturate(prev.a + albedo.a);
#if WRITEALPHA == 0
albedo.a = prev.a;
#endif
#endif
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,53 @@
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
// [COMBO] {"material":"ui_editor_properties_lighting","combo":"LIGHTING","type":"options","default":0}
#include "common_perspective.h"
uniform mat4 g_ModelViewProjectionMatrix;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
#if PERSPECTIVE == 1
uniform vec2 g_Point0; // {"hidden":true,"material":"point0","label":"p0","default":"0 0"}
uniform vec2 g_Point1; // {"hidden":true,"material":"point1","label":"p1","default":"1 0"}
uniform vec2 g_Point2; // {"hidden":true,"material":"point2","label":"p2","default":"1 1"}
uniform vec2 g_Point3; // {"hidden":true,"material":"point3","label":"p3","default":"0 1"}
varying vec3 v_TexCoordPerspective;
#endif
#if LIGHTING
uniform mat4 g_EffectModelMatrix;
uniform mat4 g_EffectModelViewProjectionMatrixInverse;
uniform vec3 g_LightsPosition[4];
varying vec4 v_Light0DirectionL3X;
varying vec4 v_Light1DirectionL3Y;
varying vec4 v_Light2DirectionL3Z;
#endif
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord = a_TexCoord.xy;
#if PERSPECTIVE == 1
mat3 xform = inverse(squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3));
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), xform);
#endif
#if LIGHTING
vec4 worldPos = mul(vec4(a_Position, 1.0), g_EffectModelMatrix);
v_Light0DirectionL3X.xyz = g_LightsPosition[0] - worldPos.xyz;
v_Light1DirectionL3Y.xyz = g_LightsPosition[1] - worldPos.xyz;
v_Light2DirectionL3Z.xyz = g_LightsPosition[2] - worldPos.xyz;
vec3 l3 = g_LightsPosition[3] - worldPos.xyz;
v_Light0DirectionL3X.w = l3.x;
v_Light1DirectionL3Y.w = l3.y;
v_Light2DirectionL3Z.w = l3.z;
#endif
}

View File

@@ -0,0 +1,21 @@
uniform sampler2D g_Texture0; // {"hidden":true}
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture0, vL).y;
float R = texSample2D(g_Texture0, vR).y;
float T = texSample2D(g_Texture0, vT).x;
float B = texSample2D(g_Texture0, vB).x;
float vorticity = R - L - T + B;
//float vorticity = R - L - B + T;
gl_FragColor = vec4(0.5 * vorticity, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,21 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = a_TexCoord.xyxy;
v_TexCoordRightBottom = a_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,26 @@
uniform sampler2D g_Texture0; // {"hidden":true}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture0, vL).x;
float R = texSample2D(g_Texture0, vR).x;
float T = texSample2D(g_Texture0, vT).y;
float B = texSample2D(g_Texture0, vB).y;
vec2 C = texSample2D(g_Texture0, vUv).xy;
if (vL.x < 0.0) { L = -C.x; }
if (vR.x > 1.0) { R = -C.x; }
if (vT.y > 1.0) { T = -C.y; }
if (vB.y < 0.0) { B = -C.y; }
float div = 0.5 * (R - L + T - B);
gl_FragColor = vec4(div, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,23 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = v_TexCoord.xyxy;
v_TexCoordRightBottom = v_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,23 @@
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture0, vL).x;
float R = texSample2D(g_Texture0, vR).x;
float T = texSample2D(g_Texture0, vT).x;
float B = texSample2D(g_Texture0, vB).x;
vec2 velocity = texSample2D(g_Texture1, vUv).xy;
velocity.xy -= vec2(R - L, T - B);
gl_FragColor = vec4(velocity, 0.0, 1.0);
}

View File

@@ -0,0 +1,23 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = v_TexCoord.xyxy;
v_TexCoordRightBottom = v_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,30 @@
uniform sampler2D g_Texture0; // {"hidden":true}
uniform vec4 g_Texture0Resolution;
uniform float u_Depth; // {"material":"depth","label":"ui_editor_properties_depth","default":0.5,"range":[0,1],"group":"ui_editor_properties_material"}
varying vec2 v_TexCoord;
void main() {
vec2 fxCoords = v_TexCoord.xy;
float refAlpha = texSample2D(g_Texture0, fxCoords).a;
vec2 ist = CAST2(1.0) / g_Texture0Resolution.xy;
float s10 = texSample2D(g_Texture0, fxCoords + vec2(ist.x, 0.0)).a;
float s01 = texSample2D(g_Texture0, fxCoords + vec2(0.0, ist.y)).a;
vec2 base = vec2(s10 - refAlpha, s01 - refAlpha) * CAST2(25.0 * u_Depth);
//float bLen = length(base) + 0.0001;
//base /= bLen;
//bLen = saturate(bLen);
//base *= bLen * refAlpha;
base = clamp(base, CAST2(-1.0), CAST2(1.0)) * refAlpha;
vec3 normal = vec3(base, 0.0);
normal.x = -normal.x;
normal.z = sqrt(saturate(1.0 - normal.x * normal.x - normal.y * normal.y));
gl_FragColor = vec4(normal * CAST3(0.5) + CAST3(0.5), 1.0);
}

View File

@@ -0,0 +1,10 @@
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
}

View File

@@ -0,0 +1,24 @@
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture1, vL).x;
float R = texSample2D(g_Texture1, vR).x;
float T = texSample2D(g_Texture1, vT).x;
float B = texSample2D(g_Texture1, vB).x;
float C = texSample2D(g_Texture1, vUv).x;
float divergence = texSample2D(g_Texture0, vUv).x;
float pressure = (L + R + B + T - divergence) * 0.25;
gl_FragColor = vec4(pressure, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,23 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = v_TexCoord.xyxy;
v_TexCoordRightBottom = v_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,209 @@
// [COMBO] {"material":"ui_editor_properties_point_emitter_count","combo":"POINTEMITTER","type":"options","default":1,"options":[0,1,2,3]}
// [COMBO] {"material":"ui_editor_properties_line_emitter_count","combo":"LINEEMITTER","type":"options","default":0,"options":[0,1,2,3]}
#include "common.h"
uniform float g_Frametime;
uniform float g_Time;
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
uniform sampler2D g_Texture2; // {"hidden":true,"default":"util/noise"}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
uniform vec4 g_PointerState;
varying vec4 v_PointerUV;
varying vec4 v_PointerUVLast;
varying vec2 v_PointDelta;
#if PERSPECTIVE == 1
//varying mat3 v_XForm;
varying vec3 v_TexCoordPerspective;
#endif
uniform vec4 g_Texture0Resolution;
uniform float u_Curl; // {"material":"curl","label":"ui_editor_properties_curling","default":30.0,"range":[0.0, 50.0],"group":"ui_editor_properties_simulation"}
uniform vec2 m_EmitterPos0; // {"material":"emitterPos0","label":"ui_editor_properties_position","default":"0.5 0.5","group":"ui_editor_properties_point_emitter_1"}
uniform float m_EmitterAngle0; // {"material":"emitterAngle0","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_1"}
uniform float m_EmitterSize0; // {"material":"emitterSize0","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_1"}
uniform float m_EmitterSpeed0; // {"material":"emitterSpeed0","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_1"}
uniform vec2 m_EmitterPos1; // {"material":"emitterPos1","label":"ui_editor_properties_position","default":"0.5 0.7","group":"ui_editor_properties_point_emitter_2"}
uniform float m_EmitterAngle1; // {"material":"emitterAngle1","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_2"}
uniform float m_EmitterSize1; // {"material":"emitterSize1","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_2"}
uniform float m_EmitterSpeed1; // {"material":"emitterSpeed1","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_2"}
uniform vec2 m_EmitterPos2; // {"material":"emitterPos2","label":"ui_editor_properties_position","default":"0.7 0.7","group":"ui_editor_properties_point_emitter_3"}
uniform float m_EmitterAngle2; // {"material":"emitterAngle2","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_3"}
uniform float m_EmitterSize2; // {"material":"emitterSize2","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_3"}
uniform float m_EmitterSpeed2; // {"material":"emitterSpeed2","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_3"}
uniform vec2 m_EmitterPos3; // {"material":"emitterPos3","label":"ui_editor_properties_position","default":"0.7 0.5","group":"ui_editor_properties_point_emitter_4"}
uniform float m_EmitterAngle3; // {"material":"emitterAngle3","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_4"}
uniform float m_EmitterSize3; // {"material":"emitterSize3","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_4"}
uniform float m_EmitterSpeed3; // {"material":"emitterSpeed3","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_4"}
uniform vec2 m_LineEmitterPosA0; // {"material":"lineEmitterPosA0","label":"p0","default":"0.1 0.1","group":"ui_editor_properties_line_emitter_1"}
uniform vec2 m_LineEmitterPosB0; // {"material":"lineEmitterPosB0","label":"p1","default":"0.4 0.1","group":"ui_editor_properties_line_emitter_1"}
uniform float m_LineEmitterAngle0; // {"material":"lineEmitterAngle0","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_line_emitter_1"}
uniform float m_LineEmitterSize0; // {"material":"lineEmitterSize0","label":"ui_editor_properties_size","default":0.02,"range":[0.0, 0.3],"group":"ui_editor_properties_line_emitter_1"}
uniform float m_LineEmitterSpeed0; // {"material":"lineEmitterSpeed0","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_line_emitter_1"}
uniform vec2 m_LineEmitterPosA1; // {"material":"lineEmitterPosA1","label":"p0","default":"0.1 0.2","group":"ui_editor_properties_line_emitter_2"}
uniform vec2 m_LineEmitterPosB1; // {"material":"lineEmitterPosB1","label":"p1","default":"0.4 0.2","group":"ui_editor_properties_line_emitter_2"}
uniform float m_LineEmitterAngle1; // {"material":"lineEmitterAngle1","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_line_emitter_2"}
uniform float m_LineEmitterSize1; // {"material":"lineEmitterSize1","label":"ui_editor_properties_size","default":0.02,"range":[0.0, 0.3],"group":"ui_editor_properties_line_emitter_2"}
uniform float m_LineEmitterSpeed1; // {"material":"lineEmitterSpeed1","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_line_emitter_2"}
uniform vec2 m_LineEmitterPosA2; // {"material":"lineEmitterPosA2","label":"p0","default":"0.1 0.3","group":"ui_editor_properties_line_emitter_3"}
uniform vec2 m_LineEmitterPosB2; // {"material":"lineEmitterPosB2","label":"p1","default":"0.4 0.3","group":"ui_editor_properties_line_emitter_3"}
uniform float m_LineEmitterAngle2; // {"material":"lineEmitterAngle2","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_line_emitter_3"}
uniform float m_LineEmitterSize2; // {"material":"lineEmitterSize2","label":"ui_editor_properties_size","default":0.02,"range":[0.0, 0.3],"group":"ui_editor_properties_line_emitter_3"}
uniform float m_LineEmitterSpeed2; // {"material":"lineEmitterSpeed2","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_line_emitter_3"}
vec2 EmitterVelocity(vec2 texCoord, float aspect, vec2 position, float angle, float size, float speed)
{
vec2 delta = position - texCoord;
//delta.y *= aspect;
float amt = step(length(delta), size) * speed;
vec2 emitterSpeed = vec2(sin(angle), -cos(angle)) * amt;
//emitterSpeed.y *= aspect;
return emitterSpeed;
}
vec2 LineEmitterVelocity(vec2 texCoord, vec2 linePosA, vec2 linePosB, float aspect, float angle, float size, float speed, vec2 noise)
{
vec2 lineDelta = linePosB - linePosA;
float distLineDelta = length(lineDelta) + 0.0001;
lineDelta /= distLineDelta;
float distOnEmitterLine = dot(lineDelta, texCoord - linePosA);
distOnEmitterLine = max(0.0, min(distLineDelta, distOnEmitterLine));
vec2 posOnEmitterLine = linePosA + lineDelta * distOnEmitterLine;
vec2 delta = texCoord - posOnEmitterLine;
//delta.y *= aspect;
float amt = step(length(delta), size) * g_Frametime * speed;
vec2 emitterSpeed = vec2(sin(angle), -cos(angle)) * amt;
//emitterSpeed.y *= aspect;
emitterSpeed *= step(CAST2(0.5), noise);
return emitterSpeed;
}
void main() {
//vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
//gl_FragColor = albedo;
float dt = min(1.0/20.0, g_Frametime);
//float dt = 1.0 / 60.0;
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture1, vL).x;
float R = texSample2D(g_Texture1, vR).x;
float T = texSample2D(g_Texture1, vT).x;
float B = texSample2D(g_Texture1, vB).x;
float C = texSample2D(g_Texture1, vUv).x;
vec2 force = 0.5 * vec2(abs(T) - abs(B), abs(R) - abs(L));
force /= length(force) + 0.0001;
force *= u_Curl * C;
force.y *= -1.0;
vec2 velocity = texSample2D(g_Texture0, v_TexCoord).xy;
velocity += force * dt;
velocity = min(max(velocity, -1000.0), 1000.0);
vec2 emitterUV = v_TexCoord;
#if PERSPECTIVE == 1
emitterUV = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
#endif
// Add emitter velocities
float aspect = g_Texture0Resolution.y / g_Texture0Resolution.x;
#if POINTEMITTER >= 1
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos0, m_EmitterAngle0, m_EmitterSize0, g_Frametime * m_EmitterSpeed0);
#endif
#if POINTEMITTER >= 2
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos1, m_EmitterAngle1, m_EmitterSize1, g_Frametime * m_EmitterSpeed1);
#endif
#if POINTEMITTER >= 3
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos2, m_EmitterAngle2, m_EmitterSize2, g_Frametime * m_EmitterSpeed2);
#endif
#if POINTEMITTER >= 4
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos3, m_EmitterAngle3, m_EmitterSize3, g_Frametime * m_EmitterSpeed3);
#endif
#if LINEEMITTER >= 1
vec2 noise = texSample2D(g_Texture2, emitterUV * 0.1 + g_Time * 0.01).rg;
velocity += LineEmitterVelocity(emitterUV, m_LineEmitterPosA0, m_LineEmitterPosB0, aspect, m_LineEmitterAngle0, m_LineEmitterSize0, m_LineEmitterSpeed0, noise);
#endif
#if LINEEMITTER >= 2
velocity += LineEmitterVelocity(emitterUV, m_LineEmitterPosA1, m_LineEmitterPosB1, aspect, m_LineEmitterAngle1, m_LineEmitterSize1, m_LineEmitterSpeed1, noise);
#endif
#if LINEEMITTER >= 3
velocity += LineEmitterVelocity(emitterUV, m_LineEmitterPosA2, m_LineEmitterPosB2, aspect, m_LineEmitterAngle2, m_LineEmitterSize2, m_LineEmitterSpeed2, noise);
#endif
// Cursor velocity interaction
vec2 texSource = v_TexCoord.xy;
vec2 unprojectedUVs = v_PointerUV.xy;
vec2 unprojectedUVsLast = v_PointerUVLast.xy;
float rippleMask = 1.0;
#if PERSPECTIVE == 1
// Block impulse when cursor moves across perspective horizon
rippleMask *= step(abs(unprojectedUVs.x - 0.5), 0.5);
rippleMask *= step(abs(unprojectedUVs.y - 0.5), 0.5);
rippleMask *= step(abs(unprojectedUVsLast.x - 0.5), 0.5);
rippleMask *= step(abs(unprojectedUVsLast.y - 0.5), 0.5);
#endif
vec2 lDelta = unprojectedUVs - unprojectedUVsLast;
vec2 texDelta = texSource - unprojectedUVsLast;
float distLDelta = length(lDelta) + 0.0001;
lDelta /= distLDelta; // DIV ZERO
float distOnLine = dot(lDelta, texDelta);
//distOnLine = distOnLine * distLDelta;
float rayMask = max(step(0.0, distOnLine) * step(distOnLine, distLDelta), step(distLDelta, 0.1));
distOnLine = saturate(distOnLine / distLDelta) * distLDelta;
vec2 posOnLine = unprojectedUVsLast + lDelta * distOnLine;
unprojectedUVs = (texSource - posOnLine) * vec2(v_PointDelta.y, v_PointerUV.w);
float pointerDist = length(unprojectedUVs);
pointerDist = saturate(1.0 - pointerDist);
pointerDist *= rayMask * rippleMask;
float timeAmt = 1.0; //g_Frametime / 0.1;
float pointerMoveAmt = v_PointDelta.x;
float inputStrength = pointerDist * timeAmt * (pointerMoveAmt + g_PointerState.z);
vec2 impulseDir = lDelta;
vec2 colorAdd = vec2(
impulseDir.x * inputStrength,
impulseDir.y * inputStrength
);
//gl_FragColor.xy += colorAdd * 300;
velocity += colorAdd * 300;
gl_FragColor = vec4(velocity, 0.0, 1.0);
}

View File

@@ -0,0 +1,101 @@
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
#include "common_perspective.h"
uniform mat4 g_EffectTextureProjectionMatrixInverse;
uniform vec2 g_PointerPosition;
uniform vec2 g_PointerPositionLast;
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
varying vec4 v_PointerUV;
varying vec4 v_PointerUVLast;
varying vec2 v_PointDelta;
#if PERSPECTIVE == 1
uniform vec2 g_Point0; // {"hidden":true,"material":"point0","label":"p0","default":"0 0"}
uniform vec2 g_Point1; // {"hidden":true,"material":"point1","label":"p1","default":"1 0"}
uniform vec2 g_Point2; // {"hidden":true,"material":"point2","label":"p2","default":"1 1"}
uniform vec2 g_Point3; // {"hidden":true,"material":"point3","label":"p3","default":"0 1"}
//varying mat3 v_XForm;
varying vec3 v_TexCoordPerspective;
#endif
uniform float u_CursorInfluence; // {"material":"cursorinfluence","label":"ui_editor_properties_cursor_influence","default":1.0,"range":[0.0, 2.0],"group":"ui_editor_properties_simulation"}
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = a_TexCoord.xyxy;
v_TexCoordRightBottom = a_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
// Cursor velocity interaction
vec2 pointer = g_PointerPosition;
pointer.y = 1.0 - pointer.y; // Flip pointer screen space Y to match texture space Y
vec2 pointerLast = g_PointerPositionLast;
pointerLast.y = 1.0 - pointerLast.y;
#if PERSPECTIVE == 1
mat3 xform = inverse(squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3));
//v_XForm = xform;
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), inverse(xform));
#endif
vec4 preTransformPoint = vec4(pointer * 2 - 1, 0.0, 1.0);
vec4 preTransformPointLast = vec4(pointerLast * 2 - 1, 0.0, 1.0);
//v_PointerUV.xyz = preTransformPoint.xyw; //mul(preTransformPoint, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUV.xyz = mul(preTransformPoint, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUV.xy *= 0.5;
v_PointerUV.xy /= v_PointerUV.z;
//v_PointerUVLast.xyz = preTransformPointLast.xyw; // mul(preTransformPointLast, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUVLast.xyz = mul(preTransformPointLast, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUVLast.xy *= 0.5;
v_PointerUVLast.xy /= v_PointerUVLast.z;
v_PointerUV.w = g_Texture0Resolution.y / -g_Texture0Resolution.x;
//v_PointerUV.y *= v_PointerUV.w;
float moveAmt = length(g_PointerPosition - g_PointerPositionLast);
v_PointDelta.x = step(0, moveAmt) * 0.5 + moveAmt * 10.0 * u_CursorInfluence;
//v_PointDelta.x *= 100;
//v_PointDelta.x *= 0.5;
v_PointDelta.y = 60.0 / max(0.0001, u_CursorInfluence);
v_PointerUV.w *= -v_PointDelta.y;
v_PointerUVLast.w = v_PointerUV.w;
v_PointerUV.xy += 0.5;
v_PointerUV.y = 1.0 - v_PointerUV.y;
v_PointerUV.z = 1;
v_PointerUVLast.xy += 0.5;
v_PointerUVLast.y = 1.0 - v_PointerUVLast.y;
v_PointerUVLast.z = 1;
#if PERSPECTIVE == 1
v_PointerUV.xyz = mul(v_PointerUV.xyz, xform);
v_PointerUVLast.xyz = mul(v_PointerUVLast.xyz, xform);
v_PointerUV.xy /= v_PointerUV.z;
v_PointerUVLast.xy /= v_PointerUVLast.z;
#endif
}

View File

@@ -0,0 +1,4 @@
{
"name": "FX Preview",
"type": "scene2d"
}

View File

@@ -0,0 +1,191 @@
// [COMBO] {"material":"ui_editor_properties_point_emitter_count","combo":"POINTEMITTER","type":"options","default":1,"options":[0,1,2,3]}
// [COMBO] {"material":"ui_editor_properties_line_emitter_count","combo":"LINEEMITTER","type":"options","default":0,"options":[0,1,2,3]}
// [COMBO] {"material":"ui_editor_properties_rendering","combo":"RENDERING","type":"options","default":0,"options":{"ui_editor_properties_gradient":0,"ui_editor_properties_emitter_color":1,"ui_editor_properties_background_color":2,"ui_editor_properties_distortion":3}}
uniform float g_Frametime;
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
uniform sampler2D g_Texture2; // {"hidden":true}
uniform sampler2D g_Texture3; // {"label":"ui_editor_properties_collision_mask","mode":"opacitymask","combo":"COLLISIONMASK","paintdefaultcolor":"0 0 0 1","painttexturescale":1,"require":{"DYE":0}}
uniform sampler2D g_Texture4; // {"label":"ui_editor_properties_dye_emitter","mode":"rgbmask","combo":"DYEEMITTER","paintdefaultcolor":"0 0 0 1","painttexturescale":1,"require":{"DYE":1}}
uniform vec4 g_Texture0Resolution;
uniform float u_Dissipation; // {"material":"dissipationfactor","label":"ui_editor_properties_dissipation","default":1.0,"range":[0.01, 10.0],"group":"ui_editor_properties_simulation"}
uniform float u_Viscosity; // {"material":"viscosityfactor","label":"ui_editor_properties_viscosity","default":1.0,"range":[0.0, 20.0],"group":"ui_editor_properties_simulation"}
uniform float m_Dissipation; // {"hidden":true,"material":"dissipation","label":"ui_editor_properties_dissipation","default":1.0,"range":[0.0, 1.0],"group":"ui_editor_properties_simulation"}
uniform float u_Lifetime; // {"material":"lifetime","label":"ui_editor_properties_high_pass","default":0.1,"range":[0.1, 1.0],"group":"ui_editor_properties_simulation"}
uniform float u_Saturation; // {"material":"saturation","label":"ui_editor_properties_saturation","default":1.0,"range":[0.0, 1.0]}
varying vec2 v_TexCoord;
uniform float u_ConstantVelocityAngle; // {"material":"forcedirection","label":"ui_editor_properties_direction","default":3.141593,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_gravity"}
uniform float u_ConstantVelocityStrength; // {"material":"forcestrength","label":"ui_editor_properties_strength","default":0.0,"range":[0,100.0],"group":"ui_editor_properties_gravity"}
#if DYE
uniform vec2 m_EmitterPos0; // {"material":"emitterPos0","default":"0.5 0.5"}
uniform float m_EmitterSize0; // {"material":"emitterSize0","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor0; // {"material":"emitterColor0","label":"ui_editor_properties_color","default":"1 0 0","group":"ui_editor_properties_point_emitter_1","type":"color"}
uniform vec2 m_EmitterPos1; // {"material":"emitterPos1","default":"0.5 0.7"}
uniform float m_EmitterSize1; // {"material":"emitterSize1","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor1; // {"material":"emitterColor1","label":"ui_editor_properties_color","default":"0 1 0","group":"ui_editor_properties_point_emitter_2","type":"color"}
uniform vec2 m_EmitterPos2; // {"material":"emitterPos2","default":"0.7 0.7"}
uniform float m_EmitterSize2; // {"material":"emitterSize2","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor2; // {"material":"emitterColor2","label":"ui_editor_properties_color","default":"0 0 1","group":"ui_editor_properties_point_emitter_3","type":"color"}
uniform vec2 m_EmitterPos3; // {"material":"emitterPos3","default":"0.7 0.5"}
uniform float m_EmitterSize3; // {"material":"emitterSize3","default":0.05,"range":[0.0, 0.3]}
uniform vec3 m_EmitterColor3; // {"material":"emitterColor3","label":"ui_editor_properties_color","default":"1 1 0","group":"ui_editor_properties_point_emitter_4","type":"color"}
uniform vec2 m_LineEmitterPosA0; // {"material":"lineEmitterPosA0","default":"0.1 0.1"}
uniform vec2 m_LineEmitterPosB0; // {"material":"lineEmitterPosB0","default":"0.4 0.1"}
uniform float m_LineEmitterSize0; // {"material":"lineEmitterSize0","default":0.02}
uniform vec3 m_LineEmitterColor0; // {"material":"lineEmitterColor0","label":"ui_editor_properties_color","default":"0 1 1","group":"ui_editor_properties_line_emitter_1","type":"color"}
uniform vec2 m_LineEmitterPosA1; // {"material":"lineEmitterPosA1","default":"0.1 0.2"}
uniform vec2 m_LineEmitterPosB1; // {"material":"lineEmitterPosB1","default":"0.4 0.2"}
uniform float m_LineEmitterSize1; // {"material":"lineEmitterSize1","default":0.02}
uniform vec3 m_LineEmitterColor1; // {"material":"lineEmitterColor1","label":"ui_editor_properties_color","default":"1 1 0","group":"ui_editor_properties_line_emitter_2","type":"color"}
uniform vec2 m_LineEmitterPosA2; // {"material":"lineEmitterPosA2","default":"0.1 0.3"}
uniform vec2 m_LineEmitterPosB2; // {"material":"lineEmitterPosB2","default":"0.4 0.3"}
uniform float m_LineEmitterSize2; // {"material":"lineEmitterSize2","default":0.02}
uniform vec3 m_LineEmitterColor2; // {"material":"lineEmitterColor2","label":"ui_editor_properties_color","default":"1 0 1","group":"ui_editor_properties_line_emitter_3","type":"color"}
#endif
#if PERSPECTIVE == 1
varying vec3 v_TexCoordPerspective;
#endif
vec4 AddEmitterColor(vec2 texCoord, float amt, vec4 currentColor, vec3 emitterColor)
{
#if RENDERING == 2
vec4 prevColor = texSample2D(g_Texture2, texCoord);
return mix(currentColor, prevColor, amt);
#endif
#if RENDERING == 1
emitterColor *= amt;
return min(currentColor + vec4(mix(g_Frametime, 1.0, u_Saturation) * emitterColor, amt), max(CAST4(1.0), vec4(emitterColor, amt)));
//return mix(currentColor, vec4(emitterColor, 1), amt);
#endif
// Clamp to max injected color for proper HDR behavior?
return min(currentColor + CAST4(amt), CAST4(1.0));
}
vec4 EmitterColor(vec2 texCoord, float aspect, vec4 currentColor, vec2 position, float size, vec3 emitterColor)
{
vec2 delta = position - texCoord;
delta.y *= aspect;
float amt = smoothstep(size, 0.0, length(delta));
return AddEmitterColor(texCoord, amt, currentColor, emitterColor);
}
vec4 LineEmitterColor(vec2 texCoord, vec2 linePosA, vec2 linePosB, float aspect, vec4 currentColor, float size, vec3 emitterColor)
{
vec2 lineDelta = linePosB - linePosA;
float distLineDelta = length(lineDelta) + 0.0001;
lineDelta /= distLineDelta;
float distOnEmitterLine = dot(lineDelta, texCoord - linePosA);
distOnEmitterLine = max(0.0, min(distLineDelta, distOnEmitterLine));
vec2 posOnEmitterLine = linePosA + lineDelta * distOnEmitterLine;
vec2 delta = texCoord - posOnEmitterLine;
delta.y *= aspect;
float amt = smoothstep(size, 0.0, length(delta));
return AddEmitterColor(texCoord, amt, currentColor, emitterColor);
}
void main() {
vec2 vUv = v_TexCoord;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
float dt = min(1.0/20.0, g_Frametime);
vec2 coord = vUv - dt * texSample2D(g_Texture0, vUv).xy * texelSize;
vec4 result = texSample2D(g_Texture1, coord);
#if DYE
float decayFactor = u_Dissipation;
float boundaryMask = step(0.0, coord.x) *
step(coord.x, 1.0) *
step(0.0, coord.y) *
step(coord.y, 1.0);
#else
float decayFactor = u_Viscosity;
#endif
float decay = 1.0 + decayFactor * m_Dissipation * dt;
//float lowPass = smoothstep(1.0, 0.00001, length(result.rgb)) * 0.5;
float lowPass = step(length(result.rgb), u_Lifetime) * 0.5;
#if DYE
result *= boundaryMask;
#endif
gl_FragColor = result / (decay + lowPass);
float aspect = g_Texture0Resolution.y / g_Texture0Resolution.x;
#if DYE
vec2 emitterUV = v_TexCoord;
#if PERSPECTIVE == 1
emitterUV = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
#endif
// Add color
#if POINTEMITTER >= 1
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos0, m_EmitterSize0, m_EmitterColor0);
#endif
#if POINTEMITTER >= 2
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos1, m_EmitterSize1, m_EmitterColor1);
#endif
#if POINTEMITTER >= 3
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos2, m_EmitterSize2, m_EmitterColor2);
#endif
#if POINTEMITTER >= 4
gl_FragColor = EmitterColor(emitterUV, aspect, gl_FragColor, m_EmitterPos3, m_EmitterSize3, m_EmitterColor3);
#endif
#if LINEEMITTER >= 1
gl_FragColor = LineEmitterColor(emitterUV, m_LineEmitterPosA0, m_LineEmitterPosB0, aspect, gl_FragColor, m_LineEmitterSize0, m_LineEmitterColor0);
#endif
#if LINEEMITTER >= 2
gl_FragColor = LineEmitterColor(emitterUV, m_LineEmitterPosA1, m_LineEmitterPosB1, aspect, gl_FragColor, m_LineEmitterSize1, m_LineEmitterColor1);
#endif
#if LINEEMITTER >= 3
gl_FragColor = LineEmitterColor(emitterUV, m_LineEmitterPosA2, m_LineEmitterPosB2, aspect, gl_FragColor, m_LineEmitterSize2, m_LineEmitterColor2);
#endif
#if DYEEMITTER
vec4 dyeEmitterSample = texSample2D(g_Texture4, v_TexCoord);
dyeEmitterSample.rgb *= dyeEmitterSample.a;
gl_FragColor = min(gl_FragColor + vec4(dyeEmitterSample.rgb * u_Saturation,
saturate(dot(dyeEmitterSample.rgb, CAST3(g_Frametime)) * dyeEmitterSample.a)),
CAST4(1.0));
#endif
#else
vec2 constantSpeed = vec2(sin(u_ConstantVelocityAngle), -cos(u_ConstantVelocityAngle)) * u_ConstantVelocityStrength;
constantSpeed.y *= aspect;
gl_FragColor.xy += constantSpeed * g_Frametime;
#if COLLISIONMASK
vec2 emitterUV = v_TexCoord;
#if PERSPECTIVE == 1
emitterUV = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
#endif
vec4 collisionColor = texSample2D(g_Texture3, emitterUV);
float solid = collisionColor.r * collisionColor.a;
gl_FragColor.xy = mix(gl_FragColor.xy, vec2(0, 0), solid);
#endif
#endif
}

View File

@@ -0,0 +1,27 @@
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
#include "common_perspective.h"
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
#if PERSPECTIVE == 1
uniform vec2 g_Point0; // {"hidden":true,"material":"point0","label":"p0","default":"0 0"}
uniform vec2 g_Point1; // {"hidden":true,"material":"point1","label":"p1","default":"1 0"}
uniform vec2 g_Point2; // {"hidden":true,"material":"point2","label":"p2","default":"1 1"}
uniform vec2 g_Point3; // {"hidden":true,"material":"point3","label":"p3","default":"0 1"}
varying vec3 v_TexCoordPerspective;
#endif
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
#if PERSPECTIVE == 1
mat3 xform = squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3);
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), xform);
#endif
}

View File

@@ -0,0 +1,8 @@
uniform sampler2D g_Texture0; // {"hidden":true}
varying vec3 v_TexCoord;
void main() {
gl_FragColor = v_TexCoord.z * texSample2D(g_Texture0, v_TexCoord.xy);
}

View File

@@ -0,0 +1,15 @@
uniform float g_Frametime;
uniform float u_Pressure; // {"material":"pressure","label":"ui_editor_properties_pressure","default":0.8,"range":[0.0, 1.0],"group":"ui_editor_properties_simulation"}
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec3 v_TexCoord;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord.xy = a_TexCoord.xy;
v_TexCoord.z = pow(u_Pressure, 60 * g_Frametime);
}

View File

@@ -0,0 +1,141 @@
// [COMBO] {"material":"ui_editor_properties_blend_mode","combo":"BLENDMODE","type":"imageblending","default":31}
// [COMBO] {"material":"ui_editor_properties_rendering","combo":"RENDERING","type":"options","default":0,"options":{"ui_editor_properties_gradient":0,"ui_editor_properties_emitter_color":1,"ui_editor_properties_background_color":2,"ui_editor_properties_distortion":3}}
// [COMBO] {"material":"ui_editor_properties_opaque_background","combo":"OPAQUE","type":"options","default":0}
// [COMBO] {"material":"ui_editor_properties_write_alpha","combo":"WRITEALPHA","type":"options","default":1}
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
// [COMBO] {"material":"ui_editor_properties_lighting","combo":"LIGHTING","type":"options","default":0}
#if LIGHTS_SHADOW_MAPPING
#define SHADOW_ATLAS_SAMPLER g_Texture6
#define SHADOW_ATLAS_TEXEL g_Texture6Texel
uniform sampler2DComparison g_Texture6; // {"hidden":true,"default":"_rt_shadowAtlas"}
uniform vec4 g_Texture6Texel;
#endif
#if LIGHTS_COOKIE
#define COOKIE_SAMPLER g_Texture7
uniform sampler2D g_Texture7; // {"hidden":true,"default":"_alias_lightCookie"}
#endif
#include "common_pbr_2.h"
#include "common_blending.h"
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
uniform sampler2D g_Texture2; // {"hidden":true}
uniform sampler2D g_Texture3; // {"label":"ui_editor_properties_gradient_map","default":"gradient/gradient_fire","require":{"RENDERING":0}}
uniform sampler2D g_Texture4; // {"hidden":true}
uniform float u_Brightness; // {"material":"brightness","label":"ui_editor_properties_brightness","default":1.0,"range":[0.01, 5]}
uniform float u_Alpha; // {"material":"opacity","label":"ui_editor_properties_opacity","default":1.0,"range":[0.01, 1]}
uniform float u_Feather; // {"material":"feather","label":"ui_editor_properties_feather","default":1.0,"range":[0.01, 1]}
uniform float u_HueShift; // {"material":"hue","label":"ui_editor_properties_hue","default":0.0,"range":[0.0, 1.0]}
varying vec2 v_TexCoord;
uniform vec4 g_Texture0Resolution;
uniform vec4 g_Texture1Resolution;
#if PERSPECTIVE == 1
varying vec3 v_TexCoordPerspective;
#endif
#if LIGHTING
uniform float u_Roughness; // {"material":"roughness","label":"ui_editor_properties_roughness","default":0.5,"range":[0,1],"group":"ui_editor_properties_material"}
uniform float u_Metallic; // {"material":"metallic","label":"ui_editor_properties_metallic","default":0.5,"range":[0,1],"group":"ui_editor_properties_material"}
uniform vec3 g_LightAmbientColor;
varying vec3 v_WorldPos;
#endif
#require LightingV1
void main() {
vec2 fxCoords = v_TexCoord.xy;
float fxMask = 1.0;
#if PERSPECTIVE == 1
fxCoords = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
fxMask *= step(abs(fxCoords.x - 0.5), 0.5);
fxMask *= step(abs(fxCoords.y - 0.5), 0.5);
#endif
vec4 albedo = texSample2D(g_Texture0, fxCoords.xy);
float refAlpha = albedo.a;
#if RENDERING == 0
vec4 gradientColor = texSample2D(g_Texture3, vec2(albedo.r, 0.5));
vec3 hsv = rgb2hsv(gradientColor.rgb);
hsv.x += u_HueShift;
albedo.rgb = hsv2rgb(hsv) * u_Brightness;
albedo.a *= gradientColor.a;
#endif
#if RENDERING == 1
albedo.rgb *= u_Brightness;
#endif
#if RENDERING == 2
albedo.rgb *= u_Brightness;
albedo.rgb /= albedo.a + 0.00001;
#endif
albedo.a = smoothstep(0.0, u_Feather, albedo.a);
#if RENDERING == 3
#if LIGHTING
vec2 velocity = texSample2D(g_Texture2, fxCoords.xy).xy * CAST2(2.0) - CAST2(1.0);
#else
float pressure = texSample2D(g_Texture4, fxCoords.xy).x;
vec2 velocity = vec2(ddx(pressure), ddy(pressure));
velocity = sign(velocity) * smoothstep(CAST2(0.01), CAST2(10.0), abs(velocity));
#endif
vec2 uvOffset = velocity;
vec4 prevDistorted = texSample2D(g_Texture1, v_TexCoord.xy - uvOffset);
albedo.rgb = prevDistorted.rgb;
albedo.a = 1;
#endif
albedo.a *= fxMask;
#if LIGHTING
vec3 normal = normalize(texSample2D(g_Texture2, fxCoords.xy).rgb * CAST3(2.0) - CAST3(1.0));
float metallic = u_Metallic;
float roughness = u_Roughness;
vec3 f0 = CAST3(0.04);
f0 = mix(f0, albedo.rgb, metallic);
vec3 normalizedViewVector = vec3(0, 0, 1);
vec3 light = CAST3(0.0);
#if LIGHTING
light = PerformLighting_V1(v_WorldPos, albedo.rgb, normal, normalizedViewVector, CAST3(1.0), f0, roughness, metallic);
vec3 ambient = max(CAST3(0.001), g_LightAmbientColor) * albedo.rgb;
#else
vec3 ambient = albedo.rgb;
#endif
albedo.rgb = CombineLighting(light, ambient);
#endif
#if OPAQUE
albedo.a = 1;
#else
vec4 prev = texSample2D(g_Texture1, v_TexCoord.xy);
#if BLENDMODE == 0
albedo = mix(prev, albedo, saturate(albedo.a) * u_Alpha);
#else
albedo.rgb = ApplyBlending(BLENDMODE, prev.rgb, albedo.rgb, albedo.a * u_Alpha);
#endif
albedo.a = saturate(prev.a + albedo.a);
#if WRITEALPHA == 0
albedo.a = prev.a;
#endif
#endif
gl_FragColor = albedo;
}

View File

@@ -0,0 +1,51 @@
#include "common_perspective.h"
uniform mat4 g_ModelViewProjectionMatrix;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
#if PERSPECTIVE == 1
uniform vec2 g_Point0; // {"hidden":true,"material":"point0","label":"p0","default":"0 0"}
uniform vec2 g_Point1; // {"hidden":true,"material":"point1","label":"p1","default":"1 0"}
uniform vec2 g_Point2; // {"hidden":true,"material":"point2","label":"p2","default":"1 1"}
uniform vec2 g_Point3; // {"hidden":true,"material":"point3","label":"p3","default":"0 1"}
varying vec3 v_TexCoordPerspective;
#endif
#if LIGHTING
uniform mat4 g_EffectModelMatrix;
uniform mat4 g_EffectModelViewProjectionMatrixInverse;
//uniform vec3 g_LightsPosition[4];
//varying vec4 v_Light0DirectionL3X;
//varying vec4 v_Light1DirectionL3Y;
//varying vec4 v_Light2DirectionL3Z;
varying vec3 v_WorldPos;
#endif
void main() {
gl_Position = mul(vec4(a_Position, 1.0), g_ModelViewProjectionMatrix);
v_TexCoord = a_TexCoord.xy;
#if PERSPECTIVE == 1
mat3 xform = inverse(squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3));
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), xform);
#endif
#if LIGHTING
v_WorldPos = mul(vec4(a_Position, 1.0), g_EffectModelMatrix).xyz;
//v_Light0DirectionL3X.xyz = g_LightsPosition[0] - worldPos.xyz;
//v_Light1DirectionL3Y.xyz = g_LightsPosition[1] - worldPos.xyz;
//v_Light2DirectionL3Z.xyz = g_LightsPosition[2] - worldPos.xyz;
//vec3 l3 = g_LightsPosition[3] - worldPos.xyz;
//
//v_Light0DirectionL3X.w = l3.x;
//v_Light1DirectionL3Y.w = l3.y;
//v_Light2DirectionL3Z.w = l3.z;
#endif
}

View File

@@ -0,0 +1,21 @@
uniform sampler2D g_Texture0; // {"hidden":true}
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture0, vL).y;
float R = texSample2D(g_Texture0, vR).y;
float T = texSample2D(g_Texture0, vT).x;
float B = texSample2D(g_Texture0, vB).x;
float vorticity = R - L - T + B;
//float vorticity = R - L - B + T;
gl_FragColor = vec4(0.5 * vorticity, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,21 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = a_TexCoord.xyxy;
v_TexCoordRightBottom = a_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,26 @@
uniform sampler2D g_Texture0; // {"hidden":true}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture0, vL).x;
float R = texSample2D(g_Texture0, vR).x;
float T = texSample2D(g_Texture0, vT).y;
float B = texSample2D(g_Texture0, vB).y;
vec2 C = texSample2D(g_Texture0, vUv).xy;
if (vL.x < 0.0) { L = -C.x; }
if (vR.x > 1.0) { R = -C.x; }
if (vT.y > 1.0) { T = -C.y; }
if (vB.y < 0.0) { B = -C.y; }
float div = 0.5 * (R - L + T - B);
gl_FragColor = vec4(div, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,23 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = v_TexCoord.xyxy;
v_TexCoordRightBottom = v_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,23 @@
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture0, vL).x;
float R = texSample2D(g_Texture0, vR).x;
float T = texSample2D(g_Texture0, vT).x;
float B = texSample2D(g_Texture0, vB).x;
vec2 velocity = texSample2D(g_Texture1, vUv).xy;
velocity.xy -= vec2(R - L, T - B);
gl_FragColor = vec4(velocity, 0.0, 1.0);
}

View File

@@ -0,0 +1,23 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = v_TexCoord.xyxy;
v_TexCoordRightBottom = v_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,30 @@
uniform sampler2D g_Texture0; // {"hidden":true}
uniform vec4 g_Texture0Resolution;
uniform float u_Depth; // {"material":"depth","label":"ui_editor_properties_depth","default":0.5,"range":[0,1],"group":"ui_editor_properties_material"}
varying vec2 v_TexCoord;
void main() {
vec2 fxCoords = v_TexCoord.xy;
float refAlpha = texSample2D(g_Texture0, fxCoords).a;
vec2 ist = CAST2(1.0) / g_Texture0Resolution.xy;
float s10 = texSample2D(g_Texture0, fxCoords + vec2(ist.x, 0.0)).a;
float s01 = texSample2D(g_Texture0, fxCoords + vec2(0.0, ist.y)).a;
vec2 base = vec2(s10 - refAlpha, s01 - refAlpha) * CAST2(25.0 * u_Depth);
//float bLen = length(base) + 0.0001;
//base /= bLen;
//bLen = saturate(bLen);
//base *= bLen * refAlpha;
base = clamp(base, CAST2(-1.0), CAST2(1.0)) * refAlpha;
vec3 normal = vec3(base, 0.0);
normal.x = -normal.x;
normal.z = sqrt(saturate(1.0 - normal.x * normal.x - normal.y * normal.y));
gl_FragColor = vec4(normal * CAST3(0.5) + CAST3(0.5), 1.0);
}

View File

@@ -0,0 +1,10 @@
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
}

View File

@@ -0,0 +1,24 @@
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture1, vL).x;
float R = texSample2D(g_Texture1, vR).x;
float T = texSample2D(g_Texture1, vT).x;
float B = texSample2D(g_Texture1, vB).x;
float C = texSample2D(g_Texture1, vUv).x;
float divergence = texSample2D(g_Texture0, vUv).x;
float pressure = (L + R + B + T - divergence) * 0.25;
gl_FragColor = vec4(pressure, 0.0, 0.0, 1.0);
}

View File

@@ -0,0 +1,23 @@
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = v_TexCoord.xyxy;
v_TexCoordRightBottom = v_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
}

View File

@@ -0,0 +1,209 @@
// [COMBO] {"material":"ui_editor_properties_point_emitter_count","combo":"POINTEMITTER","type":"options","default":1,"options":[0,1,2,3]}
// [COMBO] {"material":"ui_editor_properties_line_emitter_count","combo":"LINEEMITTER","type":"options","default":0,"options":[0,1,2,3]}
#include "common.h"
uniform float g_Frametime;
uniform float g_Time;
uniform sampler2D g_Texture0; // {"hidden":true}
uniform sampler2D g_Texture1; // {"hidden":true}
uniform sampler2D g_Texture2; // {"hidden":true,"default":"util/noise"}
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
uniform vec4 g_PointerState;
varying vec4 v_PointerUV;
varying vec4 v_PointerUVLast;
varying vec2 v_PointDelta;
#if PERSPECTIVE == 1
//varying mat3 v_XForm;
varying vec3 v_TexCoordPerspective;
#endif
uniform vec4 g_Texture0Resolution;
uniform float u_Curl; // {"material":"curl","label":"ui_editor_properties_curling","default":30.0,"range":[0.0, 50.0],"group":"ui_editor_properties_simulation"}
uniform vec2 m_EmitterPos0; // {"material":"emitterPos0","label":"ui_editor_properties_position","default":"0.5 0.5","group":"ui_editor_properties_point_emitter_1","attachmentproject":true,"attachmentangles":"emitterAngle0"}
uniform float m_EmitterAngle0; // {"material":"emitterAngle0","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_1"}
uniform float m_EmitterSize0; // {"material":"emitterSize0","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_1"}
uniform float m_EmitterSpeed0; // {"material":"emitterSpeed0","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_1"}
uniform vec2 m_EmitterPos1; // {"material":"emitterPos1","label":"ui_editor_properties_position","default":"0.5 0.7","group":"ui_editor_properties_point_emitter_2","attachmentproject":true,"attachmentangles":"emitterAngle1"}
uniform float m_EmitterAngle1; // {"material":"emitterAngle1","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_2"}
uniform float m_EmitterSize1; // {"material":"emitterSize1","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_2"}
uniform float m_EmitterSpeed1; // {"material":"emitterSpeed1","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_2"}
uniform vec2 m_EmitterPos2; // {"material":"emitterPos2","label":"ui_editor_properties_position","default":"0.7 0.7","group":"ui_editor_properties_point_emitter_3","attachmentproject":true,"attachmentangles":"emitterAngle2"}
uniform float m_EmitterAngle2; // {"material":"emitterAngle2","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_3"}
uniform float m_EmitterSize2; // {"material":"emitterSize2","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_3"}
uniform float m_EmitterSpeed2; // {"material":"emitterSpeed2","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_3"}
uniform vec2 m_EmitterPos3; // {"material":"emitterPos3","label":"ui_editor_properties_position","default":"0.7 0.5","group":"ui_editor_properties_point_emitter_4","attachmentproject":true,"attachmentangles":"emitterAngle3"}
uniform float m_EmitterAngle3; // {"material":"emitterAngle3","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_point_emitter_4"}
uniform float m_EmitterSize3; // {"material":"emitterSize3","label":"ui_editor_properties_size","default":0.05,"range":[0.0, 0.3],"group":"ui_editor_properties_point_emitter_4"}
uniform float m_EmitterSpeed3; // {"material":"emitterSpeed3","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_point_emitter_4"}
uniform vec2 m_LineEmitterPosA0; // {"material":"lineEmitterPosA0","label":"p0","default":"0.1 0.1","group":"ui_editor_properties_line_emitter_1","attachmentproject":true}
uniform vec2 m_LineEmitterPosB0; // {"material":"lineEmitterPosB0","label":"p1","default":"0.4 0.1","group":"ui_editor_properties_line_emitter_1","attachmentproject":true}
uniform float m_LineEmitterAngle0; // {"material":"lineEmitterAngle0","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_line_emitter_1"}
uniform float m_LineEmitterSize0; // {"material":"lineEmitterSize0","label":"ui_editor_properties_size","default":0.02,"range":[0.0, 0.3],"group":"ui_editor_properties_line_emitter_1"}
uniform float m_LineEmitterSpeed0; // {"material":"lineEmitterSpeed0","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_line_emitter_1"}
uniform vec2 m_LineEmitterPosA1; // {"material":"lineEmitterPosA1","label":"p0","default":"0.1 0.2","group":"ui_editor_properties_line_emitter_2","attachmentproject":true}
uniform vec2 m_LineEmitterPosB1; // {"material":"lineEmitterPosB1","label":"p1","default":"0.4 0.2","group":"ui_editor_properties_line_emitter_2","attachmentproject":true}
uniform float m_LineEmitterAngle1; // {"material":"lineEmitterAngle1","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_line_emitter_2"}
uniform float m_LineEmitterSize1; // {"material":"lineEmitterSize1","label":"ui_editor_properties_size","default":0.02,"range":[0.0, 0.3],"group":"ui_editor_properties_line_emitter_2"}
uniform float m_LineEmitterSpeed1; // {"material":"lineEmitterSpeed1","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_line_emitter_2"}
uniform vec2 m_LineEmitterPosA2; // {"material":"lineEmitterPosA2","label":"p0","default":"0.1 0.3","group":"ui_editor_properties_line_emitter_3","attachmentproject":true}
uniform vec2 m_LineEmitterPosB2; // {"material":"lineEmitterPosB2","label":"p1","default":"0.4 0.3","group":"ui_editor_properties_line_emitter_3","attachmentproject":true}
uniform float m_LineEmitterAngle2; // {"material":"lineEmitterAngle2","label":"ui_editor_properties_angle","default":0.0,"direction":true,"conversion":"rad2deg","group":"ui_editor_properties_line_emitter_3"}
uniform float m_LineEmitterSize2; // {"material":"lineEmitterSize2","label":"ui_editor_properties_size","default":0.02,"range":[0.0, 0.3],"group":"ui_editor_properties_line_emitter_3"}
uniform float m_LineEmitterSpeed2; // {"material":"lineEmitterSpeed2","label":"ui_editor_properties_force","default":100,"range":[0.0, 1000.0],"group":"ui_editor_properties_line_emitter_3"}
vec2 EmitterVelocity(vec2 texCoord, float aspect, vec2 position, float angle, float size, float speed)
{
vec2 delta = position - texCoord;
//delta.y *= aspect;
float amt = step(length(delta), size) * speed;
vec2 emitterSpeed = vec2(sin(angle), -cos(angle)) * amt;
//emitterSpeed.y *= aspect;
return emitterSpeed;
}
vec2 LineEmitterVelocity(vec2 texCoord, vec2 linePosA, vec2 linePosB, float aspect, float angle, float size, float speed, vec2 noise)
{
vec2 lineDelta = linePosB - linePosA;
float distLineDelta = length(lineDelta) + 0.0001;
lineDelta /= distLineDelta;
float distOnEmitterLine = dot(lineDelta, texCoord - linePosA);
distOnEmitterLine = max(0.0, min(distLineDelta, distOnEmitterLine));
vec2 posOnEmitterLine = linePosA + lineDelta * distOnEmitterLine;
vec2 delta = texCoord - posOnEmitterLine;
//delta.y *= aspect;
float amt = step(length(delta), size) * g_Frametime * speed;
vec2 emitterSpeed = vec2(sin(angle), -cos(angle)) * amt;
//emitterSpeed.y *= aspect;
emitterSpeed *= step(CAST2(0.5), noise);
return emitterSpeed;
}
void main() {
//vec4 albedo = texSample2D(g_Texture0, v_TexCoord.xy);
//gl_FragColor = albedo;
float dt = min(1.0/20.0, g_Frametime);
//float dt = 1.0 / 60.0;
vec2 vUv = v_TexCoord;
vec2 vL = v_TexCoordLeftTop.xy;
vec2 vR = v_TexCoordRightBottom.xy;
vec2 vT = v_TexCoordLeftTop.zw;
vec2 vB = v_TexCoordRightBottom.zw;
float L = texSample2D(g_Texture1, vL).x;
float R = texSample2D(g_Texture1, vR).x;
float T = texSample2D(g_Texture1, vT).x;
float B = texSample2D(g_Texture1, vB).x;
float C = texSample2D(g_Texture1, vUv).x;
vec2 force = 0.5 * vec2(abs(T) - abs(B), abs(R) - abs(L));
force /= length(force) + 0.0001;
force *= u_Curl * C;
force.y *= -1.0;
vec2 velocity = texSample2D(g_Texture0, v_TexCoord).xy;
velocity += force * dt;
velocity = min(max(velocity, -1000.0), 1000.0);
vec2 emitterUV = v_TexCoord;
#if PERSPECTIVE == 1
emitterUV = v_TexCoordPerspective.xy / v_TexCoordPerspective.z;
#endif
// Add emitter velocities
float aspect = g_Texture0Resolution.y / g_Texture0Resolution.x;
#if POINTEMITTER >= 1
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos0, m_EmitterAngle0, m_EmitterSize0, g_Frametime * m_EmitterSpeed0);
#endif
#if POINTEMITTER >= 2
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos1, m_EmitterAngle1, m_EmitterSize1, g_Frametime * m_EmitterSpeed1);
#endif
#if POINTEMITTER >= 3
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos2, m_EmitterAngle2, m_EmitterSize2, g_Frametime * m_EmitterSpeed2);
#endif
#if POINTEMITTER >= 4
velocity += EmitterVelocity(emitterUV, aspect, m_EmitterPos3, m_EmitterAngle3, m_EmitterSize3, g_Frametime * m_EmitterSpeed3);
#endif
#if LINEEMITTER >= 1
vec2 noise = texSample2D(g_Texture2, emitterUV * 0.1 + g_Time * 0.01).rg;
velocity += LineEmitterVelocity(emitterUV, m_LineEmitterPosA0, m_LineEmitterPosB0, aspect, m_LineEmitterAngle0, m_LineEmitterSize0, m_LineEmitterSpeed0, noise);
#endif
#if LINEEMITTER >= 2
velocity += LineEmitterVelocity(emitterUV, m_LineEmitterPosA1, m_LineEmitterPosB1, aspect, m_LineEmitterAngle1, m_LineEmitterSize1, m_LineEmitterSpeed1, noise);
#endif
#if LINEEMITTER >= 3
velocity += LineEmitterVelocity(emitterUV, m_LineEmitterPosA2, m_LineEmitterPosB2, aspect, m_LineEmitterAngle2, m_LineEmitterSize2, m_LineEmitterSpeed2, noise);
#endif
// Cursor velocity interaction
vec2 texSource = v_TexCoord.xy;
vec2 unprojectedUVs = v_PointerUV.xy;
vec2 unprojectedUVsLast = v_PointerUVLast.xy;
float rippleMask = 1.0;
#if PERSPECTIVE == 1
// Block impulse when cursor moves across perspective horizon
rippleMask *= step(abs(unprojectedUVs.x - 0.5), 0.5);
rippleMask *= step(abs(unprojectedUVs.y - 0.5), 0.5);
rippleMask *= step(abs(unprojectedUVsLast.x - 0.5), 0.5);
rippleMask *= step(abs(unprojectedUVsLast.y - 0.5), 0.5);
#endif
vec2 lDelta = unprojectedUVs - unprojectedUVsLast;
vec2 texDelta = texSource - unprojectedUVsLast;
float distLDelta = length(lDelta) + 0.0001;
lDelta /= distLDelta; // DIV ZERO
float distOnLine = dot(lDelta, texDelta);
//distOnLine = distOnLine * distLDelta;
float rayMask = max(step(0.0, distOnLine) * step(distOnLine, distLDelta), step(distLDelta, 0.1));
distOnLine = saturate(distOnLine / distLDelta) * distLDelta;
vec2 posOnLine = unprojectedUVsLast + lDelta * distOnLine;
unprojectedUVs = (texSource - posOnLine) * vec2(v_PointDelta.y, v_PointerUV.w);
float pointerDist = length(unprojectedUVs);
pointerDist = saturate(1.0 - pointerDist);
pointerDist *= rayMask * rippleMask;
float timeAmt = 1.0; //g_Frametime / 0.1;
float pointerMoveAmt = v_PointDelta.x;
float inputStrength = pointerDist * timeAmt * (pointerMoveAmt + g_PointerState.z);
vec2 impulseDir = lDelta;
vec2 colorAdd = vec2(
impulseDir.x * inputStrength,
impulseDir.y * inputStrength
);
//gl_FragColor.xy += colorAdd * 300;
velocity += colorAdd * 300;
gl_FragColor = vec4(velocity, 0.0, 1.0);
}

View File

@@ -0,0 +1,101 @@
// [COMBO] {"material":"ui_editor_properties_perspective","combo":"PERSPECTIVE","type":"options","default":0}
#include "common_perspective.h"
uniform mat4 g_EffectTextureProjectionMatrixInverse;
uniform vec2 g_PointerPosition;
uniform vec2 g_PointerPositionLast;
uniform vec4 g_Texture0Resolution;
attribute vec3 a_Position;
attribute vec2 a_TexCoord;
varying vec2 v_TexCoord;
varying vec4 v_TexCoordLeftTop;
varying vec4 v_TexCoordRightBottom;
varying vec4 v_PointerUV;
varying vec4 v_PointerUVLast;
varying vec2 v_PointDelta;
#if PERSPECTIVE == 1
uniform vec2 g_Point0; // {"hidden":true,"material":"point0","label":"p0","default":"0 0"}
uniform vec2 g_Point1; // {"hidden":true,"material":"point1","label":"p1","default":"1 0"}
uniform vec2 g_Point2; // {"hidden":true,"material":"point2","label":"p2","default":"1 1"}
uniform vec2 g_Point3; // {"hidden":true,"material":"point3","label":"p3","default":"0 1"}
//varying mat3 v_XForm;
varying vec3 v_TexCoordPerspective;
#endif
uniform float u_CursorInfluence; // {"material":"cursorinfluence","label":"ui_editor_properties_cursor_influence","default":1.0,"range":[0.0, 2.0],"group":"ui_editor_properties_simulation"}
void main() {
gl_Position = vec4(a_Position, 1.0);
v_TexCoord = a_TexCoord.xy;
vec2 texelSize = CAST2(1.0) / g_Texture0Resolution.xy;
v_TexCoordLeftTop = a_TexCoord.xyxy;
v_TexCoordRightBottom = a_TexCoord.xyxy;
v_TexCoordLeftTop.x -= texelSize.x;
v_TexCoordLeftTop.w += texelSize.y;
v_TexCoordRightBottom.x += texelSize.x;
v_TexCoordRightBottom.w -= texelSize.y;
// Cursor velocity interaction
vec2 pointer = g_PointerPosition;
pointer.y = 1.0 - pointer.y; // Flip pointer screen space Y to match texture space Y
vec2 pointerLast = g_PointerPositionLast;
pointerLast.y = 1.0 - pointerLast.y;
#if PERSPECTIVE == 1
mat3 xform = inverse(squareToQuad(g_Point0, g_Point1, g_Point2, g_Point3));
//v_XForm = xform;
v_TexCoordPerspective = mul(vec3(a_TexCoord.xy, 1.0), inverse(xform));
#endif
vec4 preTransformPoint = vec4(pointer * 2 - 1, 0.0, 1.0);
vec4 preTransformPointLast = vec4(pointerLast * 2 - 1, 0.0, 1.0);
//v_PointerUV.xyz = preTransformPoint.xyw; //mul(preTransformPoint, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUV.xyz = mul(preTransformPoint, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUV.xy *= 0.5;
v_PointerUV.xy /= v_PointerUV.z;
//v_PointerUVLast.xyz = preTransformPointLast.xyw; // mul(preTransformPointLast, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUVLast.xyz = mul(preTransformPointLast, g_EffectTextureProjectionMatrixInverse).xyw;
v_PointerUVLast.xy *= 0.5;
v_PointerUVLast.xy /= v_PointerUVLast.z;
v_PointerUV.w = g_Texture0Resolution.y / -g_Texture0Resolution.x;
//v_PointerUV.y *= v_PointerUV.w;
float moveAmt = length(g_PointerPosition - g_PointerPositionLast);
v_PointDelta.x = step(0, moveAmt) * 0.5 + moveAmt * 10.0 * u_CursorInfluence;
//v_PointDelta.x *= 100;
//v_PointDelta.x *= 0.5;
v_PointDelta.y = 60.0 / max(0.0001, u_CursorInfluence);
v_PointerUV.w *= -v_PointDelta.y;
v_PointerUVLast.w = v_PointerUV.w;
v_PointerUV.xy += 0.5;
v_PointerUV.y = 1.0 - v_PointerUV.y;
v_PointerUV.z = 1;
v_PointerUVLast.xy += 0.5;
v_PointerUVLast.y = 1.0 - v_PointerUVLast.y;
v_PointerUVLast.z = 1;
#if PERSPECTIVE == 1
v_PointerUV.xyz = mul(v_PointerUV.xyz, xform);
v_PointerUVLast.xyz = mul(v_PointerUVLast.xyz, xform);
v_PointerUV.xy /= v_PointerUV.z;
v_PointerUVLast.xy /= v_PointerUVLast.z;
#endif
}