From ff838b8e85a93236fa67b26496083ec90899566a Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Wed, 16 Feb 2022 20:33:16 +0800 Subject: [PATCH] rename shader variables to avoid keywords --- internal/asset/shader/world/ssao.frag | 4 ++-- internal/asset/shader/world/ssao_blur.frag | 12 ++++++------ internal/render/render_world.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/asset/shader/world/ssao.frag b/internal/asset/shader/world/ssao.frag index fac6f9a..ad74c1f 100644 --- a/internal/asset/shader/world/ssao.frag +++ b/internal/asset/shader/world/ssao.frag @@ -25,7 +25,7 @@ float fragDepthView; in vec2 fragPosScreen; -layout (location = 0) out float output; +layout (location = 0) out float outputColor; // A random number generator from the web. @@ -74,5 +74,5 @@ void main() { occlusion += (sampleDepth >= viewpos.z/viewpos.w + bias ? 1.0 : 0.0) * rangeCheck; } - output = 1.0 - (occlusion / SSAO_SAMPLE_COUNT); + outputColor = 1.0 - (occlusion / SSAO_SAMPLE_COUNT); } diff --git a/internal/asset/shader/world/ssao_blur.frag b/internal/asset/shader/world/ssao_blur.frag index c36cf9d..888dc44 100644 --- a/internal/asset/shader/world/ssao_blur.frag +++ b/internal/asset/shader/world/ssao_blur.frag @@ -1,21 +1,21 @@ #version 330 -uniform sampler2D input; +uniform sampler2D tex; uniform vec2 screenSize; in vec2 fragPosScreen; -layout (location = 0) out float output; +layout (location = 0) out float outputColor; void main() { - output = 0; + outputColor = 0; for (int i = -3; i <= 3; i++) for (int j = -3; j <= 3; j++) - output += texture(input, fragPosScreen + vec2(i, j) / screenSize).r; + outputColor += texture(tex, fragPosScreen + vec2(i, j) / screenSize).r; - output /= 49.0; - output *= output; + outputColor /= 49.0; + outputColor *= outputColor; } diff --git a/internal/render/render_world.go b/internal/render/render_world.go index d07b6aa..18c753a 100644 --- a/internal/render/render_world.go +++ b/internal/render/render_world.go @@ -233,7 +233,7 @@ func (r *WorldRenderer) Init(w *world.World) (err error) { gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, r.ssao.ambient, 0) - r.ssao.blur.shader.SetUniformTextureHandle("input", r.ssao.ambient) + r.ssao.blur.shader.SetUniformTextureHandle("tex", r.ssao.ambient) // uniform buffer object for samples ssaoSamples := make([]itype.Vec4f, SSAOSampleCount) for i := range ssaoSamples {