skyrim-community-shaders icon indicating copy to clipboard operation
skyrim-community-shaders copied to clipboard

feat: add Terrain Variation

Open davo0411 opened this issue 8 months ago • 7 comments

This is the final version of my plugin, Terrain Variation. It fixes the in game texture tiling visible on terrain via Stochastic Texturing. Works with vanilla, PBR, Complex Materials and Parallax. Untested with CS Terrain Helper. Untested in VR, no clue if that has a different pipeline for terrain or anything.

How it works:

  1. Transforms UV coordinates into a triangular grid space using a skew transformation matrix, creating a more natural-looking pattern than square grid sampling.
  2. Uses barycentric coordinates (the barry variable) to interpolate between three chosen points in this grid.
  3. Applies hash-based randomisation with the hash2D2D function to create pseudo-random but deterministic offsets for each sample point. Some blending is applied, and the offsets are applied to all texture layers the same, resulting in the texture being offset by the correct, same amount, for each layer.

BeforeVolcanic AfterVolcanic

BeforeTundra AfterTundra

Performance Performance 2

davo0411 avatar Apr 18 '25 10:04 davo0411

In addition to the line comments:

  1. Ensure there are no hlsl warnings or errors caused by your changes. You may have to turn on debug mode. To the extent some warnings are there from older code in the files you've touched, consider cleaning them up in a prereq PR.
  2. Test with the feature off both in config (if an option) and with disable with boot under advanced.
  3. You may post a test build after addressing both 1 and 2. All major errors should be handled before we merge to dev.
  1. No errors with my compile, I have tested 4 different states: AIO compiles fine AIO With plugin disabled at boot Individual plugins, with terrain variation disabled in MO2 Individual plugins, with terrain variation enabled in MO2. 1a. I'm not sure what you're saying, are you saying that previous warnings unrelated to my code need to be tidied before i can get my plugin accepted? I don't really get why. There are pre-existing warnings within lighting.hlsl, and i'm not gonna spend a day trying to troubleshoot those when they are unrelated to my changes.

  2. Compiles just fine

  3. I have a test build AIO posted in the discord, davo's Terrain Variation thread in the community channel.

davo0411 avatar Apr 19 '25 08:04 davo0411

  1. I said consider. If you don't want to help, that's fine. Just don't cause more problems.

alandtse avatar Apr 19 '25 17:04 alandtse

Please check the names of things. The feature is Terrain Variations but it shows up in the menu as something else.

alandtse avatar Apr 20 '25 20:04 alandtse

Please check the names of things. The feature is Terrain Variations but it shows up in the menu as something else.

Fixed this up, sorry was flipping between names but i think the tooltip is enough to explain what it does, and allows me to add more features or "Variation" ideas in future ( i was thinking something with texture-bombing, like puddles or other things onto terrain randomly)

davo0411 avatar Apr 21 '25 07:04 davo0411

Prior to merge I need to see a performance comparison, e.g. https://www.capframex.com/

doodlum avatar Apr 21 '25 23:04 doodlum

Also, please see if using the new functions from this commit are useful for you.

alandtse avatar May 01 '25 02:05 alandtse

Also, please see if using the new functions from this commit are useful for you.

That is very cool, I'll incorporate that in time. I have done a very large rewrite of the code on suggestion of exist and a couple others who were testing. The function now works on a distance-based slider, a video in action is visible in discord. Idk if its best to do a new PR or merge it into this (i created a separate branch as i didn't know if it was gonna work)

davo0411 avatar May 01 '25 02:05 davo0411