Skip to content

Commit

Permalink
chore: fixing some bugs in ray marching material
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Nov 29, 2023
1 parent 2a9283b commit 270b4c7
Show file tree
Hide file tree
Showing 4 changed files with 1,085 additions and 262 deletions.
2 changes: 1 addition & 1 deletion UnityClient/Assets/Scenes/UnityMouseRenderer.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 2699667523703933131, guid: a0c57925ee59dae4ebf1f78ba70837a6, type: 3}
propertyPath: localhost
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2699667523703933131, guid: a0c57925ee59dae4ebf1f78ba70837a6, type: 3}
propertyPath: IDChangedEvent.m_PersistentCalls.m_Calls.Array.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Material:
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Alpha: 0.05
- _Alpha: 0.025
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
Expand All @@ -76,7 +76,7 @@ Material:
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _StepSize: 0.05
- _StepSize: 0.5
- _UVSec: 0
- _ZWrite: 1
m_Colors:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Shader "Unlit/VolumeRayMarchShader"
#include "UnityCG.cginc"

// Maximum amount of raymarching samples
#define MAX_STEP_COUNT 256
#define MAX_STEP_COUNT 128

// Allowed floating point inaccuracy
#define EPSILON 0.00001f
Expand Down Expand Up @@ -95,7 +95,11 @@ Shader "Unlit/VolumeRayMarchShader"
// Accumulate color only within unit cube bounds
if(max(abs(samplePosition.x), max(abs(samplePosition.y), abs(samplePosition.z))) < 0.5f + EPSILON)
{
float4 sampledColor = tex3D(_MainTex, samplePosition + float3(0.5f, 0.5f, 0.5f));
// Calculate gradients for texture sampling
float3 dx = ddx(samplePosition + float3(0.5f, 0.5f, 0.5f));
float3 dy = ddy(samplePosition + float3(0.5f, 0.5f, 0.5f));

float4 sampledColor = tex3Dgrad(_MainTex, samplePosition + float3(0.5f, 0.5f, 0.5f), dx, dy);
sampledColor.a *= _Alpha;
color = BlendUnder(color, sampledColor);
samplePosition += rayDirection * _StepSize;
Expand Down
Loading

0 comments on commit 270b4c7

Please sign in to comment.