Implemented terrain texturing
This commit is contained in:
parent
1475fd2101
commit
9fdd47ea6e
19 changed files with 1977 additions and 87 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#version 450
|
||||
|
||||
|
||||
layout(location = 0) in vec3 vertPos;
|
||||
layout(location = 1) in vec3 normal;
|
||||
layout(location = 2) in vec2 uv;
|
||||
|
|
@ -19,17 +20,18 @@ layout(location = 4) out vec2 TexCoords;
|
|||
layout (set = 1, binding = 0) uniform sampler2D diffuseSampler;
|
||||
|
||||
void main() {
|
||||
float texelSize = 1.0 / 200;
|
||||
float hL = texture(diffuseSampler, uv - vec2(texelSize, 0.0)).r;
|
||||
float hR = texture(diffuseSampler, uv + vec2(texelSize, 0.0)).r;
|
||||
float hD = texture(diffuseSampler, uv - vec2(0.0, texelSize)).r;
|
||||
float hU = texture(diffuseSampler, uv + vec2(0.0, texelSize)).r;
|
||||
float texelSize = 1.0 / (50*4);
|
||||
float hL = texture(diffuseSampler, uv - vec2(texelSize, 0.0)).r * 10;
|
||||
float hR = texture(diffuseSampler, uv + vec2(texelSize, 0.0)).r * 10;
|
||||
float hD = texture(diffuseSampler, uv - vec2(0.0, texelSize)).r * 10;
|
||||
float hU = texture(diffuseSampler, uv + vec2(0.0, texelSize)).r * 10;
|
||||
|
||||
float dX = (hR - hL) * 15.0;
|
||||
float dY = (hU - hD) * 15.0;
|
||||
|
||||
float y = texture(diffuseSampler, uv).x * 3;
|
||||
vec4 out_vec = proj.proj * view.view * vec4(vec3(vertPos.x, y, vertPos.z), 1.0);
|
||||
float y = texture(diffuseSampler, uv).x;
|
||||
|
||||
vec4 out_vec = proj.proj * view.view * vec4(vec3(vertPos.x, y * 10, vertPos.z), 1.0);
|
||||
FragPos = vec3(vertPos.x, y, vertPos.z);
|
||||
|
||||
Normal = normalize(vec3(-dX, -dY, 1.0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue