]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fix scale issue with offsetmapping LOD due to calculated fractional steps count
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 15 Jan 2012 14:14:19 +0000 (14:14 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Mon, 16 Jan 2012 09:27:14 +0000 (10:27 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11646 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=6dec6a79c594d96f510004b3798153d4373e6486

shader_glsl.h
shader_hlsl.h

index f968e3eb852a5f4fc4dcf3718f7c012b190c0765..bb489c8f92ba1d234f9fd6fdaf5902c7b236b39a 100644 (file)
 "      float i;\n"
 "      // distance-based LOD\n"
 "#ifdef USEOFFSETMAPPING_LOD\n"
-"      mediump float LODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
-"      mediump vec4 ScaleSteps = vec4(OffsetMapping_ScaleSteps.x, OffsetMapping_ScaleSteps.y * LODFactor, OffsetMapping_ScaleSteps.z / LODFactor, OffsetMapping_ScaleSteps.w * LODFactor);\n"
+"      //mediump float LODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
+"      //mediump vec4 ScaleSteps = vec4(OffsetMapping_ScaleSteps.x, OffsetMapping_ScaleSteps.y * LODFactor, OffsetMapping_ScaleSteps.z / LODFactor, OffsetMapping_ScaleSteps.w * LODFactor);\n"
+"      mediump float GuessLODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
+"      mediump float LODSteps = ceil(GuessLODFactor * OffsetMapping_ScaleSteps.y);\n"
+"      mediump float LODFactor = LODSteps / OffsetMapping_ScaleSteps.y;\n"
+"      mediump vec4 ScaleSteps = vec4(OffsetMapping_ScaleSteps.x, LODSteps, 1.0 / LODSteps, OffsetMapping_ScaleSteps.w * LODFactor);\n"
 "#else\n"
 "      #define ScaleSteps OffsetMapping_ScaleSteps\n"
 "#endif\n"
index d09307cfcf57e671e6f6a2c61fecd2cb607533f1..b8d851fea84e9a1805d335388e08373260aa6659 100644 (file)
 "      float i;\n"
 "      // distance-based LOD\n"
 "#ifdef USEOFFSETMAPPING_LOD\n"
-"      float LODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
-"      mediump vec4 ScaleSteps = float4(OffsetMapping_ScaleSteps.x, OffsetMapping_ScaleSteps.y * LODFactor, OffsetMapping_ScaleSteps.z / LODFactor, OffsetMapping_ScaleSteps.w * LODFactor);\n"
+"      //float LODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
+"      //float4 ScaleSteps = float4(OffsetMapping_ScaleSteps.x, OffsetMapping_ScaleSteps.y * LODFactor, OffsetMapping_ScaleSteps.z / LODFactor, OffsetMapping_ScaleSteps.w * LODFactor);\n"
+"      float GuessLODFactor = min(1.0, OffsetMapping_LodDistance / EyeVectorFogDepth.z);\n"
+"      float LODSteps = ceil(GuessLODFactor * OffsetMapping_ScaleSteps.y);\n"
+"      float LODFactor = LODSteps / OffsetMapping_ScaleSteps.y;\n"
+"      float4 ScaleSteps = float4(OffsetMapping_ScaleSteps.x, LODSteps, 1.0 / LODSteps, OffsetMapping_ScaleSteps.w * LODFactor);\n"
 "#else\n"
 "      #define ScaleSteps OffsetMapping_ScaleSteps\n"
 "#endif\n"