mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 18:00:34 +00:00
coolfog: also affect textures
This commit is contained in:
parent
81d1066596
commit
44f359582c
20
shaders.cpp
20
shaders.cpp
@ -67,6 +67,9 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
||||
varying += "varying mediump vec4 vColor;\n";
|
||||
|
||||
fmain += "gl_FragColor = vColor;\n";
|
||||
|
||||
bool have_texture = false;
|
||||
|
||||
if(shader_flags & GF_TEXTURE_SHADED) {
|
||||
vsh += "attribute mediump vec3 aTexture;\n";
|
||||
varying += "varying mediump vec3 vTexCoord;\n";
|
||||
@ -80,7 +83,7 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
||||
varying += "varying mediump vec2 vTexCoord;\n";
|
||||
fsh += "uniform mediump sampler2D tTexture;\n";
|
||||
vmain += "vTexCoord = aTexture;\n",
|
||||
fmain += "gl_FragColor *= texture2D(tTexture, vTexCoord);\n";
|
||||
have_texture = true;
|
||||
}
|
||||
if(shader_flags & GF_LEVELS) {
|
||||
fsh += "uniform mediump float uLevelLines;\n";
|
||||
@ -300,6 +303,18 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
||||
"if(fogs < 0.) fogs = 0.;\n"
|
||||
"fog.xyz /= fog.w;\n"
|
||||
"vColor.xyz = vColor.xyz * fogs + fog.xyz * (1.0-fogs);\n";
|
||||
|
||||
if(have_texture) {
|
||||
varying += "varying mediump vec4 fog_color;\n";
|
||||
vmain += "fog_color = fog;\n";
|
||||
fmain +=
|
||||
"if(vTexCoord.x == 0.) {\n"
|
||||
"vec4 t = texture2D(tTexture, vTexCoord);\n"
|
||||
"gl_FragColor = t * gl_FragColor + (1.-t) * fog_color;\n"
|
||||
"}\n"
|
||||
"else gl_FragColor *= texture2D(tTexture, vTexCoord);\n";
|
||||
have_texture = false;
|
||||
}
|
||||
}
|
||||
else if(distfun != "") {
|
||||
vmain += "mediump float fogs = (uFogBase - " + distfun + " / uFog);\n";
|
||||
@ -314,6 +329,9 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
||||
vmain += "gl_Position = uP * t;\n";
|
||||
}
|
||||
|
||||
if(have_texture)
|
||||
fmain += "gl_FragColor *= texture2D(tTexture, vTexCoord);\n";
|
||||
|
||||
vsh +=
|
||||
"uniform mediump mat4 uMV;\n"
|
||||
"uniform mediump mat4 uP;\n";
|
||||
|
Loading…
Reference in New Issue
Block a user