mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-09 05:27:41 +00:00
Mass refactoring part 1/2: establishing multiple subprojects, moving source files to their new location, adding resources/templates to version control
This commit is contained in:
22
resources/shaders/BillboardShader.ps
Normal file
22
resources/shaders/BillboardShader.ps
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
in vec2 TexCoord;
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform sampler2D Texture;
|
||||
uniform vec4 TintColor;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
vec4 TextureColor = texture(Texture, TexCoord);
|
||||
if (TextureColor.a < 0.25) discard;
|
||||
|
||||
PixelColor = texture(Texture, TexCoord) * TintColor;
|
||||
PixelColor.a = 0;
|
||||
}
|
||||
|
||||
33
resources/shaders/BillboardShader.vs
Normal file
33
resources/shaders/BillboardShader.vs
Normal file
@@ -0,0 +1,33 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 4) in vec2 Tex0;
|
||||
|
||||
// Output
|
||||
out vec2 TexCoord;
|
||||
|
||||
// Uniforms
|
||||
layout(std140) uniform MVPBlock
|
||||
{
|
||||
mat4 TranslateMtx;
|
||||
mat4 ViewMtx;
|
||||
mat4 ProjMtx;
|
||||
};
|
||||
|
||||
uniform vec2 BillboardScale;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
mat4 MV = TranslateMtx * ViewMtx;
|
||||
mat4 VP = mat4 ( 1, 0, 0, MV[0][3],
|
||||
0, 1, 0, MV[1][3],
|
||||
0, 0, 1, MV[2][3],
|
||||
MV[3][0], MV[3][1], MV[3][2], MV[3][3]) * ProjMtx;
|
||||
|
||||
gl_Position = vec4(Position,1) * vec4(BillboardScale.xy, 1, 1) * VP;
|
||||
|
||||
TexCoord = vec2(Tex0.x, -Tex0.y);
|
||||
}
|
||||
|
||||
17
resources/shaders/CollisionShader.ps
Normal file
17
resources/shaders/CollisionShader.ps
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
in vec2 TexCoord;
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform sampler2D Texture;
|
||||
uniform vec4 TintColor;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
PixelColor = vec4(texture(Texture, TexCoord).rgb, 0) * TintColor;
|
||||
}
|
||||
28
resources/shaders/CollisionShader.vs
Normal file
28
resources/shaders/CollisionShader.vs
Normal file
@@ -0,0 +1,28 @@
|
||||
// This shader will be obsoleted soon when the collision rendering is improved
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 Position;
|
||||
|
||||
// Output
|
||||
out vec2 TexCoord;
|
||||
|
||||
// Uniforms
|
||||
layout(std140) uniform MVPBlock
|
||||
{
|
||||
mat4 ModelMtx;
|
||||
mat4 ViewMtx;
|
||||
mat4 ProjMtx;
|
||||
};
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
|
||||
gl_Position = vec4(Position, 1) * MVP;
|
||||
|
||||
// UV Generation
|
||||
float avg = (Position.x + Position.z) / 2;
|
||||
TexCoord.x = avg;
|
||||
TexCoord.y = Position.y + (avg / 2);
|
||||
}
|
||||
13
resources/shaders/ColorShader.ps
Normal file
13
resources/shaders/ColorShader.ps
Normal file
@@ -0,0 +1,13 @@
|
||||
#version 330 core
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform vec4 ColorIn;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
PixelColor = ColorIn;
|
||||
}
|
||||
19
resources/shaders/ColorShader.vs
Normal file
19
resources/shaders/ColorShader.vs
Normal file
@@ -0,0 +1,19 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 Position;
|
||||
|
||||
// Uniforms
|
||||
layout(std140) uniform MVPBlock
|
||||
{
|
||||
mat4 ModelMtx;
|
||||
mat4 ViewMtx;
|
||||
mat4 ProjMtx;
|
||||
};
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
|
||||
gl_Position = vec4(Position, 1) * MVP;
|
||||
};
|
||||
16
resources/shaders/ColorShaderLighting.ps
Normal file
16
resources/shaders/ColorShaderLighting.ps
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
in vec4 COLOR0A0;
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform vec4 ColorIn;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
PixelColor = ColorIn * COLOR0A0;
|
||||
}
|
||||
69
resources/shaders/ColorShaderLighting.vs
Normal file
69
resources/shaders/ColorShaderLighting.vs
Normal file
@@ -0,0 +1,69 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 RawPosition;
|
||||
layout(location = 1) in vec3 RawNormal;
|
||||
|
||||
// Output
|
||||
out vec4 COLOR0A0;
|
||||
|
||||
// Uniforms
|
||||
layout(std140) uniform MVPBlock
|
||||
{
|
||||
mat4 ModelMtx;
|
||||
mat4 ViewMtx;
|
||||
mat4 ProjMtx;
|
||||
};
|
||||
|
||||
layout(std140) uniform VertexBlock
|
||||
{
|
||||
mat4 TexMtx[10];
|
||||
mat4 PostMtx[20];
|
||||
vec4 COLOR0_Amb;
|
||||
vec4 COLOR0_Mat;
|
||||
vec4 COLOR1_Amb;
|
||||
vec4 COLOR1_Mat;
|
||||
};
|
||||
|
||||
struct SGXLight
|
||||
{
|
||||
vec4 Position;
|
||||
vec4 Direction;
|
||||
vec4 Color;
|
||||
vec4 DistAtten;
|
||||
vec4 AngleAtten;
|
||||
};
|
||||
layout(std140) uniform LightBlock {
|
||||
SGXLight Lights[8];
|
||||
};
|
||||
uniform int NumLights;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
|
||||
mat4 MV = ModelMtx * ViewMtx;
|
||||
gl_Position = vec4(RawPosition, 1) * MVP;
|
||||
vec3 Normal = normalize(RawNormal.xyz * inverse(transpose(mat3(MV))));
|
||||
|
||||
// Dynamic Lighting
|
||||
vec4 Illum = vec4(0.0);
|
||||
vec3 PositionMV = vec3(vec4(RawPosition, 1.0) * MV);
|
||||
|
||||
for (int iLight = 0; iLight < NumLights; iLight++)
|
||||
{
|
||||
vec3 LightPosMV = vec3(Lights[iLight].Position * ViewMtx);
|
||||
vec3 LightDirMV = normalize(Lights[iLight].Direction.xyz * inverse(transpose(mat3(ViewMtx))));
|
||||
vec3 LightDist = LightPosMV.xyz - PositionMV.xyz;
|
||||
float DistSquared = dot(LightDist, LightDist);
|
||||
float Dist = sqrt(DistSquared);
|
||||
LightDist /= Dist;
|
||||
vec3 AngleAtten = Lights[iLight].AngleAtten.xyz;
|
||||
AngleAtten = vec3(AngleAtten.x, AngleAtten.y, AngleAtten.z);
|
||||
float Atten = max(0, dot(LightDist, LightDirMV.xyz));
|
||||
Atten = max(0, dot(AngleAtten, vec3(1.0, Atten, Atten * Atten))) / dot(Lights[iLight].DistAtten.xyz, vec3(1.0, Dist, DistSquared));
|
||||
float DiffuseAtten = max(0, dot(Normal, LightDist));
|
||||
Illum += (Atten * DiffuseAtten * Lights[iLight].Color);
|
||||
}
|
||||
COLOR0A0 = COLOR0_Mat * (Illum + COLOR0_Amb);
|
||||
};
|
||||
28
resources/shaders/LightBillboardShader.ps
Normal file
28
resources/shaders/LightBillboardShader.ps
Normal file
@@ -0,0 +1,28 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
in vec2 TexCoord;
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform sampler2D Texture;
|
||||
uniform sampler2D LightMask;
|
||||
uniform vec4 LightColor;
|
||||
uniform vec4 TintColor;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
vec4 TextureColor = texture(Texture, TexCoord);
|
||||
if (TextureColor.a < 0.25) discard;
|
||||
|
||||
vec4 MaskColor = texture(LightMask, TexCoord);
|
||||
float MaskValue = (MaskColor.r + MaskColor.g + MaskColor.b) / 3;
|
||||
vec4 MaskedColor = mix(vec4(1,1,1,1), LightColor, MaskValue);
|
||||
|
||||
PixelColor = TextureColor * MaskedColor * TintColor;
|
||||
PixelColor.a = 0;
|
||||
}
|
||||
|
||||
33
resources/shaders/LightBillboardShader.vs
Normal file
33
resources/shaders/LightBillboardShader.vs
Normal file
@@ -0,0 +1,33 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 4) in vec2 Tex0;
|
||||
|
||||
// Output
|
||||
out vec2 TexCoord;
|
||||
|
||||
// Uniforms
|
||||
layout(std140) uniform MVPBlock
|
||||
{
|
||||
mat4 TranslateMtx;
|
||||
mat4 ViewMtx;
|
||||
mat4 ProjMtx;
|
||||
};
|
||||
|
||||
uniform vec2 BillboardScale;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
mat4 MV = TranslateMtx * ViewMtx;
|
||||
mat4 VP = mat4 ( 1, 0, 0, MV[0][3],
|
||||
0, 1, 0, MV[1][3],
|
||||
0, 0, 1, MV[2][3],
|
||||
MV[3][0], MV[3][1], MV[3][2], MV[3][3]) * ProjMtx;
|
||||
|
||||
gl_Position = vec4(Position,1) * vec4(BillboardScale.xy, 1, 1) * VP;
|
||||
|
||||
TexCoord = vec2(Tex0.x, -Tex0.y);
|
||||
}
|
||||
|
||||
27
resources/shaders/TextShader.ps
Normal file
27
resources/shaders/TextShader.ps
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
in vec2 TexCoord;
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform int RGBALayer;
|
||||
uniform vec4 FontColor;
|
||||
uniform sampler2D Texture;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
switch (RGBALayer)
|
||||
{
|
||||
case 0x0: PixelColor = texture(Texture, TexCoord).rrrr; break;
|
||||
case 0x1: PixelColor = texture(Texture, TexCoord).gggg; break;
|
||||
case 0x2: PixelColor = texture(Texture, TexCoord).bbbb; break;
|
||||
case 0x3: PixelColor = texture(Texture, TexCoord).aaaa; break;
|
||||
default: PixelColor = vec4(0,0,0,0); break;
|
||||
}
|
||||
|
||||
PixelColor *= FontColor;
|
||||
}
|
||||
18
resources/shaders/TextShader.vs
Normal file
18
resources/shaders/TextShader.vs
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 4) in vec2 Tex0;
|
||||
|
||||
// Output
|
||||
out vec2 TexCoord;
|
||||
|
||||
// Uniforms
|
||||
uniform mat4 ModelMtx;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position, 1) * ModelMtx;
|
||||
TexCoord = Tex0;
|
||||
}
|
||||
17
resources/shaders/TextureShader.ps
Normal file
17
resources/shaders/TextureShader.ps
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
in vec2 TexCoord;
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform sampler2D Texture;
|
||||
uniform vec4 TintColor;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
PixelColor = texture(Texture, TexCoord) * TintColor;
|
||||
}
|
||||
24
resources/shaders/TextureShader.vs
Normal file
24
resources/shaders/TextureShader.vs
Normal file
@@ -0,0 +1,24 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 4) in vec2 Tex0;
|
||||
|
||||
// Output
|
||||
out vec2 TexCoord;
|
||||
|
||||
// Uniforms
|
||||
layout(std140) uniform MVPBlock
|
||||
{
|
||||
mat4 ModelMtx;
|
||||
mat4 ViewMtx;
|
||||
mat4 ProjMtx;
|
||||
};
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
|
||||
gl_Position = vec4(Position, 1) * MVP;
|
||||
TexCoord = Tex0;
|
||||
};
|
||||
Reference in New Issue
Block a user