From afdde25cee431f07b6d490ed3d399fb5c9ba8a81 Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 15 Jan 2012 14:14:19 +0000 Subject: [PATCH] fix scale issue with offsetmapping LOD due to calculated fractional steps count git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11646 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=6dec6a79c594d96f510004b3798153d4373e6486 --- shader_glsl.h | 8 ++++++-- shader_hlsl.h | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/shader_glsl.h b/shader_glsl.h index f968e3eb..bb489c8f 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -726,8 +726,12 @@ " 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" diff --git a/shader_hlsl.h b/shader_hlsl.h index d09307cf..b8d851fe 100644 --- a/shader_hlsl.h +++ b/shader_hlsl.h @@ -594,8 +594,12 @@ " 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" -- 2.39.2