Too much changes

This commit is contained in:
2025-03-09 04:50:41 +03:00
parent e45d21b621
commit b1fb15fa1f
20 changed files with 255 additions and 44 deletions

10
shaders/debug_draw.ps Normal file
View File

@@ -0,0 +1,10 @@
#version 330 core
in vec3 v_color;
out vec4 fragColor;
void main()
{
fragColor = vec4(v_color, 1.0);
}

15
shaders/debug_draw.vs Normal file
View File

@@ -0,0 +1,15 @@
#version 330 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec3 color;
out vec3 v_color;
uniform mat4 u_modelViewProjection;
void main()
{
gl_Position = u_modelViewProjection * vec4(position, 1.0f);
v_color = color;
}

15
shaders/lit_generic.ps Normal file
View File

@@ -0,0 +1,15 @@
#version 120
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord;
varying vec3 v_finalColor;
uniform sampler2D u_albedoTexture;
uniform vec4 u_customColor;
void main() {
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragColor = u_customColor * vec4(v_finalColor, 1.0) * texture2D(u_albedoTexture, v_texcoord);
//gl_FragColor = vec4( v_normal, 1.0 );
}

46
shaders/lit_generic.vs Normal file
View File

@@ -0,0 +1,46 @@
#version 120
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texcoord;
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord;
varying vec3 v_finalColor;
uniform mat4 u_modelMatrix;
uniform mat4 u_viewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat4 u_modelViewProjection;
vec3 CalcOmniLight()
{
vec3 lightPos = vec3(0.1, 2.1, 0.1);
float d = distance(lightPos, v_position);
vec3 L = normalize(lightPos-v_position);
vec3 N = normalize(v_normal);
vec3 col = vec3( max(0, dot(N, L) / d) );
col = col * 0.8 + 0.2;
return col;
}
vec3 CalcDirLight()
{
vec3 lightPos = vec3(5.0, 10.0, 1.0);
//lightPos = -lightPos;
vec3 L = normalize(lightPos);
vec3 N = normalize(v_normal);
vec3 col = vec3( max(0, dot(N, L)) );
col = col * 0.8 + 0.2;
return col;
}
void main() {
v_position = vec3( u_modelMatrix * vec4(a_position, 1.0) );
v_normal = vec3( mat3(u_modelMatrix) * a_normal );
v_texcoord = a_texcoord;
v_finalColor = CalcDirLight();
gl_Position = u_modelViewProjection * vec4(a_position, 1);
}

View File

@@ -0,0 +1,15 @@
#version 120
varying vec3 v_position;
varying vec3 v_normal;
varying vec2 v_texcoord;
varying vec3 v_finalColor;
uniform sampler2D u_albedoTexture;
uniform vec4 u_customColor;
void main() {
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragColor = u_customColor * vec4(v_finalColor, 1.0) * texture2D(u_albedoTexture, v_texcoord);
//gl_FragColor = vec4( v_normal, 1.0 );
}

8
shaders/ui_base.ps Normal file
View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 v_texcoord;
varying vec4 v_color;
void main() {
gl_FragColor = v_color;
}

16
shaders/ui_base.vs Normal file
View File

@@ -0,0 +1,16 @@
#version 120
attribute vec2 a_position;
attribute vec2 a_texcoord;
attribute vec4 a_color;
varying vec2 v_texcoord;
varying vec4 v_color;
uniform mat4 u_projectionMatrix;
void main() {
v_texcoord = a_texcoord;
v_color = a_color;
gl_Position = u_projectionMatrix * vec4(a_position.xy,0,1);
}

11
shaders/ui_tex.ps Normal file
View File

@@ -0,0 +1,11 @@
#version 120
varying vec2 v_texcoord;
varying vec4 v_color;
uniform sampler2D u_texture;
void main() {
vec4 tex = texture2D( u_texture, v_texcoord );
gl_FragColor = v_color * tex;
}