YAML 101

    But of course it would be cumbersome and error-prone, so what YAML provides is a much simpler representation of the same data:

    • All quotation marks and commas can be omitted

      1. key2: unquoted string
    • Like Python, indentation is part of the syntax, representing hierarchy of the data1

      1. object1:
      2. key1: false
      3. object2:
      4. key2: 3.14
      5. key3: 0xdeadbeef
      6. nestedObject:
      7. key4: 'quoted string'

    With these in mind, the effect manifest at the beginning of this document can be re-write as follows:

    1. techniques:
    2. - passes:
    3. - vert: skybox-vs
    4. cullMode: none
    5. # ...

    Another YAML feature that comes in handy is referencing and inheriting between data.

    • Reference

      1. object1: &o1
      2. key1: value1
      3. object2:
      4. key2: value2
      5. key3: *o1

      This is its corresponding JSON:

      1. object1: &o1
      2. key1: value1
      3. key2: value2
      4. object2:
      5. <<: *o1

      The corresponding JSON:

      1. "object1": {
      2. "key1": "value1",
      3. "key2": "value2"
      4. },
      5. "object2": {
      6. "key1": "value1",
      7. "key2": "value2",
      8. "key3": "value3"
      9. }
      10. }

    For our purposes, like when multiple pass has the same properties, etc. it could be really helpful:

    Finally, before writing any YAML, wrap it in a CCEffect block first:

    1. CCEffect %{
    2. }%

    You can always refer to any to play around ideas.

    1. The YAML standard doesn’t support tabs, so the effect compiler will try to replace all the tabs in file with 2 spaces first, to avoid the trivial yet annoying trouble of accidentally inserting tabs somewhere. But overall, please try to avoid doing that completely to make sure the compilation goes smoothly.