Sampling the terrain type below a billboard

Discuss modding questions and implementation details.
Post Reply
User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Sampling the terrain type below a billboard

Post by Daniel87 »

Hi fellow modders!

I am currently working on my "Vegetation Redistribution" Mod that aims at redistributing the nature billboard flats in Daggerfalls Wilderness to create a somewhat more believable random environment.

BEFORE
Image
AFTER
Image

So far everything goes pretty well but yesterday when testing the mod together with BasicRoads, I realized that vegetation ends up in the middle of the road due to my mod randomizing the tree distribution. In the original code, the billboards were placed exactly on x and y values, therefore giving off the feeling of an artificial grid of vegetation.

With BasicRoads
Image

Currently it seems my mod is not compatible with Trees of Daggerfall and it plants trees on BasicRoads. I already tried to change the load order of BasicRoads and my mod, but it didn't solve the problem. Is there a resources saving way to sample the texture below an asset? Then I could tell my billboards to not instantiate if they would be placed on a road texture.

I found this bit of code dealing with the ground, but am not sure why there is "& 0x3F":

Code: Select all

// Chance also determined by tile type
int tile = dfTerrain.MapData.tilemapSamples[x, y] & 0x3F;
And as I understand it, x and y have to be int, while my billboards are placed on float values between x and y to avoid the grid-like look.

Any help is as always much appreciated!
Last edited by Daniel87 on Fri Jan 22, 2021 10:51 am, edited 1 time in total.
In Julianos we Trust.

User avatar
pango
Posts: 3359
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Sampling the terrain type below a billboard

Post by pango »

Daniel87 wrote: Fri Jan 22, 2021 10:23 am I found this bit of code dealing with the ground, but am not sure why there is "& 0x3F":

Code: Select all

// Chance also determined by tile type
int tile = dfTerrain.MapData.tilemapSamples[x, y] & 0x3F;
This takes the 6 lesser bits of tilemapSamples data, so I guess this is to extract the texture index
https://en.uesp.net/wiki/Daggerfall_Mod ... extureList
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Sampling the terrain type below a billboard

Post by Ralzar »

I honestly like it the way it looks in your picture.

The biggest problem I have with Basic Roads is that the roads look extremely industrial. Having vegetation infringe on the edges randomly is a big improvement as long as it doesn't place a bunch of trees in the middle of the road, but even then I might prefer it.

User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Re: Sampling the terrain type below a billboard

Post by Daniel87 »

Ah that makes sense! Thank you!
Do you know which texture index is the one used for the roads in BasicRoads?

@Ralzar: Yes, I think a more meandering layout of the roads would be nice. Do you know if the BasicRoads Mod is open source? Then I would have a look into the algorithms creating the roads and mess around with it to see if I can give it a more diverse pattern.
In Julianos we Trust.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Sampling the terrain type below a billboard

Post by Ralzar »

Basic Roads is Hazelnuts and he makes everything available as he makes mods as much to show the way as for the mods themselves :)

https://github.com/ajrb/dfunity-mods

User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Re: Sampling the terrain type below a billboard

Post by Daniel87 »

Thanks Ralzar! Will definitely check it out once I finished basic setup of all biomes in my mode :)
In Julianos we Trust.

User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Re: Sampling the terrain type below a billboard

Post by Daniel87 »

I think I've overdone it. Looks like a huge highway cutting through the nature now :D
Image

Should I change it back?
Because now, nature flats on dirt and grass are keeping distance to the perimeter which causes a patchy, awkward look somehow.
Not sure why my algorithm doesn't work. Spaghetti code I guess ¯\_(ツ)_/¯
In Julianos we Trust.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Sampling the terrain type below a billboard

Post by Ralzar »

I'd much prefer if it infringed a bit on the road. Heck, I'd even take full coverage of the road in spots if the alternative is the industrial look.

User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Re: Sampling the terrain type below a billboard

Post by Daniel87 »

Perfect, then I can remove that spaghetti code which I used to get it work. It only created more trouble than use anyway haha.
I share your opinion about the coverage, but sometimes it bothers me when a single tree is standing right in the middle of a road.
But there are worse things, like flying or hovering billboards. I cannot make out a mistake in my code, so it might happen due to the way the terrain is generated.
In Julianos we Trust.

User avatar
Hazelnut
Posts: 3016
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Sampling the terrain type below a billboard

Post by Hazelnut »

I found this bit of code dealing with the ground, but am not sure why there is "& 0x3F":
It masks the rotation & mirror bits just leaving the texture record index.

Happy to answer other queries about how to work with my roads mods, but I've not read this whole thread so re-ask if anything is outstanding.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Post Reply