summaryrefslogtreecommitdiff
path: root/resources/shaders/shader.vert
diff options
context:
space:
mode:
authorSebastian Park <SebPark03@gmail.com>2024-04-23 12:06:00 -0400
committerSebastian Park <SebPark03@gmail.com>2024-04-23 12:06:00 -0400
commit12ec81fd1624e9b06e03d9a53a1873f63fe99c3b (patch)
treedb528688bbf888cf0f147a698d061f5c7ae89560 /resources/shaders/shader.vert
parenta556b45abf18f1bd509daaf63b66b7d55e9fd291 (diff)
parent6a5806b82c44a2cae481a6015d1a0f390e4b8445 (diff)
Merge branch 'shaders'
Diffstat (limited to 'resources/shaders/shader.vert')
-rwxr-xr-xresources/shaders/shader.vert19
1 files changed, 11 insertions, 8 deletions
diff --git a/resources/shaders/shader.vert b/resources/shaders/shader.vert
index 8447dd9..750a4da 100755
--- a/resources/shaders/shader.vert
+++ b/resources/shaders/shader.vert
@@ -21,13 +21,15 @@ out vec3 pos;
out vec3 refrPos;
out float refrProb;
out vec2 uv;
+out float matIor;
vec4 getRefrPos() {
- float depth = -1.f; // TODO: Pass as uniform
+ float depth = -3.f; // TODO: Pass as uniform
vec3 w_o = normalize(pos - camera_worldSpace);
float cos_theta_i = dot(-w_o, normal_worldSpace);
float n_i = 1;
float n_t = 1.33f;
+// matIor = n_t;
float determinant = 1.f - (pow((n_i / n_t), 2.f) * (1.f - pow(cos_theta_i, 2.f)));
float r0 = pow((n_i - n_t) / (n_i + n_t), 2.f); // variable required to calculate probability of reflection
@@ -52,10 +54,11 @@ vec4 getRefrPos() {
}
void main() {
- float depth = -2.f;
- float dist = position.y - depth;
+// float depth = -4.f;
+// float dist = position.y - depth;
float width = 81.f * 2.f;
float length = 81.f * 2.f;
+ matIor = 1.33f;
normal_cameraSpace = normalize(inverse(transpose(mat3(view))) * inverseTransposeModel * normal);
camera_worldSpace = vec3(inverseView * vec4(0.f, 0.f, 0.f, 1.f));
@@ -63,11 +66,11 @@ void main() {
pos = vec3(model * vec4(position, 1.f)); //vec3(model * vec4(objSpacePos, 1.f));
// pos = position;
- float depthScale = dist / normal.y;
- vec3 groundContactPoint = -(normal * depthScale) + position; // carries down to ground
- groundContactPoint = vec3(model * vec4(position, 1));
- uv = vec2((position.x + 81.f) / (162.f), groundContactPoint.z);
- uv = vec2(texCoords);
+// float depthScale = dist / normal.y;
+// vec3 groundContactPoint = -(normal * depthScale) + position; // carries down to ground
+// groundContactPoint = vec3(model * vec4(position, 1));
+// uv = vec2((position.x + 81.f) / (162.f), groundContactPoint.z);
+// uv = vec2(normal);
vec4 refrPos_and_prob = getRefrPos();
refrPos = vec3(refrPos_and_prob);
refrProb = clamp(refrPos_and_prob.w, 0.f, 1.f);