From 53f241974bf425f94e76dedbcd8d86a8d9b52658 Mon Sep 17 00:00:00 2001 From: Lukas Joergensen Date: Mon, 25 Aug 2014 21:02:28 +0200 Subject: [PATCH] Doing a hard compare instead of using step for blending factors --- Templates/Empty/game/shaders/common/terrain/terrain.hlsl | 7 +++++-- Templates/Full/game/shaders/common/terrain/terrain.hlsl | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Templates/Empty/game/shaders/common/terrain/terrain.hlsl b/Templates/Empty/game/shaders/common/terrain/terrain.hlsl index 328acae7f..8ce497012 100644 --- a/Templates/Empty/game/shaders/common/terrain/terrain.hlsl +++ b/Templates/Empty/game/shaders/common/terrain/terrain.hlsl @@ -32,9 +32,12 @@ float calcBlend( float texId, float2 layerCoord, float layerSize, float4 layerSa float4 diff = saturate( abs( layerSample - texId ) ); float noBlend = any( 1 - diff ); - // Use step to see if any of the layer samples + // Check if any of the layer samples // match the current texture id. - float4 factors = step( texId, layerSample ); + float4 factors = 0; + for(int i = 0; i < 4; i++) + if(layerSample[i] == texId) + factors[i] = 1; // This is a custom bilinear filter. diff --git a/Templates/Full/game/shaders/common/terrain/terrain.hlsl b/Templates/Full/game/shaders/common/terrain/terrain.hlsl index 328acae7f..8ce497012 100644 --- a/Templates/Full/game/shaders/common/terrain/terrain.hlsl +++ b/Templates/Full/game/shaders/common/terrain/terrain.hlsl @@ -32,9 +32,12 @@ float calcBlend( float texId, float2 layerCoord, float layerSize, float4 layerSa float4 diff = saturate( abs( layerSample - texId ) ); float noBlend = any( 1 - diff ); - // Use step to see if any of the layer samples + // Check if any of the layer samples // match the current texture id. - float4 factors = step( texId, layerSample ); + float4 factors = 0; + for(int i = 0; i < 4; i++) + if(layerSample[i] == texId) + factors[i] = 1; // This is a custom bilinear filter.