PrismaticFlower / shaderpatch

Improved shaders (and fun stuff for modders) for Star Wars Battlefront II (2005) - Incompatible with Classic Collection
MIT License
39 stars 2 forks source link

Terrain appears to hate SP materials #38

Closed DoctorAnsem closed 5 years ago

DoctorAnsem commented 5 years ago

I think at this point we can establish that whenever you wish to look for trouble, any terrain file in BF2 is where you'll find plenty. Terrains have been giving me all sorts of issues since day 1 of my entire modding career, so I can't say I didn't see this coming but it doesn't hurt to spread awareness, I guess. Observe.

https://i.imgur.com/Ei4x3kk.mp4

Note that any textures that flicker in and out aren't even the ones supposed to be there, about the only "correct" texture that's there is the grayscale detail map and that's probably because it's a stock texture.

This is with PBR materials. I didn't test normal_ext but something tells me the terrain will throw a tantrum from that as well, just because it can. Of course, one could always just use stock materials for terrains but there are three issues for anyone who'd like to be more thorough with the artwork. 1) Stock terrain allows no specular. 2) The entire terrain can only have one normal map specified. 3) Said normal map can't even be scaled to match a specific tile range (I think?), resulting in the kind of mess that is present in the stock Naboo map among others.

This isn't a big problem for urban maps where it's feasible to replace terrain with grid-shaped objects, but for a natural terrain I imagine it won't be that simple. I don't blame you if you decide this isn't worth the hassle though. I know for a fact that trying to work with any BF2 terrain thing is a combination of annoying, irritating, cumbersome, infuriating and exasperating, haha. xd

PrismaticFlower commented 5 years ago

Yeah terrain is a pain. It's drawn with multiple textures and in multiple rendering passes making it play very poorly with SP's custom materials. But I agree terrain is also a prime place for custom materials for all the reasons (and more) you say.

I think the best way to solve this would be special rendertypes specifically for terrain and a tool (possibly integrated into the hypothetical but definitely planned lighting baker) to convert the terrain into a bunch of regular (but special) model segments that could be used with custom materials.

The (still upcoming) Direct3D 11 support enables easier and better implementation of things here. Rough list of the features I'd be going for is below.

It may be easier to limit the max textures all the terrain can have to eight. (Instead of the sixteen ZE exposes.) Anyone that this would be a problem for should let me know.

3) Said normal map can't even be scaled to match a specific tile range (I think?)

It can, Naboo just doesn't for whatever reason.

DoctorAnsem commented 5 years ago

It can, Naboo just doesn't for whatever reason.

Curious... How does one make it happen then? The only seemingly relevant number I found is the one directly after the texture name in the sky file, but changing that number from 1.0 to 16.0 has no effect. Am I missing something?

PrismaticFlower commented 5 years ago

I'm pretty sure you do just edit that number. I could be remembering incorrectly though or maybe it only works for SWBF1.

DoctorAnsem commented 5 years ago

Oh, yeah it's probably the latter. I've tried it on several maps in BF2 but it's just getting ignored. This actually made me even more curious, did BF1 have a better terrain shader than BF2 in general? It doesn't seem to have those color mismatch issues with high quality lighting either, from what little I've tested. (the ones I talked about in #33)

PrismaticFlower commented 5 years ago

I'm working on introducing support for terrain to material_munge for v1.1. Current working syntax of the config file that'll be required to enable it is this.

Global:
   # Use an environment map as a probe for ambient sky light.
   UseEnvironmentMapping: no
   EnvironmentMap: envmap

   # Use height maps to smartly blend between textures.
   UseHeightBasedBlending: yes

   # Use Parallax Occlusion Mapping.
   # Global detail map like stock terrain has.
   UseDetailMap: no
   DetailMap: yav1_detail_map

Materials:
   yav1_main_0:
      AlbedoMap: yav1_main_0
      NormalMap: yav1_main_0_normalmap
      MetallicRoughnessMap: yav1_main_0_roughness
      AOMap: yav1_main_0_aomap
      HeightMap: yav1_main_0_normalmap

      UseParallaxOcclusionMapping: yes  

   yav1_main_1:
      AlbedoMap: yav1_main_1
      NormalMap: yav1_main_1_normalmap
      MetallicRoughnessMap: yav1_main_1_roughness
      AOMap: yav1_main_1_aomap
      HeightMap: yav1_main_1_normalmap

      UseParallaxOcclusionMapping: no 

   yav1_main_3:

   # etc, you get the idea

I'm probably (initially at least) only going to support PBR materials for terrain because they'll provide the most flexibility and it cuts down on the workload.