-
Notifications
You must be signed in to change notification settings - Fork 13
CAD DTM Rendering #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
CAD DTM Rendering #186
Conversation
…Examples-and-Tests into dtm
}; | ||
|
||
// Set 0 - Scene Data and Globals, buffer bindings don't change the buffers only get updated | ||
[[vk::binding(0, 0)]] ConstantBuffer<Globals> globals : register(b0); | ||
[[vk::binding(1, 0)]] StructuredBuffer<DrawObject> drawObjects : register(t0); | ||
[[vk::binding(2, 0)]] StructuredBuffer<MainObject> mainObjects : register(t1); | ||
[[vk::binding(3, 0)]] StructuredBuffer<LineStyle> lineStyles : register(t2); | ||
[[vk::binding(4, 0)]] StructuredBuffer<DTMSettings> dtmSettingsBuff : register(t3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small rename, just dtmSettings
{ | ||
float4 outputColor = colorBelow; | ||
outputColor.rgb = colorAbove.rgb * colorAbove.a + outputColor.rgb * outputColor.a * (1.0f - colorAbove.a); | ||
outputColor.a = colorAbove.a + outputColor.a * (1.0f - colorAbove.a); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I think first ever blendColorOnTop, should override outputColor (dtmColor) and not blend at all.
you're wrongly blending with color black (let's say your only have height shading and it's color is (1, 0, 0, 0.5)), background color can be anything. you should let the hardware do the final blend.seems like you handle that by multiplying by outputColor.a -
looks like you're using the under blending operator, in that case it should be blendUnder?!
TL;DR I need some time to figure this out, can you help me understand why this works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok we should do under blending, change this function's name to blendUnder
and then render the other way around.
and as an optimization skip rendering the next stuff if alpha is 1.0 (the color is gonna get discarded for things behind)
the under blending operator is as follows:
dst.rgb = dst.rgb*dst.a + (1-dst.a)*src.a*src.rgb; // src and dst swapped
dst.a = (1.0f-src.a)*dst.a + src.a; // like currently implemented
``
the current implementation while it looks correct, fails when you just blend a bunch of fully transparent things on top of a semi transparent thing because `outputColor.rgb = outputColor.rgb*outputColor.a;` each time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edits: after putting some thought into it and reading dual depth, we should replace dst.rgb*dst.a
with just dst.rgb
because the multiplication was taken into account in previous steps by src.a*src.rgb
so the whole expression becomes:
dst.rgb = dst.rgb + (1-dst.a)*src.a*src.rgb; // src and dst swapped
dst.a = (1.0f-src.a)*dst.a + src.a; // like currently implemented
…Examples-and-Tests into dtm
// TODO: functions outside of the "dtm" namespace need to be moved to another file | ||
|
||
// for usage in upper_bound function | ||
struct StyleAccessor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move these to line_style.hlsl, and include it here
these aren't related to dtms
return dot(vec, vec); | ||
} | ||
|
||
// TODO: Later move these functions and structs to dtmSettings.hlsl and a namespace like dtmSettings::height_shading or dtmSettings::contours, etc.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
CAD DTM Rendering Example
Devsh-Graphics-Programming/Nabla#858