Текстурное смещение
This commit is contained in:
@@ -8,6 +8,7 @@ layout(std140, binding = 1) uniform Material
|
||||
float p;
|
||||
bool normalmapped;
|
||||
bool parallaxmapped;
|
||||
bool displacementmapped;
|
||||
};
|
||||
|
||||
in vec3 pos_local;
|
||||
|
||||
@@ -8,6 +8,7 @@ layout(std140, binding = 1) uniform Material
|
||||
float p;
|
||||
bool normalmapped;
|
||||
bool parallaxmapped;
|
||||
bool displacementmapped;
|
||||
};
|
||||
|
||||
layout (location = 0) out vec3 gPosition;
|
||||
|
||||
@@ -13,6 +13,20 @@ layout(std140, binding = 0) uniform Camera
|
||||
vec3 position;
|
||||
} camera;
|
||||
|
||||
layout(std140, binding = 1) uniform Material
|
||||
{
|
||||
vec3 ka;
|
||||
vec3 kd;
|
||||
vec3 ks;
|
||||
float p;
|
||||
bool normalmapped;
|
||||
bool parallaxmapped;
|
||||
bool displacementmapped;
|
||||
};
|
||||
|
||||
uniform sampler2D tex_heights;
|
||||
uniform float displacement_heightScale = 0.1;
|
||||
|
||||
uniform mat4 model;
|
||||
|
||||
out vec3 vertex; // Позиция вершины в пространстве
|
||||
@@ -36,5 +50,11 @@ void main()
|
||||
|
||||
view = camera.position - vertex;
|
||||
|
||||
if (displacementmapped)
|
||||
{
|
||||
float height = texture(tex_heights, texCoord).r * displacement_heightScale;
|
||||
P.xyz += mat3(T, B, N) * vec3(0, 0, height);
|
||||
}
|
||||
|
||||
gl_Position = camera.projection * camera.view * P;
|
||||
}
|
||||
Reference in New Issue
Block a user