Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions data/shaders/shader_Outline.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable

layout(binding = 0) uniform sampler2D texSampler;

layout(location = 0) in vec3 fragColor;
layout(location = 1) in vec2 fragTexCoord;

layout(location = 0) out vec4 outColor;

void main() {
vec4 shadowColor = {1.0,0.5,0.0,0.5 }; // Color of the shadow/outline

vec2 texSize = textureSize(texSampler, 0);
vec2 texOffset = vec2(1.0) / texSize; // Size of a single texel

float shadowAlpha = 0.0;

shadowAlpha = 0.0;
int n=3; // Size of surrounding for outline sampling
for (int x=-n; x<=n; ++x) {
for (int y=-n; y<=n; ++y) {
shadowAlpha += texture(texSampler,
+fragTexCoord
+vec2(x,y)*texOffset).a;
}
}

// Get the original texture color
vec4 original = texture(texSampler, fragTexCoord);

// First combine the shadow with the background color
outColor = mix(vec4(0.1,0.1,0.3,1.0), shadowColor, min(shadowAlpha,1.0));

// Now combine with the original model
outColor = mix(outColor, original, original.a);
}

1 change: 1 addition & 0 deletions examples/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_subdirectory(vsgvalidate)
add_subdirectory(vsgaxes)
add_subdirectory(vsgcolorspace)
add_subdirectory(vsgmultiwindowmultiview)
add_subdirectory(vsgrenderoutline)

if (vsgXchange_FOUND)
add_subdirectory(vsghelloworld)
Expand Down
14 changes: 14 additions & 0 deletions examples/app/vsgrenderoutline/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set(SOURCES
vsgrenderoutline.cpp
)

add_executable(vsgrenderoutline ${SOURCES})

target_link_libraries(vsgrenderoutline vsg::vsg)

if (vsgXchange_FOUND)
target_compile_definitions(vsgrenderoutline PRIVATE vsgXchange_FOUND)
target_link_libraries(vsgrenderoutline vsgXchange::vsgXchange)
endif()

install(TARGETS vsgrenderoutline RUNTIME DESTINATION bin)
Loading