#version 430 layout (binding = 0) uniform sampler3D noiseSamp; layout (binding = 1) uniform sampler2D textureSamp; layout (binding = 2) uniform sampler2D bumpSamp; layout (binding = 3) uniform sampler2D normalSamp; uniform float height; in vec3 varPositionG; in vec2 varTextureG; in vec3 tangentLightPosG; in vec3 tangentViewPosG; in vec3 tangentFragPosG; uniform vec3 viewPos; out vec4 color; const vec3 light = vec3(-0.746, -0.373, -0.224); uniform float heightScale; vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir) { float height = texture(bumpSamp, texCoords, 0.0).r; vec2 p = viewDir.xy / viewDir.z * (height * heightScale); return texCoords - p; } void main(void) { vec2 tex = varTextureG + vec2(0.0, height); //float depth = texture(textureSamp, tex).x; //vec3 dir = (camPosition - varPositionG) * depth * 0.05; //vec3 f = texture(textureSamp, tex).xyz; //float l = max(dot(light, varNormalG), 0.0) * 0.7 + 0.3; //color = vec4(f, 1.0); // offset texture coordinates with Parallax Mapping vec3 viewDir = normalize(tangentViewPosG - tangentFragPosG); vec2 texCoords = ParallaxMapping(tex.xy, viewDir); // then sample textures with new texture coords //vec3 diffuse = texture(diffuseMap, texCoords); vec3 normal = texture(normalSamp, texCoords).xyz; normal = normalize(normal * 2.0 - 1.0); float l = max(dot(-light, normal), 0.0) * 0.7 + 0.3; color = vec4(texture(textureSamp, texCoords).xyz * l, 1.0); }