Skip to content

Commit

Permalink
fix: fixed crash on meshes with kVertexLighting flag enabled. (doodlu…
Browse files Browse the repository at this point in the history
…m#496)

* fix: fixed crash on meshes with kVertexLighting flag enabled.

* style: 🎨 apply clang-format changes

---------

Co-authored-by: Ilya Perapechka <[email protected]>
Co-authored-by: Jonahex <[email protected]>
  • Loading branch information
3 people authored Sep 1, 2024
1 parent 48b106f commit a916228
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/TruePBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,16 @@ struct BSLightingShaderProperty_LoadBinary
pbrMaterial->glintParameters.enabled = true;
}
}

// It was a bad idea originally to use kMenuScreen flag to enable PBR since it's actually used for world map
// meshes. But it was too late to move to use different flag so internally we use kVertexLighting instead
// as it's not used for Lighting shader.
property->flags.set(kVertexLighting);

property->flags.reset(kMenuScreen, kSpecular, kGlowMap, kEnvMap, kMultiLayerParallax, kSoftLighting, kRimLighting, kBackLighting, kAnisotropicLighting, kEffectLighting, kFitSlope);
} else {
// There are some modded non-PBR meshes with kVertexLighting enabled.
property->flags.reset(kVertexLighting);
}
}
static inline REL::Relocation<decltype(thunk)> func;
Expand Down Expand Up @@ -1361,6 +1369,8 @@ struct BSGrassShaderProperty_ctor
BSLightingShaderMaterialPBR srcMaterial;
grassProperty->LinkMaterial(&srcMaterial, true);

// Since grass actually uses kVertexLighting flag we need to switch to some flag which it does not
// use, specifically kMenuScreen.
grassProperty->SetFlags(RE::BSShaderProperty::EShaderPropertyFlag8::kMenuScreen, true);

auto pbrMaterial = static_cast<BSLightingShaderMaterialPBR*>(grassProperty->material);
Expand Down

0 comments on commit a916228

Please sign in to comment.