diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..efb9808 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c8e9c6 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Geometry Grass in Godot + +This respository contains the project which is developed in my "Grass Rendering Series". To access the state of the project at the start or end of a given tutorial, check out that commit. + +If you want to follow along, start here: https://hexaquo.at/pages/grass-rendering-series-part-1-theory/ diff --git a/environment.tres b/environment.tres new file mode 100644 index 0000000..f3f95ba --- /dev/null +++ b/environment.tres @@ -0,0 +1,24 @@ +[gd_resource type="Environment" load_steps=3 format=3 uid="uid://c6gg4l7fynga2"] + +[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_3gqex"] +ground_color = Color(1, 1, 1, 1) + +[sub_resource type="Sky" id="Sky_tlwt5"] +sky_material = SubResource("PhysicalSkyMaterial_3gqex") + +[resource] +background_mode = 2 +background_energy_multiplier = 3.0 +sky = SubResource("Sky_tlwt5") +tonemap_mode = 4 +glow_enabled = true +glow_bloom = 0.1 +glow_blend_mode = 1 +fog_enabled = true +fog_light_color = Color(0.851974, 0.909539, 1, 1) +fog_sun_scatter = 0.15 +fog_aerial_perspective = 0.93 +fog_sky_affect = 0.0 +adjustment_enabled = true +adjustment_contrast = 1.3 +adjustment_saturation = 1.3 diff --git a/grass.gdshader b/grass.gdshader index 80528fc..6e58ed6 100644 --- a/grass.gdshader +++ b/grass.gdshader @@ -30,12 +30,12 @@ void vertex() { cut_height = 1.0; // Cutting all grass on the right - if (NODE_POSITION_WORLD.x > 0.0) { - cut_height = 0.5; - - VERTEX.y = min(VERTEX.y, cut_height); - UV.y = max(UV.y, 1.0 - cut_height); - } + //if (NODE_POSITION_WORLD.x > 0.0) { + //cut_height = 0.5; +// + //VERTEX.y = min(VERTEX.y, cut_height); + //UV.y = max(UV.y, 1.0 - cut_height); + //} bottom_to_top = 1.0 - UV.y; @@ -72,6 +72,9 @@ void vertex() { } void fragment() { + // Correct normals on back-faces + if (!FRONT_FACING) NORMAL = -NORMAL; + AO = bottom_to_top - current_wind_bend * wind_ao_affect; AO_LIGHT_AFFECT = cut_height; diff --git a/world.tscn b/world.tscn index 935eee2..c5c483c 100644 --- a/world.tscn +++ b/world.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=18 format=3 uid="uid://cvcy4ye5phhn4"] +[gd_scene load_steps=16 format=3 uid="uid://cvcy4ye5phhn4"] [ext_resource type="ArrayMesh" uid="uid://bte61gg2ejn5e" path="res://grass-stalk.obj" id="1_4cp3x"] [ext_resource type="Shader" uid="uid://db6rwrkgyosy0" path="res://grass.gdshader" id="2_8rwdi"] [ext_resource type="Script" uid="uid://bmx385ngdvuwt" path="res://grass.gd" id="3_aqk2v"] +[ext_resource type="Environment" uid="uid://c6gg4l7fynga2" path="res://environment.tres" id="4_aqk2v"] [sub_resource type="Gradient" id="Gradient_odt3n"] offsets = PackedFloat32Array(0) @@ -61,17 +62,6 @@ buffer = PackedFloat32Array(0.703672, 0, -0.711932, 2.46375, 0, 1.001, 0, 0, 0.7 [sub_resource type="SphereMesh" id="SphereMesh_tlwt5"] -[sub_resource type="PhysicalSkyMaterial" id="PhysicalSkyMaterial_3gqex"] -ground_color = Color(1, 1, 1, 1) -energy_multiplier = 3.0 - -[sub_resource type="Sky" id="Sky_a067n"] -sky_material = SubResource("PhysicalSkyMaterial_3gqex") - -[sub_resource type="Environment" id="Environment_cjdki"] -background_mode = 2 -sky = SubResource("Sky_a067n") - [node name="World" type="Node3D"] [node name="GrassChunk" type="Node3D" parent="."] @@ -92,9 +82,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0) mesh = SubResource("SphereMesh_tlwt5") [node name="WorldEnvironment" type="WorldEnvironment" parent="."] -environment = SubResource("Environment_cjdki") +environment = ExtResource("4_aqk2v") [node name="DirectionalLight3D" type="DirectionalLight3D" parent="WorldEnvironment"] transform = Transform3D(-0.926267, -0.376806, -0.00684522, -0.363545, 0.888589, 0.279724, -0.0993189, 0.261587, -0.960056, -0.156811, 0.610055, 0) -light_energy = 3.0 +light_energy = 1.5 shadow_enabled = true