From 2f47cbbb177a950daeb3701e76890a814ab721d1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 16 Jan 2009 02:56:51 +0000 Subject: [PATCH] further depth-bias fixes --- panda/src/dxgsg9/config_dxgsg9.cxx | 7 +++++++ panda/src/dxgsg9/config_dxgsg9.h | 1 + panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index 3193da984e..9b09965271 100755 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -80,6 +80,13 @@ ConfigVariableBool dx_broken_depth_bias "to just leave this set, since the workaround seems to be " "sufficient for all cases.")); +ConfigVariableDouble dx_depth_bias_scale +("dx-depth-bias-scale", 0.000001, + PRC_DESC("If depth bias is not directly supported by the graphics driver " + "(or if dx-broken-depth-bias is set true), this configures the " + "amount by which we slide the viewport back to achieve the effect " + "of a depth bias. It should generally be a small number.")); + #ifndef NDEBUG // debugging flag // values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW diff --git a/panda/src/dxgsg9/config_dxgsg9.h b/panda/src/dxgsg9/config_dxgsg9.h index 2145a0d490..0e4493a6dd 100755 --- a/panda/src/dxgsg9/config_dxgsg9.h +++ b/panda/src/dxgsg9/config_dxgsg9.h @@ -34,6 +34,7 @@ extern ConfigVariableInt dx_multisample_antialiasing_level; extern ConfigVariableBool dx_use_triangle_mipgen_filter; extern ConfigVariableBool dx_broken_max_index; extern ConfigVariableBool dx_broken_depth_bias; +extern ConfigVariableDouble dx_depth_bias_scale; // debug flags we might want to use in full optimized build extern ConfigVariableBool dx_ignore_mipmaps; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 088b7cc4a8..e07fb497dc 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -3143,7 +3143,7 @@ do_issue_depth_offset() { // DirectX depth bias isn't directly supported by the driver. // Cheese a depth bias effect by sliding the viewport backward a // bit. - static const float bias_scale = 0.0001; + static const float bias_scale = dx_depth_bias_scale; D3DVIEWPORT9 vp = _current_viewport; vp.MinZ -= bias_scale * offset; vp.MaxZ -= bias_scale * offset;