Working on planet
This commit is contained in:
1 parent
3887208b8d
commit
fe361885c0
10 files changed
+358
-227
No files matched your search
@@ -1,11 +1,23 @@
|
||||
attribute vec3 vPosition;
|
||||
attribute vec3 vColor;
|
||||
attribute vec3 vNormal;
|
||||
attribute vec2 vTexCoord; // <-- Обычные UV (если используются)
|
||||
|
||||
varying vec3 color;
|
||||
varying vec3 normal;
|
||||
|
||||
varying vec2 TexCoord; // <-- Передаем UV
|
||||
|
||||
uniform mat4 ProjectionModelViewMatrix;
|
||||
uniform mat4 ModelViewMatrix;
|
||||
uniform vec3 uLightDirection;
|
||||
|
||||
void main()
|
||||
void main()
|
||||
{
|
||||
gl_Position = ProjectionModelViewMatrix * vec4(vPosition.xyz, 1.0);
|
||||
color = vColor;
|
||||
gl_Position = ProjectionModelViewMatrix * vec4(vPosition.xyz, 1.0);
|
||||
|
||||
normal = normalize((ModelViewMatrix * vec4(vNormal, 0.0)).xyz);
|
||||
|
||||
color = vColor;
|
||||
TexCoord = vTexCoord;
|
||||
}
|
||||
@@ -1,9 +1,22 @@
|
||||
//precision mediump float;
|
||||
varying vec3 color;
|
||||
varying vec3 color; // Цвет вершины (с шумом)
|
||||
varying vec3 normal;
|
||||
varying vec3 lightDirection_VS;
|
||||
varying vec2 TexCoord; // UV-координаты
|
||||
|
||||
void main()
|
||||
uniform sampler2D Texture;
|
||||
uniform vec3 uLightDirection;
|
||||
void main()
|
||||
{
|
||||
//gl_FragColor = vec4(color, 1.0);
|
||||
gl_FragColor = vec4(1.0, 1.0, 0.5, 1.0);
|
||||
|
||||
// 1. Получаем цвет из текстуры и смешиваем с цветовым шумом
|
||||
vec4 textureColor = texture2D(Texture, TexCoord);
|
||||
vec3 finalColor = textureColor.rgb * color;
|
||||
|
||||
// 3. Расчет освещения
|
||||
float diffuse = max(0.0, dot(normal, uLightDirection));
|
||||
float ambient = 0.2;
|
||||
float lightingFactor = min(1.0, ambient + diffuse);
|
||||
|
||||
|
||||
gl_FragColor = vec4(finalColor * lightingFactor, 1.0);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user