Fix build errors by using C string literals
I used c++ style and it compiled locally but failed on the test
This commit is contained in:
parent
f97f994512
commit
41d9453ef4
1 changed files with 92 additions and 95 deletions
|
|
@ -39,104 +39,101 @@
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Forward Vertex Shader
|
// Forward Vertex Shader
|
||||||
static const char *multiLightVS = GLSL_VERSION R"(
|
static const char *multiLightVS = GLSL_VERSION
|
||||||
in vec3 vertexPosition;
|
"in vec3 vertexPosition;\n"
|
||||||
in vec2 vertexTexCoord;
|
"in vec2 vertexTexCoord;\n"
|
||||||
in vec3 vertexNormal;
|
"in vec3 vertexNormal;\n"
|
||||||
|
"\n"
|
||||||
out vec3 fragPosition;
|
"out vec3 fragPosition;\n"
|
||||||
out vec3 fragNormal;
|
"out vec3 fragNormal;\n"
|
||||||
out vec2 fragTexCoord;
|
"out vec2 fragTexCoord;\n"
|
||||||
|
"\n"
|
||||||
uniform mat4 mvp;
|
"uniform mat4 mvp;\n"
|
||||||
uniform mat4 matModel;
|
"uniform mat4 matModel;\n"
|
||||||
|
"\n"
|
||||||
void main() {
|
"void main() {\n"
|
||||||
fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));
|
" fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));\n"
|
||||||
fragNormal = normalize(vec3(matModel * vec4(vertexNormal, 0.0)));
|
" fragNormal = normalize(vec3(matModel * vec4(vertexNormal, 0.0)));\n"
|
||||||
fragTexCoord = vertexTexCoord;
|
" fragTexCoord = vertexTexCoord;\n"
|
||||||
gl_Position = mvp * vec4(vertexPosition, 1.0);
|
" gl_Position = mvp * vec4(vertexPosition, 1.0);\n"
|
||||||
}
|
"}\n";
|
||||||
)";
|
|
||||||
|
|
||||||
// Forward Fragment Shader (Point Light Falloff & Blinn-Phong Specular)
|
// Forward Fragment Shader (Point Light Falloff & Blinn-Phong Specular)
|
||||||
static const char *multiLightFS = GLSL_VERSION R"(
|
static const char *multiLightFS = GLSL_VERSION
|
||||||
in vec3 fragPosition;
|
"in vec3 fragPosition;\n"
|
||||||
in vec3 fragNormal;
|
"in vec3 fragNormal;\n"
|
||||||
in vec2 fragTexCoord;
|
"in vec2 fragTexCoord;\n"
|
||||||
|
"\n"
|
||||||
out vec4 finalColor;
|
"out vec4 finalColor;\n"
|
||||||
|
"\n"
|
||||||
uniform sampler2D texture0;
|
"uniform sampler2D texture0;\n"
|
||||||
uniform vec3 viewPos;
|
"uniform vec3 viewPos;\n"
|
||||||
uniform vec3 lightPositions[8];
|
"uniform vec3 lightPositions[8];\n"
|
||||||
uniform vec3 lightColors[8];
|
"uniform vec3 lightColors[8];\n"
|
||||||
|
"\n"
|
||||||
void main() {
|
"void main() {\n"
|
||||||
vec4 texColor = texture(texture0, fragTexCoord);
|
" vec4 texColor = texture(texture0, fragTexCoord);\n"
|
||||||
vec3 norm = normalize(fragNormal);
|
" vec3 norm = normalize(fragNormal);\n"
|
||||||
vec3 viewDir = normalize(viewPos - fragPosition);
|
" vec3 viewDir = normalize(viewPos - fragPosition);\n"
|
||||||
|
"\n"
|
||||||
// Dark ambient baseline
|
" // Dark ambient baseline\n"
|
||||||
vec3 ambient = 0.05 * texColor.rgb;
|
" vec3 ambient = 0.05 * texColor.rgb;\n"
|
||||||
vec3 totalDiffuse = vec3(0.0);
|
" vec3 totalDiffuse = vec3(0.0);\n"
|
||||||
vec3 totalSpecular = vec3(0.0);
|
" vec3 totalSpecular = vec3(0.0);\n"
|
||||||
|
"\n"
|
||||||
for (int i = 0; i < 8; i++) {
|
" for (int i = 0; i < 8; i++) {\n"
|
||||||
vec3 lightDir = normalize(lightPositions[i] - fragPosition);
|
" vec3 lightDir = normalize(lightPositions[i] - fragPosition);\n"
|
||||||
float dist = length(lightPositions[i] - fragPosition);
|
" float dist = length(lightPositions[i] - fragPosition);\n"
|
||||||
|
" \n"
|
||||||
// Attenuation calculation
|
" // Attenuation calculation\n"
|
||||||
float attenuation = 1.0 / (1.0 + 0.8 * dist + 0.4 * dist * dist);
|
" float attenuation = 1.0 / (1.0 + 0.8 * dist + 0.4 * dist * dist);\n"
|
||||||
|
"\n"
|
||||||
// Diffuse Shading
|
" // Diffuse Shading\n"
|
||||||
float diff = max(dot(norm, lightDir), 0.0);
|
" float diff = max(dot(norm, lightDir), 0.0);\n"
|
||||||
totalDiffuse += diff * lightColors[i] * attenuation * 1.2;
|
" totalDiffuse += diff * lightColors[i] * attenuation * 1.2;\n"
|
||||||
|
"\n"
|
||||||
// Blinn-Phong Specular
|
" // Blinn-Phong Specular\n"
|
||||||
vec3 halfwayDir = normalize(lightDir + viewDir);
|
" vec3 halfwayDir = normalize(lightDir + viewDir);\n"
|
||||||
float spec = pow(max(dot(norm, halfwayDir), 0.0), 32.0);
|
" float spec = pow(max(dot(norm, halfwayDir), 0.0), 32.0);\n"
|
||||||
totalSpecular += spec * lightColors[i] * attenuation * 0.8;
|
" totalSpecular += spec * lightColors[i] * attenuation * 0.8;\n"
|
||||||
}
|
" }\n"
|
||||||
|
"\n"
|
||||||
vec3 result = ambient + (totalDiffuse * texColor.rgb) + totalSpecular;
|
" vec3 result = ambient + (totalDiffuse * texColor.rgb) + totalSpecular;\n"
|
||||||
finalColor = vec4(result, texColor.a);
|
" finalColor = vec4(result, texColor.a);\n"
|
||||||
}
|
"}\n";
|
||||||
)";
|
|
||||||
|
|
||||||
// Tone-Mapped Kawase Bloom Fragment Shader
|
// Tone-Mapped Kawase Bloom Fragment Shader
|
||||||
static const char *bloomFS = GLSL_VERSION R"(
|
static const char *bloomFS = GLSL_VERSION
|
||||||
in vec2 fragTexCoord;
|
"in vec2 fragTexCoord;\n"
|
||||||
out vec4 finalColor;
|
"out vec4 finalColor;\n"
|
||||||
|
"\n"
|
||||||
uniform sampler2D texture0;
|
"uniform sampler2D texture0;\n"
|
||||||
|
"\n"
|
||||||
void main() {
|
"void main() {\n"
|
||||||
vec2 uv = fragTexCoord;
|
" vec2 uv = fragTexCoord;\n"
|
||||||
vec4 color = texture(texture0, uv);
|
" vec4 color = texture(texture0, uv);\n"
|
||||||
|
"\n"
|
||||||
// High-pass threshold check (pixels brighter than 0.75)
|
" // High-pass threshold check (pixels brighter than 0.75)\n"
|
||||||
vec4 bloom = vec4(0.0);
|
" vec4 bloom = vec4(0.0);\n"
|
||||||
vec2 texel = vec2(1.0 / 1280.0, 1.0 / 720.0) * 2.5;
|
" vec2 texel = vec2(1.0 / 1280.0, 1.0 / 720.0) * 2.5;\n"
|
||||||
|
"\n"
|
||||||
for (int x = -2; x <= 2; x++) {
|
" for (int x = -2; x <= 2; x++) {\n"
|
||||||
for (int y = -2; y <= 2; y++) {
|
" for (int y = -2; y <= 2; y++) {\n"
|
||||||
vec4 smp = texture(texture0, uv + vec2(x, y) * texel);
|
" vec4 smp = texture(texture0, uv + vec2(x, y) * texel);\n"
|
||||||
float brightness = max(smp.r, max(smp.g, smp.b));
|
" float brightness = max(smp.r, max(smp.g, smp.b));\n"
|
||||||
if (brightness > 0.75) bloom += smp;
|
" if (brightness > 0.75) bloom += smp;\n"
|
||||||
}
|
" }\n"
|
||||||
}
|
" }\n"
|
||||||
bloom /= 25.0;
|
" bloom /= 25.0;\n"
|
||||||
|
"\n"
|
||||||
// Combine original with soft bloom glow
|
" // Combine original with soft bloom glow\n"
|
||||||
vec3 HDR = color.rgb + bloom.rgb * 1.2;
|
" vec3 HDR = color.rgb + bloom.rgb * 1.2;\n"
|
||||||
|
"\n"
|
||||||
// Reinhard Tone Mapping
|
" // Reinhard Tone Mapping\n"
|
||||||
vec3 LDR = HDR / (HDR + vec3(1.0));
|
" vec3 LDR = HDR / (HDR + vec3(1.0));\n"
|
||||||
|
"\n"
|
||||||
finalColor = vec4(LDR, color.a);
|
" finalColor = vec4(LDR, color.a);\n"
|
||||||
}
|
"}\n";
|
||||||
)";
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Types and Structures Definition
|
// Types and Structures Definition
|
||||||
|
|
@ -311,4 +308,4 @@ void UpdateDrawFrame(void)
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue