fix: consistent EXTENDED_DRAW distances + LOD fade design (playtest round 4)
linux / build (push) Successful in 11m26s
linux / build (push) Successful in 11m26s
This commit is contained in:
+6
-3
@@ -728,9 +728,12 @@ CCamera::Process(void)
|
||||
#if GTA_VERSION > GTA3_PS2_160
|
||||
GenerationDistMultiplier = LODDistMultiplier;
|
||||
#ifdef EXTENDED_DRAW
|
||||
// Consumed by VEHICLE_LODDIST_MULTIPLIER in VisibilityPlugins.cpp, which
|
||||
// divides this scale back out so vehicle LOD stays vanilla. Keep the two in
|
||||
// sync and don't move this past the ms_lodDistScale multiply below.
|
||||
// Widens the ped/vehicle creation and removal radius (consumed by CCarCtrl
|
||||
// and CPopulation) and, through GenerationDistMultiplier, the vehicle LOD
|
||||
// bands in CVisibilityPlugins::SetRenderWareCamera, so vehicle LOD keeps
|
||||
// vanilla's spawn:LOD proportion. Don't move this past the ms_lodDistScale
|
||||
// multiply below: vehicle LOD and creation deliberately ignore the
|
||||
// draw-distance slider, as they do in vanilla.
|
||||
GenerationDistMultiplier *= EXTENDED_DRAW_GENERATION_SCALE;
|
||||
#endif
|
||||
LODDistMultiplier *= CRenderer::ms_lodDistScale;
|
||||
|
||||
+12
-9
@@ -499,14 +499,17 @@ enum Config {
|
||||
// Extended draw distance (issue #30): peds and vehicles are created and removed
|
||||
// farther from the player, reducing pop-in. Custom tuning, so off by default.
|
||||
// The generation scale feeds the ped/vehicle creation and removal radii, the
|
||||
// car-generator activation band and car path acceptance. Vehicle LOD cull
|
||||
// distances (CVisibilityPlugins ms_vehicleLod0/1Dist, ms_bigVehicleLod0Dist,
|
||||
// wheel-atomic LOD ratio) are deliberately NOT scaled: they divide the
|
||||
// generation scale back out so they match vanilla exactly, otherwise low-detail
|
||||
// car bodies stay visible well past vanilla's switch and cull distance. That
|
||||
// also avoids the fade risk the old VEHICLE_LODDIST_MULTIPLIER comment warns
|
||||
// about, because the whole LOD band is left untouched; only the spawn radius is
|
||||
// scaled.
|
||||
// vehicle LOD bands, the car-generator activation band and car path acceptance.
|
||||
// Vehicle LOD keeps vanilla's spawn:LOD proportion: GenerationDistMultiplier is
|
||||
// what CVisibilityPlugins scales the bands with, so the hi->vlo body switch
|
||||
// (ms_vehicleLod0Dist) and the big-vehicle bands move out by the same factor as
|
||||
// the spawn radius. The "_hi" -> "_vlo" switch has no crossfade yet, so the fade
|
||||
// path in RenderAlphaAtomic had to be fixed as well: the vanilla fade wrote a
|
||||
// constant material alpha over the model's own and restored 255, which loses
|
||||
// alpha on materials shared by every instance of a model (see ScaleAlphaCB).
|
||||
// The draw-distance slider still moves neither vehicle LOD nor vehicle creation:
|
||||
// GenerationDistMultiplier is taken before the slider is applied (CCamera::Process),
|
||||
// so the slider only drives building/ped LOD and the global LOD distance.
|
||||
// The 1.5 slider default and 1.25 generation scale are a matched pair: their
|
||||
// ratio reproduces vanilla's generation/LOD proportion only at these values, so
|
||||
// tune together. Existing saved settings keep their stored DrawDistance; the new
|
||||
@@ -514,7 +517,7 @@ enum Config {
|
||||
//#define EXTENDED_DRAW // master switch for the items below
|
||||
#ifdef EXTENDED_DRAW
|
||||
# define DEFAULT_DRAW_DISTANCE_SCALE 1.5f // draw-distance slider default (vanilla 1.2, slider range 0.8-1.8)
|
||||
# define EXTENDED_DRAW_GENERATION_SCALE 1.25f // ped/vehicle creation and removal radius scale (vanilla 1.0)
|
||||
# define EXTENDED_DRAW_GENERATION_SCALE 1.25f // ped/vehicle creation, removal and vehicle LOD radius scale (vanilla 1.0); CCamera::Process applies it to GenerationDistMultiplier
|
||||
#else
|
||||
# define DEFAULT_DRAW_DISTANCE_SCALE 1.2f
|
||||
#endif
|
||||
|
||||
@@ -227,19 +227,18 @@ CVisibilityPlugins::InsertAtomicIntoSortedList(RpAtomic *a, float dist)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// can't increase this yet unfortunately...
|
||||
// probably have to fix fading for this so material alpha isn't overwritten
|
||||
#ifdef EXTENDED_DRAW
|
||||
// EXTENDED_DRAW inflates GenerationDistMultiplier to widen the ped/vehicle
|
||||
// creation and removal radius. Vehicle LOD is decoupled from that: dividing the
|
||||
// scale back out restores the five body/cull bands exactly, so low-detail car
|
||||
// bodies don't stay visible well past vanilla's switch/cull distance. The
|
||||
// wheel-atomic LOD ratio below still follows the draw-distance slider (vanilla
|
||||
// formula), so distant wheel detail moves with the slider by design.
|
||||
#define VEHICLE_LODDIST_MULTIPLIER (TheCamera.GenerationDistMultiplier / EXTENDED_DRAW_GENERATION_SCALE)
|
||||
#else
|
||||
// Vanilla scales the vehicle bands with GenerationDistMultiplier, which is the
|
||||
// LOD distance before the draw-distance slider is applied (see CCamera::Process),
|
||||
// so the slider moves building and ped LOD but not vehicles.
|
||||
// ms_vehicleLod0Dist is the live hi->vlo body switch: CVehicleModelInfo tags the
|
||||
// "_hi" atomics with RenderVehicleHiDetail*CB (drawn below this distance) and the
|
||||
// single "_vlo" atomic with RenderVehicleReallyLowDetailCB (drawn above it).
|
||||
// ms_vehicleLod1Dist is only read by VehicleVisibilityCB, and nothing in this
|
||||
// renderer calls IsClumpVisible, so that cull is inert today; it is left in the
|
||||
// vanilla proportion so it stays correct if the cull is ever wired up.
|
||||
// There is no crossfade between the two bodies (see RenderAlphaAtomic), which is
|
||||
// why the switch distance can't simply be pushed out to the spawn radius.
|
||||
#define VEHICLE_LODDIST_MULTIPLIER (TheCamera.GenerationDistMultiplier)
|
||||
#endif
|
||||
|
||||
void
|
||||
CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera)
|
||||
@@ -277,6 +276,53 @@ SetTextureCB(RpMaterial *material, void *data)
|
||||
return material;
|
||||
}
|
||||
|
||||
#ifdef EXTENDED_DRAW
|
||||
// Cars are created with clump alpha 0 and blend up to 255, and are blended down
|
||||
// to 0 again when they are removed, so RenderVehicleReallyLowDetailCB calls this
|
||||
// for the "_vlo" body whenever a car is spawning or despawning. SetAlphaCB writes
|
||||
// a constant alpha and the restore below used to write 255, which loses the alpha
|
||||
// a material had of its own (car and ped materials are shared by every instance of
|
||||
// a model, so the loss is permanent) and replaces instead of scales, so a
|
||||
// translucent material stops being translucent while it fades. Remember the
|
||||
// original alpha for the duration of one render and restore it, scaling it rather
|
||||
// than overwriting it.
|
||||
struct AlphaOverride
|
||||
{
|
||||
RpMaterial *material;
|
||||
uint8 alpha;
|
||||
};
|
||||
|
||||
// Vehicle and ped geometries have far fewer materials than this.
|
||||
#define MAX_ALPHA_OVERRIDES 64
|
||||
static AlphaOverride ms_alphaOverrides[MAX_ALPHA_OVERRIDES];
|
||||
static int32 ms_numAlphaOverrides;
|
||||
static int32 ms_alphaOverrideIndex;
|
||||
static uint8 ms_alphaScale;
|
||||
|
||||
static RpMaterial*
|
||||
ScaleAlphaCB(RpMaterial *material, void *data)
|
||||
{
|
||||
RwRGBA *color = (RwRGBA*)RpMaterialGetColor(material);
|
||||
if(ms_numAlphaOverrides < MAX_ALPHA_OVERRIDES){
|
||||
ms_alphaOverrides[ms_numAlphaOverrides].material = material;
|
||||
ms_alphaOverrides[ms_numAlphaOverrides].alpha = color->alpha;
|
||||
ms_numAlphaOverrides++;
|
||||
color->alpha = (uint8)(color->alpha * ms_alphaScale / 255);
|
||||
}
|
||||
return material;
|
||||
}
|
||||
|
||||
static RpMaterial*
|
||||
RestoreAlphaCB(RpMaterial *material, void *data)
|
||||
{
|
||||
if(ms_alphaOverrideIndex < ms_numAlphaOverrides &&
|
||||
ms_alphaOverrides[ms_alphaOverrideIndex].material == material)
|
||||
((RwRGBA*)RpMaterialGetColor(material))->alpha = ms_alphaOverrides[ms_alphaOverrideIndex].alpha;
|
||||
ms_alphaOverrideIndex++;
|
||||
return material;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
CVisibilityPlugins::RenderAlphaAtomics(void)
|
||||
{
|
||||
@@ -394,9 +440,18 @@ CVisibilityPlugins::RenderAlphaAtomic(RpAtomic *atomic, int alpha)
|
||||
geo = RpAtomicGetGeometry(atomic);
|
||||
flags = RpGeometryGetFlags(geo);
|
||||
RpGeometrySetFlags(geo, flags | rpGEOMETRYMODULATEMATERIALCOLOR);
|
||||
#ifdef EXTENDED_DRAW
|
||||
ms_alphaScale = (uint8)alpha;
|
||||
ms_numAlphaOverrides = 0;
|
||||
RpGeometryForAllMaterials(geo, ScaleAlphaCB, nil);
|
||||
RENDERCALLBACK(atomic);
|
||||
ms_alphaOverrideIndex = 0;
|
||||
RpGeometryForAllMaterials(geo, RestoreAlphaCB, nil);
|
||||
#else
|
||||
RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)alpha);
|
||||
RENDERCALLBACK(atomic);
|
||||
RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)255);
|
||||
#endif
|
||||
RpGeometrySetFlags(geo, flags);
|
||||
return atomic;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user