diff --git a/Projekte/mdga/client/src/main/resources/Images/b1.png b/Projekte/mdga/client/src/main/resources/Images/b1.png deleted file mode 100644 index 99b070f8..00000000 Binary files a/Projekte/mdga/client/src/main/resources/Images/b1.png and /dev/null differ diff --git a/Projekte/mdga/client/src/main/resources/Images/b2.png b/Projekte/mdga/client/src/main/resources/Images/b2.png deleted file mode 100644 index a545aec5..00000000 Binary files a/Projekte/mdga/client/src/main/resources/Images/b2.png and /dev/null differ diff --git a/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/Outline.frag b/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/Outline.frag index d38250b7..3dbbfaf0 100644 --- a/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/Outline.frag +++ b/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/Outline.frag @@ -1,7 +1,8 @@ +#version 150 + // Samplers for textures uniform sampler2D m_Texture; uniform sampler2D m_OutlineDepthTexture; -uniform sampler2D m_DepthTexture; // Input texture coordinates from the vertex shader in vec2 texCoord; @@ -15,26 +16,25 @@ uniform float m_OutlineWidth; out vec4 fragColor; void main() { - // Sample depth textures + // Sample depth textures at various offsets vec4 depth = texture(m_OutlineDepthTexture, texCoord); - vec4 depth1 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution); - vec4 depth2 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution); - vec4 depth3 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution); - vec4 depth4 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution); - vec4 depth5 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, m_OutlineWidth)) / m_Resolution); - vec4 depth6 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, -m_OutlineWidth)) / m_Resolution); - vec4 depth7 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, 0.0)) / m_Resolution); - vec4 depth8 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, 0.0)) / m_Resolution); + vec4 depth1 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution); + vec4 depth2 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution); + vec4 depth3 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution); + vec4 depth4 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution); + vec4 depth5 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, m_OutlineWidth)) / m_Resolution); + vec4 depth6 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -m_OutlineWidth)) / m_Resolution); + vec4 depth7 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, 0.0)) / m_Resolution); + vec4 depth8 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, 0.0)) / m_Resolution); // Sample the main texture vec4 color = texture(m_Texture, texCoord); - // Determine whether to apply the outline color - if (depth == vec4(0.0) && - (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth || - depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) { - fragColor = m_OutlineColor; // Apply outline color - } else { - fragColor = color; // Use the original texture color - } + // Check if an outline should be applied + bool isEdge = (depth == vec4(0.0)) && + (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth || + depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth); + + // Output the final color + fragColor = isEdge ? m_OutlineColor : color; } diff --git a/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePre.frag b/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePre.frag index a814e693..fcc055e9 100644 --- a/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePre.frag +++ b/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePre.frag @@ -1,11 +1,12 @@ +#version 150 -// Use 'in' instead of 'varying' for inputs from the vertex shader +// Input texture coordinates from the vertex shader in vec2 texCoord; -// Declare a custom output variable for the fragment color +// Output variable for the fragment color out vec4 fragColor; -// Uniform samplers +// Uniform samplers for textures uniform sampler2D m_Texture; uniform sampler2D m_NormalsTexture; uniform sampler2D m_DepthTexture; @@ -13,6 +14,7 @@ uniform sampler2D m_DepthTexture; void main() { // Sample the texture at the given texture coordinates vec4 color = texture(m_Texture, texCoord); + // Assign the color to the output variable fragColor = color; } diff --git a/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePro.frag b/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePro.frag index 26a9626e..106d3a1f 100644 --- a/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePro.frag +++ b/Projekte/mdga/client/src/main/resources/MatDefs/SelectObjectOutliner/OutlinePro.frag @@ -1,109 +1,80 @@ +#version 150 + +// Uniform samplers uniform sampler2D m_Texture; uniform sampler2D m_OutlineDepthTexture; uniform sampler2D m_DepthTexture; -varying vec2 texCoord; +// Input texture coordinates from the vertex shader +in vec2 texCoord; + +// Uniforms for resolution, outline color, and width uniform vec2 m_Resolution; uniform vec4 m_OutlineColor; uniform float m_OutlineWidth; +// Output variable for fragment color +out vec4 fragColor; + void main() { - vec4 depth = texture2D(m_OutlineDepthTexture, texCoord); - vec4 depth1 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,m_OutlineWidth))/m_Resolution); - vec4 depth2 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,-m_OutlineWidth))/m_Resolution); - vec4 depth3 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,m_OutlineWidth))/m_Resolution); - vec4 depth4 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,-m_OutlineWidth))/m_Resolution); - vec4 depth5 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,m_OutlineWidth))/m_Resolution); - vec4 depth6 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-m_OutlineWidth))/m_Resolution); - vec4 depth7 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,0.))/m_Resolution); - vec4 depth8 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,0.))/m_Resolution); - vec4 color = texture2D(m_Texture, texCoord); - //如果是背景 - float ratio=0.; - if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){ - float dist=m_OutlineWidth; - //距离边的像素 - vec4 nearDepth; - if(depth1 != depth){ - for(float i=0.;i