Skip to content

Commit

Permalink
Improve shader editor templates to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
Calinou committed Jul 17, 2023
1 parent 851bc64 commit 02bf74a
Showing 1 changed file with 48 additions and 21 deletions.
69 changes: 48 additions & 21 deletions editor/shader_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,37 +164,64 @@ void ShaderCreateDialog::_create_new() {
code += vformat("shader_type %s;\n", mode_menu->get_text().to_snake_case());

if (current_template == 0) { // Default template.
code += "\n";
switch (current_mode) {
case Shader::MODE_SPATIAL:
code += "void fragment() {\n";
code += "\t// Place fragment code here.\n";
code += "}\n";
code += R"(
void vertex() {
// Called for every vertex the material is visible on.
}
void fragment() {
// Called for every pixel the material is visible on.
}
void light() {
// Called for every pixel for every light affecting the material.
}
)";
break;
case Shader::MODE_CANVAS_ITEM:
code += "void fragment() {\n";
code += "\t// Place fragment code here.\n";
code += "}\n";
code += R"(
void vertex() {
// Called for every vertex the material is visible on.
}
void fragment() {
// Called for every pixel the material is visible on.
}
void light() {
// Called for every pixel for every light affecting the CanvasItem.
}
)";
break;
case Shader::MODE_PARTICLES:
code += "void start() {\n";
code += "\t// Place start code here.\n";
code += "}\n";
code += "\n";
code += "void process() {\n";
code += "\t// Place process code here.\n";
code += "}\n";
code += R"(
void start() {
// Called when a particle is spawned.
}
void process() {
// Called every frame on existing particles (according to the Fixed FPS property).
}
)";
break;
case Shader::MODE_SKY:
code += "void sky() {\n";
code += "\t// Place sky code here.\n";
code += "}\n";
code += R"(
void sky() {
// Called for every visible pixel in the sky background, as well as all pixels
// in the radiance cubemap.
}
)";
break;
case Shader::MODE_FOG:
code += "void fog() {\n";
code += "\t// Place fog code here.\n";
code += "}\n";
break;
code += R"(
void fog() {
// Called once for every froxel that is touched by an axis-aligned bounding box
// of the associated FogVolume. This means that froxels that just barely touch
// a given FogVolume will still be used.
}
)";
}
}
text_shader->set_code(code.as_string());
Expand Down

0 comments on commit 02bf74a

Please sign in to comment.