Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions addons/material_maker/nodes/material.mmg
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,51 @@
}
]
},
"Imaginando VS 2": {
"custom": [
"func process_option_vs2(s : String, is_declaration : bool = false) -> String:",
"\ts = s.replace(\"elapsed_time\", \"time\")",
"\ts = s.replace(\"uniform vec2\", \"const vec2\")",
"\ts = s.replace(\"uniform vec3\", \"const vec3\")",
"\ts = s.replace(\"uniform mat2\", \"const mat2\")",
"\treturn s"
],
"export_extension": "vs2.frag",
"files": [
{
"file_name": "$(path_prefix).vs2.frag",
"template": [
"/*",
"{",
"\t\"author\": \"\",",
"\t\"color\": \"white\",",
"\t\"movement\": true,",
"\t\"name\": \"$(file_prefix)\",",
"\t\"parameters\": [],",
"\t\"url\": \"\",",
"\t\"uuid\": \"$uid(0)\"",
"}",
"*/",
"// mm2vs: exported-by=material-maker | target=imaginando-vs2",
"// mm2vs: finalize with `mm2vs convert <this file>` to normalize the uuid and lift exposed parameters.",
"$definitions float_uniform_to_const,vs2",
"void main() {",
"\tfloat _seed_variation_ = 0.0;",
"\tvec4 _controlled_variation_ = vec4(0.0);",
"\tvec2 uv = fract(texCoord);",
"$begin_generate vs2",
"\tvec3 mm2vs_albedo = $albedo_tex(uv) * vec3($(param:albedo_color.r), $(param:albedo_color.g), $(param:albedo_color.b));",
"\tvec3 mm2vs_emission = $emission_tex(uv) * $(param:emission_energy);",
"\tfloat mm2vs_opacity = $opacity_tex(uv) * $(param:albedo_color.a);",
"\tvec4 generatedColor = vec4(mm2vs_albedo + mm2vs_emission, mm2vs_opacity);",
"$end_generate",
"\tfragColor = vec4(generatedColor.rgb, generatedColor.a * alpha);",
"}"
],
"type": "template"
}
]
},
"Unity/3D": {
"export_extension": "mat",
"files": [
Expand Down
42 changes: 42 additions & 0 deletions addons/material_maker/nodes/material_unlit.mmg
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,48 @@
}
]
},
"Imaginando VS 2": {
"custom": [
"func process_option_vs2(s : String, is_declaration : bool = false) -> String:",
"\ts = s.replace(\"elapsed_time\", \"time\")",
"\ts = s.replace(\"uniform vec2\", \"const vec2\")",
"\ts = s.replace(\"uniform vec3\", \"const vec3\")",
"\ts = s.replace(\"uniform mat2\", \"const mat2\")",
"\treturn s"
],
"export_extension": "vs2.frag",
"files": [
{
"file_name": "$(path_prefix).vs2.frag",
"template": [
"/*",
"{",
"\t\"author\": \"\",",
"\t\"color\": \"white\",",
"\t\"movement\": true,",
"\t\"name\": \"$(file_prefix)\",",
"\t\"parameters\": [],",
"\t\"url\": \"\",",
"\t\"uuid\": \"$uid(0)\"",
"}",
"*/",
"// mm2vs: exported-by=material-maker | target=imaginando-vs2",
"// mm2vs: finalize with `mm2vs convert <this file>` to normalize the uuid and lift exposed parameters.",
"$definitions float_uniform_to_const,vs2",
"void main() {",
"\tfloat _seed_variation_ = 0.0;",
"\tvec4 _controlled_variation_ = vec4(0.0);",
"\tvec2 uv = fract(texCoord);",
"$begin_generate vs2",
"\tvec4 generatedColor = $color_tex(uv);",
"$end_generate",
"\tfragColor = vec4(generatedColor.rgb, generatedColor.a * alpha);",
"}"
],
"type": "template"
}
]
},
"Unity": {
"export_extension": "mat",
"files": [
Expand Down
24 changes: 24 additions & 0 deletions material_maker/doc/export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ Godot game engine
When exporting for the Godot game engine, Material Maker will generate a .tres file that
describes a fully configured SpatialMaterial.

Imaginando VS 2
-----------------

When exporting for `Imaginando VS 2 <https://www.imaginando.pt/products/vs-visual-synthesizer>`_
(Visual Synthesizer), Material Maker generates a single ``.vs2.frag`` GLSL fragment
shader that can be imported with the Import button of VS 2's Material Browser.

The file contains the generated code for the material's albedo, emission and
opacity channels (VS 2 layers are unlit, so lighting inputs such as roughness or
normal are not exported), adapted to VS 2's predeclared environment (``time``,
``alpha``, ``color``, ``resolution``, ``texCoord``, ``fragColor``) and preceded
by the JSON manifest VS 2 requires. Named parameters referenced in the exported
branch are included with their current values.

Two limitations are worth knowing:

* the manifest uuid is generated without hyphens; VS 2 uses the hyphenated form,
which can be obtained by inserting hyphens in 8-4-4-4-12 grouping (the
companion ``mm2vs`` tool does this automatically and can also turn named
parameters into live VS 2 controls),
* materials that use buffer-based nodes (blur, warp, …) cannot be expressed as a
single VS 2 fragment shader; the exported file will reference textures that VS
2 cannot provide.

Unity game engine
-----------------

Expand Down