浏览代码

Improve shader editor templates to be more descriptive

Hugo Locurcio 4 年之前
父节点
当前提交
02bf74a954
共有 1 个文件被更改,包括 48 次插入21 次删除
  1. 48 21
      editor/shader_create_dialog.cpp

+ 48 - 21
editor/shader_create_dialog.cpp

@@ -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());