diff --git a/doc/demo11_particle_light/image/laigter.JPG b/doc/demo11_particle_light/image/laigter.JPG new file mode 100644 index 0000000..87aac90 Binary files /dev/null and b/doc/demo11_particle_light/image/laigter.JPG differ diff --git a/doc/demo11_particle_light/image/laigter.JPG.import b/doc/demo11_particle_light/image/laigter.JPG.import new file mode 100644 index 0000000..d5838fe --- /dev/null +++ b/doc/demo11_particle_light/image/laigter.JPG.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/laigter.JPG-fce275ef4cf4f956989ac079a7dfca9d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://doc/demo11_particle_light/image/laigter.JPG" +dest_files=[ "res://.import/laigter.JPG-fce275ef4cf4f956989ac079a7dfca9d.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/doc/demo11_particle_light/image/light-settings.gif b/doc/demo11_particle_light/image/light-settings.gif new file mode 100644 index 0000000..3f0dec7 Binary files /dev/null and b/doc/demo11_particle_light/image/light-settings.gif differ diff --git a/doc/demo11_particle_light/image/light_shadow_main.png b/doc/demo11_particle_light/image/light_shadow_main.png new file mode 100644 index 0000000..7190a0f Binary files /dev/null and b/doc/demo11_particle_light/image/light_shadow_main.png differ diff --git a/doc/demo11_particle_light/image/light_shadow_main.png.import b/doc/demo11_particle_light/image/light_shadow_main.png.import new file mode 100644 index 0000000..9fb3220 --- /dev/null +++ b/doc/demo11_particle_light/image/light_shadow_main.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/light_shadow_main.png-1196e88b3b574bbbb10d5cc94f3a3d00.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://doc/demo11_particle_light/image/light_shadow_main.png" +dest_files=[ "res://.import/light_shadow_main.png-1196e88b3b574bbbb10d5cc94f3a3d00.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/doc/demo11_particle_light/image/set-normal-map.gif b/doc/demo11_particle_light/image/set-normal-map.gif new file mode 100644 index 0000000..2aa009f Binary files /dev/null and b/doc/demo11_particle_light/image/set-normal-map.gif differ diff --git a/doc/demo11_particle_light/image/simple-sprite-with-normal.gif b/doc/demo11_particle_light/image/simple-sprite-with-normal.gif new file mode 100644 index 0000000..8ea6462 Binary files /dev/null and b/doc/demo11_particle_light/image/simple-sprite-with-normal.gif differ diff --git a/doc/demo11_particle_light/particle.md b/doc/demo11_particle_light/particle.md index 4abfa43..cd9234f 100644 --- a/doc/demo11_particle_light/particle.md +++ b/doc/demo11_particle_light/particle.md @@ -1,11 +1,21 @@ -# 1. 光照系统 +# 1. 光照系统Light2D - godot 的 2D 动态光照 - 首先看看 Demo 的预览效果。可以看到,当我们在 Demo 中移动光源的位置,小人和场景也会随之表现出不同光照的情景 ![Image text](image/light1.gif) -- 那么它和普通的 Sprite 有什么区别呢? 通过对比不难看出它们的差别主要是集中在材质上面。小人使用了自定义的 mat_normal 材质 +- 带法线贴图的Sprite和普通的 Sprite 有什么区别呢? 通过对比不难看出它们的差别主要是集中在材质上面。小人使用了自定义的 mat_normal 材质 + +# 2. 法线贴图NormalMap + +- 法线贴图的定义 + +``` +法线贴图就是在原物体的凹凸表面的每个点上均作法线,通过RGB颜色通道来标记法线的方向, +你可以把它理解成与原凹凸表面平行的另一个不同的表面,但实际上它又只是一个光滑的平面。 +对于视觉效果而言,它的效率比原有的凹凸表面更高,若在特定位置上应用光源,可以让细节程度较低的表面生成高细节程度的精确光照方向和反射效果。 +``` ![Image text](image/light2.jpg) @@ -15,7 +25,22 @@ 模拟光照的过程实际上就是模拟整个光的传播过程。 ``` -# 2. 粒子系统 +- 需要注意的是,法线贴图在3D游戏中运用的更多一点,2D稍微少很多 + +- 法线贴图的制作软件[laigter](https://github.com/azagaya/laigter) + ![Image text](image/laigter.JPG) + +- godot中使用法线贴图非常的简单 + ![Image text](image/set-normal-map.gif) + ![Image text](image/light-settings.gif) + ![Image text](image/simple-sprite-with-normal.gif) + +# 3. 光照和阴影LightOccluder2D + +- 光照是指光的照射,godot 中光照的实现模拟了光对真实世界的影响。在场景中添加光源可以使场景产生相应的光照和阴影效果,获得更好的视觉效果。 + ![Image text](image/light_shadow_main.png) + +# 4. 粒子系统 ![Image text](image/particle1.png) ![Image text](image/particle2.png) @@ -43,4 +68,4 @@ ![Image text](image/particle24.png) ![Image text](image/particle25.png) ![Image text](image/particle26.png) -![Image text](image/particle27.png) \ No newline at end of file +![Image text](image/particle27.png) diff --git a/scene/demo11_particle_light/normal_map.tscn b/scene/demo11_particle_light/normal_map.tscn new file mode 100644 index 0000000..da57435 --- /dev/null +++ b/scene/demo11_particle_light/normal_map.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://scene/demo11_particle_light/normal_map/azagaya_n.png" type="Texture" id=1] +[ext_resource path="res://scene/demo11_particle_light/normal_map/azagaya.png" type="Texture" id=2] +[ext_resource path="res://scene/demo11_particle_light/normal_map/LightSprite.png" type="Texture" id=3] + +[node name="Node2D" type="Node2D"] + +[node name="azagaya" type="Sprite" parent="."] +position = Vector2( 270, 199.431 ) +texture = ExtResource( 2 ) +normal_map = ExtResource( 1 ) + +[node name="Light2D" type="Light2D" parent="."] +position = Vector2( 306.368, 226.998 ) +texture = ExtResource( 3 ) diff --git a/scene/demo11_particle_light/normal_map/LightSprite.png b/scene/demo11_particle_light/normal_map/LightSprite.png new file mode 100644 index 0000000..b5b04d7 Binary files /dev/null and b/scene/demo11_particle_light/normal_map/LightSprite.png differ diff --git a/scene/demo11_particle_light/normal_map/LightSprite.png.import b/scene/demo11_particle_light/normal_map/LightSprite.png.import new file mode 100644 index 0000000..247046b --- /dev/null +++ b/scene/demo11_particle_light/normal_map/LightSprite.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/LightSprite.png-c40d01886f4a6ec8b4377142d643177e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scene/demo11_particle_light/normal_map/LightSprite.png" +dest_files=[ "res://.import/LightSprite.png-c40d01886f4a6ec8b4377142d643177e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/scene/demo11_particle_light/normal_map/azagaya.png b/scene/demo11_particle_light/normal_map/azagaya.png new file mode 100644 index 0000000..355c8dc Binary files /dev/null and b/scene/demo11_particle_light/normal_map/azagaya.png differ diff --git a/scene/demo11_particle_light/normal_map/azagaya.png.import b/scene/demo11_particle_light/normal_map/azagaya.png.import new file mode 100644 index 0000000..ff2505c --- /dev/null +++ b/scene/demo11_particle_light/normal_map/azagaya.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/azagaya.png-ad429dd9403620b051e8578587d08aea.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scene/demo11_particle_light/normal_map/azagaya.png" +dest_files=[ "res://.import/azagaya.png-ad429dd9403620b051e8578587d08aea.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/scene/demo11_particle_light/normal_map/azagaya_n.png b/scene/demo11_particle_light/normal_map/azagaya_n.png new file mode 100644 index 0000000..5a506f4 Binary files /dev/null and b/scene/demo11_particle_light/normal_map/azagaya_n.png differ diff --git a/scene/demo11_particle_light/normal_map/azagaya_n.png.import b/scene/demo11_particle_light/normal_map/azagaya_n.png.import new file mode 100644 index 0000000..05f3a9b --- /dev/null +++ b/scene/demo11_particle_light/normal_map/azagaya_n.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/azagaya_n.png-5b93a8bb5a6286587518a775b01152a3.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scene/demo11_particle_light/normal_map/azagaya_n.png" +dest_files=[ "res://.import/azagaya_n.png-5b93a8bb5a6286587518a775b01152a3.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/scene/demo11_particle_light/normal_map/simplebrick.png b/scene/demo11_particle_light/normal_map/simplebrick.png new file mode 100644 index 0000000..48a9226 Binary files /dev/null and b/scene/demo11_particle_light/normal_map/simplebrick.png differ diff --git a/scene/demo11_particle_light/normal_map/simplebrick.png.import b/scene/demo11_particle_light/normal_map/simplebrick.png.import new file mode 100644 index 0000000..13543da --- /dev/null +++ b/scene/demo11_particle_light/normal_map/simplebrick.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/simplebrick.png-5e16cb9c113a4ed9a022f89e50a799bc.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scene/demo11_particle_light/normal_map/simplebrick.png" +dest_files=[ "res://.import/simplebrick.png-5e16cb9c113a4ed9a022f89e50a799bc.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/scene/demo11_particle_light/normal_map/simplebrick_n.png b/scene/demo11_particle_light/normal_map/simplebrick_n.png new file mode 100644 index 0000000..345f112 Binary files /dev/null and b/scene/demo11_particle_light/normal_map/simplebrick_n.png differ diff --git a/scene/demo11_particle_light/normal_map/simplebrick_n.png.import b/scene/demo11_particle_light/normal_map/simplebrick_n.png.import new file mode 100644 index 0000000..725fcf8 --- /dev/null +++ b/scene/demo11_particle_light/normal_map/simplebrick_n.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/simplebrick_n.png-b5f5247c3aa4e49d79ccb3dd8d40a42e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://scene/demo11_particle_light/normal_map/simplebrick_n.png" +dest_files=[ "res://.import/simplebrick_n.png-b5f5247c3aa4e49d79ccb3dd8d40a42e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0