-
-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Anisotropic Mipmapping + Improved Marchers and March Sets
- Loading branch information
1 parent
437d623
commit 4b2cde5
Showing
60 changed files
with
984 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 24 additions & 13 deletions
37
sources/engine/Xenko.Voxels/Voxels/Marching/MarchSets/Shaders/VoxelMarchSetHemisphere12.xksl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 19 additions & 14 deletions
33
sources/engine/Xenko.Voxels/Voxels/Marching/MarchSets/Shaders/VoxelMarchSetHemisphere6.xksl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...es/engine/Xenko.Voxels/Voxels/Marching/MarchSets/Shaders/VoxelMarchSetRandomHemisphere.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// <auto-generated> | ||
// Do not edit this file yourself! | ||
// | ||
// This code was generated by Xenko Shader Mixin Code Generator. | ||
// To generate it yourself, please install Xenko.VisualStudio.Package .vsix | ||
// and re-save the associated .xkfx. | ||
// </auto-generated> | ||
|
||
using System; | ||
using Xenko.Core; | ||
using Xenko.Rendering; | ||
using Xenko.Graphics; | ||
using Xenko.Shaders; | ||
using Xenko.Core.Mathematics; | ||
using Buffer = Xenko.Graphics.Buffer; | ||
|
||
namespace Xenko.Rendering | ||
{ | ||
public static partial class VoxelMarchSetRandomHemisphereKeys | ||
{ | ||
public static readonly ValueParameterKey<int> marchCount = ParameterKeys.NewValue<int>(); | ||
public static readonly ValueParameterKey<float> time = ParameterKeys.NewValue<float>(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
.../engine/Xenko.Voxels/Voxels/Marching/MarchSets/Shaders/VoxelMarchSetRandomHemisphere.xksl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
shader VoxelMarchSetRandomHemisphere : VoxelMarchSet, ShaderBase | ||
{ | ||
cbuffer PerView.Lighting | ||
{ | ||
int marchCount; | ||
float time; | ||
} | ||
float Random(in float2 uv) | ||
{ | ||
float2 noise = (frac(sin(dot(uv,float2(12.9898,78.233)*2.0)) * 43758.5453)); | ||
return abs(noise.x + noise.y) * 0.5; | ||
} | ||
float3 CosineWeightedPointOnHemisphere(float2 uv) { | ||
float u = Random(uv) * 6.28; | ||
float v = Random(uv + 0.1); | ||
|
||
v = sqrt(v); | ||
|
||
float2 pos = float2(sin(u),cos(u)) * v; | ||
|
||
return float3(pos, sqrt(1-pos.x*pos.x-pos.y*pos.y)); | ||
} | ||
|
||
compose VoxelMarchMethod Marcher; | ||
override float4 March(float3 rayPos, float3 rayDir) | ||
{ | ||
float3 tan = normalize(cross(rayDir, normalize(float3(1,1,1)))); | ||
float3 bitan = cross(tan, rayDir); | ||
float3x3 tangentMatrix = float3x3(tan, bitan, rayDir); | ||
|
||
float3 startPos = rayPos + rayDir * Marcher.StepSize(); | ||
|
||
float4 reflLighting = float4(0, 0, 0, 0); | ||
|
||
for(int i = 0; i < marchCount; i ++) | ||
{ | ||
float3 dir = CosineWeightedPointOnHemisphere(streams.ShadingPosition.xy + i*1.73 + time); | ||
dir = mul(dir, tangentMatrix); | ||
reflLighting += Marcher.March(startPos, dir); | ||
} | ||
|
||
return reflLighting/(float)marchCount; | ||
} | ||
}; |
34 changes: 34 additions & 0 deletions
34
sources/engine/Xenko.Voxels/Voxels/Marching/MarchSets/VoxelMarchSetBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xenko.Core; | ||
using Xenko.Shaders; | ||
|
||
namespace Xenko.Rendering.Voxels | ||
{ | ||
[DataContract(DefaultMemberMode = DataMemberMode.Default)] | ||
public class VoxelMarchSetBase | ||
{ | ||
public IVoxelMarchMethod Marcher { set; get; } = new VoxelMarchConePerMipmap(); | ||
public float Offset { set; get; } = 1.0f; | ||
public VoxelMarchSetBase() | ||
{ | ||
|
||
} | ||
public VoxelMarchSetBase(IVoxelMarchMethod marcher) | ||
{ | ||
Marcher = marcher; | ||
} | ||
|
||
protected ValueParameterKey<float> OffsetKey; | ||
public virtual void UpdateMarchingLayout(string compositionName) | ||
{ | ||
Marcher.UpdateMarchingLayout("Marcher." + compositionName); | ||
} | ||
public virtual void ApplyMarchingParameters(ParameterCollection parameters) | ||
{ | ||
Marcher.ApplyMarchingParameters(parameters); | ||
parameters.Set(OffsetKey, Offset); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.