Skip to content

Commit

Permalink
Added some user based clipping
Browse files Browse the repository at this point in the history
  • Loading branch information
kecho committed Feb 8, 2023
1 parent 5492e73 commit 66e0a59
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion grr/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, id):
self.m_last_mouse = (0.0, 0.0)

#camera settings
self.m_cam_move_speed = 0.1
self.m_cam_move_speed = 4.0
self.m_cam_rotation_speed = 0.1
self.m_last_mouse = (0, 0)
self.m_curr_mouse = (0, 0)
Expand Down
13 changes: 7 additions & 6 deletions grr/geometry.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ namespace geometry
og1 = h1;
og2 = h2;
clipZMask = 0;
clipZMask |= clipVert(h2, h0) << 0;
clipZMask |= clipVert(h2, h1) << 1;
clipZMask |= clipVert(h1, h2) << 2;
clipZMask |= clipVert(og2, h0, 1) << 0;
clipZMask |= clipVert(og2, h1, 1) << 1;
clipZMask |= clipVert(og1, h2, 1) << 2;
calculatePoints();
}

uint clipVert(in float4 dominantVert, inout float4 h)
uint clipVert(in float4 dominantVert, inout float4 h, float s)
{
if (h.z < h.w)
return h.w < MIN_DEPTH;
return 0;

float dw = MIN_DEPTH - h.w;
float2 a = (h.xy - dominantVert.xy)/(h.w - dominantVert.w);
float ogDepth = h.w;
h.w = MIN_DEPTH;
h.xy += a * dw;
h.xy += s * a * dw;
return 1;
}

Expand Down Expand Up @@ -188,6 +188,7 @@ namespace geometry

TriInterpResult result;
result.bari = computeBaryCoordPerspective(float3(og0.xy/og0.w,og0.w), float3(og1.xy/og1.w,og1.w), float3(og2.xy/og2.w,og2.w), hCoords);
//result.bari = computeBaryCoordPerspective(float3(p0.xy,h0.w), float3(p1.xy,h1.w), float3(p2.xy,h2.w), hCoords);
result.isBackface = backFace > 0.0;
result.isFrontface = frontFace > 0.0;
result.visible = result.isBackface || result.isFrontface;
Expand Down
5 changes: 4 additions & 1 deletion grr/raster_cs.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ void csMainBinTriangles(int3 dti : SV_DispatchThreadID)
geometry::TriangleH th;
th.init(tv, g_view, g_proj);

if ((th.clipZMask & ((1 << 3) - 1)) != 0)
//if ((th.clipZMask & ((1 << 3) - 1)) != 0)
// return;

if (all(abs(th.og0.xyz) > th.og0.w) && all(abs(th.og0.xyz) > th.og0.w) && all(abs(th.og0.xyz) > th.og0.w))
return;

geometry::AABB aabb = th.aabb();
Expand Down

0 comments on commit 66e0a59

Please sign in to comment.