Procházet zdrojové kódy

update material.md & render.md (#398)

* read only user

* html5 gamepad

* sdk api update

* update

* image properties

* update editor

* defold sdk update

* animation updates

* animation fix

* run as admin

* update bob

* update about AndroidX support

* software render

* linux-faq.md update

* 4.28.2021 updates

* Basis Universal format

* sound & mesh

* gamepad event mapping

* admob url

* Minor edit to building blocks intro text

* update gamepad & ios

* project settings

* libffi version

* scaling

* image compression

* update gamepads

* increase memory

* caching assets

* update 2021/10/6

* update 2021/10/16
blend-modes.md

* update 2021/11/12

* allow dynamic transforms update

* Bundle update

* update faq

* bullet & bob

* script properties update

* editor-styling

* build server url

* editor templates

* spine extension update

* Fix typo in the "optimizations" word in Chinese docs

* Update to material.md - Constants buffers

* Verify Graphics Calls

* H5 parameters

* OpenJDK downloads

* cn update corresponds to [pull 259](https://github.com/defold/doc/pull/259)

* application security

* porting guidelines

* update for 8f1651f

* cn update for 094bf6f

* cn update for 20fdfc5 & 6263317

* cn update for 7/19/2022

* title

* profiling update

* update editor.md

* update bob.md

* update shortcuts

* update fixed update note

* Update properties.md

* Update material.md

* Updates links

* Update bob help with the latest info

* camera & renderer

* Updated android keystore info zh_cn

* bundling.md release vs debug zh_cn

* update bob.md & gui-clipping.md

* contentless bundle

* consoles update

* model animation link

* gamepad & faq

* remove a camera lib

* font shadow render mode fix

* updates about app-manifest and others

* Update script.md

* includes in shaders

* editor scripts

* material updates

* Added dynamic atlas and texture creation

* fixes for atlas and some others

* update screenshots and add explanations (CN)

* add a line about Dynamic Prototype (CN)

* remove "inline" marks in pics

* de-translate the subtitle "Running the debugger" & images fix

* bundle identifier restrictions

* node properties Enabled and Visible (CN)

* release checklist & slice-9

* Update project-settings.md (CN)

* Update camera.md (CN)

* Update project-settings.md (CN)

* culling of meshes (CN)

* Update project-settings.md (CN)

* gltf model file support (CN)

* updates about factory (CN)

* Update bob.md (CN)

* Update bob.jar help (CN)

* Update about renderer and other things

* Update PS4 development and other things

* Dynamic prototype part of the collection factory.

* sync to atlas.md

* sync to design.md

* sync to gpgs.md

* sync to hot-reload.md

* sync to linux.md

* sync to live-update.md

* sync to lua.md

* sync to networking.md

* sync to physics-shapes.md

* sync to push.md

* sync to test.md

* sync to working-offline.md

* update material.md

* update zerobrane.md

* all done

* Splitting .zip archives in live-update.md

* manual for collision events

* Updated sprite documentation to include info about multiple textures

* update editor-scripts.md & physics-events.md

* update buffer.md & physics-shapes.md

* screen blend mode

* Update camera manual for zh with new function.

* Fix texture profile documentation for 1.7.0 zh

* update material.md & render.md
COCO před 1 rokem
rodič
revize
c815ce251c
2 změnil soubory, kde provedl 76 přidání a 4 odebrání
  1. 15 3
      docs/zh/manuals/material.md
  2. 61 1
      docs/zh/manuals/render.md

+ 15 - 3
docs/zh/manuals/material.md

@@ -92,9 +92,20 @@ Value
 自定义属性也可以在 CPU 和 GPU 上帮助减少内存占用, 方法是重构流以使用更小的数据类型, 或更少的元素.
 :::
 
-::: important
-自定义属性从 Defold 1.4.8 版本开始可用!
-:::
+与用户自定义着色器常量类似, 你也可以通过调用 go.get, go.set 和 go.animate 在运行时更新顶点属性:
+	
+![Custom material attribute](images/materials/set_custom_attribute.png)
+
+```lua
+go.set("#sprite", "tint", vmath.vector4(1,0,0,1))
+
+go.animate("#sprite", "tint", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(1,0,0,1), go.EASING_LINEAR, 2)
+```
+
+更新顶点属性有一些注意事项, 组件是否可以使用该值取决于属性的语义类型. 比如, sprite 组件支持 `SEMANTIC_TYPE_POSITION` 所以如果你更新有该语义类型的属性, 该组件将忽略覆盖的值, 因为语义类型规定数据应始终由 sprites 位置生成.
+
+::: sidenote
+目前仅 sprite 组件支持在运行时设置自定义顶点数据.
 
 ## 顶点和片元常量
 
@@ -201,6 +212,7 @@ Wrap U/V
 Filter Min/Mag
 : 缩放过滤. 就近过滤比线性插值过滤省资源, 但是可能产生不良效果. 一般线性插值过滤结果比较平滑:
 
+  - `Default` 使用 `game.project` 文件里 `Graphics`  下的 `Default Texture Min Filter` 和 `Default Texture Mag Filter` 作为默认过滤选项.
   - `FILTER_MODE_NEAREST` 使用位于像素中心最近的图素.
   - `FILTER_MODE_LINEAR` 使用位于像素中心最近的的2x2图素矩阵的加权线性平均值.
   - `FILTER_MODE_NEAREST_MIPMAP_NEAREST` 使用位于单个mipmap上最近的图素值.

+ 61 - 1
docs/zh/manuals/render.md

@@ -160,7 +160,7 @@ function init(self)
   -- 定义渲染优先级. 每个优先级的绘制不相干所以绘制时可以任意修改 OpenGL 的状态.
     self.predicates = create_predicates("tile", "gui", "text", "particle", "model")
 
-    -- Create and fill data tables will be used in update()
+    -- 创建和填充数据表将在 update() 中使用
     local state = create_state()
     self.state = state
     local camera_world = create_camera(state, "camera_world", true)
@@ -267,6 +267,66 @@ GUI 脚本同样可以向 `@render` 端口发送消息:
 msg.post("@render:", "clear_color", { color = vmath.vector4(0.3, 0.4, 0.5, 0) })
 ```
 
+## 渲染资源
+要将某些引擎资源传入渲染脚本, 你可以把它们添加进项目 .render 文件里的 `Render Resoures` 表里:
+
+![Render resources](images/render/render_resources.png)
+
+在渲染脚本里使用这些资源:
+
+```lua
+-- "my_material" 现在将用于优先级关联的所有绘制调用
+render.enable_material("my_material")
+-- 谓词绘制的任何内容都将以 "my_render_target" 结尾
+render.set_render_target("my_render_target")
+render.draw(self.my_full_screen_predicate)
+render.set_render_target(render.RENDER_TARGET_DEFAULT)
+render.disable_material()
+
+-- 将渲染目标结果纹理绑定到通过优先级渲染的任何内容
+render.enable_texture(0, "my_render_target", render.BUFFER_COLOR0_BIT)
+render.draw(self.my_tile_predicate)
+```
+
+::: sidenote
+Defold 目前仅支持 `Materials` 和 `Render Targets` 作为引用的渲染资源, 但后续会加入支持更多资源类型.
+:::
+
+## 纹理句柄
+
+Defold 中的纹理在内部表示为一个句柄, 这实质上等同于一个数字, 该数字应该唯一地标识引擎中任何位置的纹理对象. 这意味着你可以通过在渲染系统和游戏对象脚本之间传递这些句柄来桥接游戏对象世界和渲染世界. 比如, 脚本可以在附加到游戏对象的脚本中动态创建纹理, 并将其发送到渲染器, 以用作绘制命令中的全局纹理.
+
+在 `.script` 文件中:
+
+```lua
+local my_texture_resource = resource.create_texture("/my_texture.texture", tparams)
+-- 注意: my_texture_resource 是资源路径的哈希值, 不能用作句柄!
+local my_texture_handle = resource.get_texture_info(my_texture_resource)
+-- my_texture_handle 包含纹理的信息, 比如宽度, 高度等等
+-- 它还包含句柄, 这就是我们所需要的
+msg.post("@render:", "set_texture", { handle = my_texture_handle.handle })
+```
+
+In a .render_script file:
+
+```lua
+function on_message(self, message_id, message)
+    if message_id == hash("set_texture") then
+        self.my_texture = message.handle
+    end
+end
+
+function update(self)
+    -- 将自定义纹理绑定到绘制状态
+    render.enable_texture(0, self.my_texture)
+    -- 进行绘制..
+end
+```
+
+::: sidenote
+目前无法更改资源应指向的纹理, 你只能在渲染脚本中使用这样的原始句柄.
+:::
+
 ## 受支持的图像 API
 Defold 渲染脚本 API 把渲染操作转换为如下图像 API: