利用者・トーク:Moguri/GSoC2010 BGE Shaders

提供: wiki
< 利用者・トーク:Moguri
2018年6月29日 (金) 04:45時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Material or Object?

As far as I know, practically all other game engines and scenegraphs associate shaders with materials. The reason probably is that the material includes additional properties (values of uniform variables for the shader, OpenGL state settings, etc.) that should also be shared by objects that have the same shader. Furthermore, materials offer one additional level of indirection; thus, if shaders are associated with materials, you can also associate a particular shader with a particular object just by creating an object-specific material. However, this wouldn't be possible if shaders would alway be associated with objects (i.e. you couldn't associate them with materials). Thus, associating shaders with materials appears to be the more flexible solution. --Martin Kraus 10:50, 10 August 2011 (CEST)

OpenGL state settings (per pass)

Please make sure that the shader can also specify OpenGL state settings (for each pass), such as the blend equation, front-face or back-face culling, depth test, polygon offset, color mask, etc. Many shaders rely on certain settings in particular because some parts of the OpenGL pipeline are not programmable and have to be customized with those state settings. For examples see:

state settings of passes in Unity shaders: http://unity3d.com/support/documentation/Components/SL-Pass.html

state settings of passes in OGRE material scripts: http://www.ogre3d.org/docs/manual/manual_16.html#SEC39

state settings for passes in FX Composer: see the description of passes on page 61 (70th page of PDF) and the example at the bottom of page 139 (148th page of the PDF) in: http://developer.download.nvidia.com/assets/gamedev/docs/FX_Composer_User_Guide.pdf

state settings for passes in Collada FX: see the description of the <states> tag on page 8-120 (372th page of the PDF) in: http://www.khronos.org/files/collada_spec_1_5.pdf

--Martin Kraus 10:49, 10 August 2011 (CEST)

Even if multipass shaders are out of the question for Blender 2.6, it would be nice to include a small dialogue for each GLSL program to specify the most common OpenGL states (I'm looking at page 325 of the OpenGL ES 2.0 Programming Guide: viewport, depth range, line width, face culling, polygon offset, multisample coverage (maybe not necessary), color and depth write mask, scissor box, stencil related stuff, depth test, blending.) Later, these states could then be defined by a shader script of some sort. Note in particular, that currently there appears to be no way for users to set these states on a per-object/per-material basis (not even with Python scripting); thus, including such a dialogue would be a tremendous progress. --Martin Kraus 15:35, 12 August 2011 (CEST)

Multipass techniques

Many shaders require multiple passes over the geometry (usually with different OpenGL state settings; e.g. first pass with front-face culling, second pass with back-face culling); this is an absolutely essential feature for any shader system. Different names exist for the containers of several passes: "subshaders" in Unity, "techniques" in OGRE material scripts, Composer FX and Collada FX, and probably other names in other formats. --Martin Kraus 10:58, 10 August 2011 (CEST)

One problem with multipass is probably that it requires to substantially extend the rendering code. In particular because the second pass for any object should only start after the first passes of all objects have been rendered. (Otherwise you might get different results just by splitting one object/mesh into multiple parts.) On the other hand, the GUI might not be too difficult: it could be similar to the Properties > Texture tab, i.e. a editable list of passes at the top and then specific settings for the selected pass below. The advantage would be that there is no need to define and/or parse any additional shader file format. --Martin Kraus 13:05, 14 August 2011 (CEST)
Thinking about shader file formats: a button to export (and only export) a shader file in an open file format (e.g. OGRE material scripts or COLLADA FX files) would probably not require a lot of programming but it would be incredible useful in many ways, e.g. you could use Blender to design, prototype, implement, test, adapt, and fine-tune GLSL shaders, which you could then use with OGRE, OGREkit, or other game engines. --Martin Kraus 13:54, 15 August 2011 (CEST)