diff --git a/.DS_Store b/.DS_Store index 6e43419..38e5042 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/resources/images/particle.png b/resources/images/particle.png index 68b8ac2..9efb1f0 100644 Binary files a/resources/images/particle.png and b/resources/images/particle.png differ diff --git a/resources/shaders/particles.frag b/resources/shaders/particles.frag index 85d9ac2..fdbd8f0 100644 --- a/resources/shaders/particles.frag +++ b/resources/shaders/particles.frag @@ -11,5 +11,5 @@ uniform float alpha; void main() { vec4 c = texture(particle_texture, TexCoords); - fragColor = c*vec4(1,1,1,alpha)*1.6; + fragColor = c*vec4(1,1,1,alpha); } diff --git a/resources/shaders/particles.vert b/resources/shaders/particles.vert index 6e9e388..e83f161 100644 --- a/resources/shaders/particles.vert +++ b/resources/shaders/particles.vert @@ -13,9 +13,11 @@ uniform float alpha; void main() { float scale = 1.f;//2000.0f; - TexCoords = vec2(pos.x, pos.w); + TexCoords = vec2(pos.z, pos.w); //ParticleColor = color; // gl_Position = projection *view* vec4((pos * scale) + vec2(offset), 0.0, 1.0); gl_Position = (vec4(pos.x*alpha, pos.y*alpha, 0, 1) + projection*view*vec4(vec3(offset), 1))*scale; + //gl_Position = vec4(pos.x, pos.y, 0, 1); + } diff --git a/resources/shaders/shader.frag b/resources/shaders/shader.frag index 7fc82ed..63c5717 100755 --- a/resources/shaders/shader.frag +++ b/resources/shaders/shader.frag @@ -10,6 +10,7 @@ in vec3 refrPos; in float refrProb; in vec2 uv; in float matIor; +in float visibility; uniform sampler2D texture_img; @@ -27,6 +28,8 @@ uniform vec2 widthBounds; uniform vec2 lengthBounds; //uniform float test = 0; +uniform vec4 skyColor = vec4(1); + // Random methods from https://gist.github.com/patriciogonzalezvivo/670c22f3966e662d2f83 float rand(vec2 n) { @@ -120,4 +123,7 @@ void main() { // fragColor = texture(groundSampler, vec2(refrUV)); // fragColor = vec4(normal_worldSpace[0], 0, normal_worldSpace[1], 1.f); // fragColor = diffuse; + + //fragColor = vec4(vec3(visibility), 1); + // fragColor = mix(vec4(skyColor, 1.f), fragColor, 1.f); } diff --git a/resources/shaders/shader.vert b/resources/shaders/shader.vert index 3cd5c17..c31fe4e 100755 --- a/resources/shaders/shader.vert +++ b/resources/shaders/shader.vert @@ -24,6 +24,10 @@ out vec3 refrPos; out float refrProb; out vec2 uv; out float matIor; +out float visibility; + +const float density = .001f; +const float gradient = 4.f; vec4 getRefrPos() { // float depth = -1500.f; // TODO: Pass as uniform @@ -69,8 +73,8 @@ vec3 getReflPos() { void main() { // float depth = -4.f; // float dist = position.y - depth; - float width = 81.f * 2.f; - float length = 81.f * 2.f; +// float width = 81.f * 2.f; +// float length = 81.f * 2.f; matIor = 1.33f; normal_cameraSpace = normalize(inverse(transpose(mat3(view))) * inverseTransposeModel * normal); @@ -91,4 +95,10 @@ void main() { reflPos = getReflPos(); gl_Position = proj * view * model * vec4(position, 1); + +// vec4 positionRelationToCam = view * vec4(pos, 1.f); +// float distance = length(positionRelationToCam.xyz); +// visibility = exp(-pow((distance*density), gradient)); +// //visibility = distance * .0009f; +// visibility = clamp(visibility, 0.f, 1.f); }