Menu

#2156 Effect parameter settings governing random vegetation generation are not passed through to the shader from a material definition.

None
New
Low
2020-04-09
2019-11-25
No

To reproduce, set <use_forest_effect> to false in a material definition, and note that the forest effect will still be used when "generate random vegetation" is selected. This can be confirmed by switching the forest render setting to the left, which shows what a switched off forest effect should actually look like. I expect that instead the use_forest_effect parameter should be honoured.</use_forest_effect>

It looks like this is because the createForest routine in scene/tgdb/TreeBin.cxx does not copy parameters from the forests' associated material definition. Instead it creates and attaches an effect to the forest based on the name of the effect only.

Happy to attempt fixing this myself if it is agreed that this is a reasonable thing to fix.

Discussion

  • Stuart Buchanan

    Stuart Buchanan - 2020-01-06
    • assigned_to: Stuart Buchanan
     
  • Stuart Buchanan

    Stuart Buchanan - 2020-01-06

    Hi James,

    I wasn't aware of <use_forest_effect> in materials.xml, and it's not documented in README.materials, nor in simgear/scene/material/mat.cxx</use_forest_effect>

    Could you explain what it's used for?

    Thanks,

    -Stuart

     
  • James Hester

    James Hester - 2020-01-07

    Hi Stuart, thanks for looking at this.

    <use_forest_effect> creates height variation within the trees in a forest. Its default value is set in fgdata/Effects/tree.eff and then fgdata/Shaders/tree-ALS.vert uses its value and a couple of other parameters to create height variations using Voronoi noise. </use_forest_effect>

    So my expectation is that in general any of the parameters defined for an effect are available to regional material definitions to fiddle with. If I squint I think I believe that the simgear code attempts in general to copy across parameters from material definitions and merge with the defaults provided by the effect. This is not happening with this effect, I think because tree generation code is a bit of a special code path.

    The way I test this is to set the <plantation> parameter to "true" for a forest material and tree density fairly high (say wood-coverage = 1000). This makes the trees uniformly spaced and thus easier to see the effect in action. With <use_forest_effect> also true (the default), you can see that the tree heights distribute into areas of differing heights. If the "forest effect" rendering slider in the 'View->Rendering' menu is moved to the left, this height effect disappears. I think the proper behaviour is for <use_forest_effect> to similarly switch off the effect if false.</use_forest_effect></use_forest_effect></plantation>

     
  • Stuart Buchanan

    Stuart Buchanan - 2020-04-09

    Hi James,

    Apologies for the delay in responding.

    I think the problem is exactly as you describe. The Trees code to some extent predates the Effects system and so has hardcoded mapping from the materials.xml file.

    TBH, I'm not sure it's worth the hassle to make it inherit properly. Instead I'd suggest that we just add the user_forest_effect mapping from materials.xml manually.

    If you are happy to do that, I'll review the code. Otherwise let me know and I'll do it myself.

    -Stuart

     
  • James Hester

    James Hester - 2020-04-09

    Hi Stuart, I'm not sure I quite know how to do the hardcoded mapping so I think I'll let you do that. However, I would anticipate in the future adding parameters to the forest effect, e.g. to switch on agricultural-effect type variation in tree row direction, and/or following the hill gradients. Given this, is the "right" thing to do to properly inherit or could a couple more parameters also be hard-coded? If the latter I will copy your way of hard-coding this time when I get around to adding the parameters.

     

Log in to post a comment.

MongoDB Logo MongoDB