mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-09 05:27:41 +00:00
Rewrote collision shader to use generated normals with fake lighting instead of generated UV coords
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
in vec2 TexCoord;
|
||||
in vec4 LightColor;
|
||||
|
||||
// Output
|
||||
out vec4 PixelColor;
|
||||
|
||||
// Uniforms
|
||||
uniform sampler2D Texture;
|
||||
uniform vec4 TintColor;
|
||||
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
PixelColor = vec4(texture(Texture, TexCoord).rgb, 0) * TintColor;
|
||||
PixelColor = LightColor * TintColor;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// This shader will be obsoleted soon when the collision rendering is improved
|
||||
#version 330 core
|
||||
|
||||
// Input
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 0) in vec3 RawPosition;
|
||||
layout(location = 1) in vec3 RawNormal;
|
||||
|
||||
// Output
|
||||
out vec2 TexCoord;
|
||||
out vec4 LightColor;
|
||||
|
||||
// Uniforms
|
||||
layout(std140) uniform MVPBlock
|
||||
@@ -18,11 +18,12 @@ layout(std140) uniform MVPBlock
|
||||
// Main
|
||||
void main()
|
||||
{
|
||||
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
|
||||
gl_Position = vec4(Position, 1) * MVP;
|
||||
mat4 MVP = ModelMtx * ViewMtx * ProjMtx;
|
||||
gl_Position = vec4(RawPosition, 1) * MVP;
|
||||
|
||||
// UV Generation
|
||||
float avg = (Position.x + Position.z) / 2;
|
||||
TexCoord.x = avg;
|
||||
TexCoord.y = Position.y + (avg / 2);
|
||||
// Fake lighting; render one white skylight pointing straight down with an ambient 0.5
|
||||
float LightDot = dot(RawNormal, vec3(0, 0, -1));
|
||||
float Alpha = (-LightDot + 1.0) / 2;
|
||||
float LightAlpha = mix(0.5, 0.9, Alpha);
|
||||
LightColor = vec4(LightAlpha, LightAlpha, LightAlpha, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user