diff options
| author | hachem <im@hachem.wtf> | 2025-08-18 05:02:13 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2025-08-18 05:02:13 +0200 |
| commit | d34925777dd4fac709096f1c18b7d886b43c15b2 (patch) | |
| tree | fac4c30a28784672c701898ff7612dbdfe530d49 /Assets/Shaders/Sphere.glsl | |
| parent | 1ecaea469e86ef3f5d18122c8b2cc187286e27f7 (diff) | |
[fix]: improvements, bump to c++20 and fix bugs
Diffstat (limited to 'Assets/Shaders/Sphere.glsl')
| -rw-r--r-- | Assets/Shaders/Sphere.glsl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Assets/Shaders/Sphere.glsl b/Assets/Shaders/Sphere.glsl index 37757b5..026f884 100644 --- a/Assets/Shaders/Sphere.glsl +++ b/Assets/Shaders/Sphere.glsl @@ -13,8 +13,8 @@ out vec3 v_WorldPos; void main() { - v_WorldPos = vec3(u_Transform * vec4(a_Position, 1.0)); - v_Normal = mat3(transpose(inverse(u_Transform))) * a_Normal; + v_WorldPos = vec3(u_Transform * vec4(a_Position, 1.0)); + v_Normal = mat3(transpose(inverse(u_Transform))) * a_Normal; gl_Position = u_ViewProjection * vec4(v_WorldPos, 1.0); } @@ -30,6 +30,9 @@ uniform float u_Specular; uniform float u_Emission; uniform vec3 u_LightPos; uniform vec3 u_CameraPos; +uniform int u_IsSelected; +uniform vec3 u_OutlineColor; +uniform float u_OutlineWidth; out vec4 o_FragColor; @@ -49,5 +52,15 @@ void main() vec3 emission = u_Color * u_Emission; vec3 result = ambient + diffuse + specular + emission; + + if (u_IsSelected > 0) + { + float ndotv = max(dot(normal, viewDir), 0.0); + float rim = 1.0 - ndotv; + float width = clamp(u_OutlineWidth, 0.0, 1.0); + float outlineMask = smoothstep(1.0 - width, 1.0, rim); + result = mix(result, u_OutlineColor, outlineMask); + } + o_FragColor = vec4(result, 1.0); } |
