Skip to content

Commit

Permalink
maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
rdw-software committed Jan 31, 2024
1 parent 4f15b17 commit 00b6375
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Core/NativeClient/WebGPU/Shaders/TerrainGeometryShader.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,16 @@ fn vs_main(in: VertexInput) -> VertexOutput {
out.diffuseTextureCoords = in.diffuseTextureCoords;
out.lightmapTextureCoords = in.lightmapTextureCoords;

let modelViewPosition = homogeneousPosition * viewMatrix;
let distance = length(modelViewPosition.xyz - uPerSceneData.cameraWorldPosition.xyz);
let worldPosition = T1 * S * homogeneousPosition;
let viewPosition = viewMatrix * worldPosition;

// let modelViewPosition = homogeneousPosition * viewMatrix;
// let distance = length(viewPosition.xyz);
let distance = length(worldPosition.xyz - uPerSceneData.cameraWorldPosition.xyz);

// Linear fog calculation
let fogFactor = (fogFarLimit - distance) / (fogFarLimit - fogNearLimit);
out.fogFactor = clamp(fogFactor, 0.0, 1.0);
out.fogFactor = 1.0 - clamp(fogFactor, 0.0, 1.0);
// out.fogFactor = distance;

return out;
Expand Down

0 comments on commit 00b6375

Please sign in to comment.