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
22
shaders.cpp
22
shaders.cpp
@ -67,6 +67,9 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
|||||||
varying += "varying mediump vec4 vColor;\n";
|
varying += "varying mediump vec4 vColor;\n";
|
||||||
|
|
||||||
fmain += "gl_FragColor = vColor;\n";
|
fmain += "gl_FragColor = vColor;\n";
|
||||||
|
|
||||||
|
bool have_texture = false;
|
||||||
|
|
||||||
if(shader_flags & GF_TEXTURE_SHADED) {
|
if(shader_flags & GF_TEXTURE_SHADED) {
|
||||||
vsh += "attribute mediump vec3 aTexture;\n";
|
vsh += "attribute mediump vec3 aTexture;\n";
|
||||||
varying += "varying mediump vec3 vTexCoord;\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";
|
varying += "varying mediump vec2 vTexCoord;\n";
|
||||||
fsh += "uniform mediump sampler2D tTexture;\n";
|
fsh += "uniform mediump sampler2D tTexture;\n";
|
||||||
vmain += "vTexCoord = aTexture;\n",
|
vmain += "vTexCoord = aTexture;\n",
|
||||||
fmain += "gl_FragColor *= texture2D(tTexture, vTexCoord);\n";
|
have_texture = true;
|
||||||
}
|
}
|
||||||
if(shader_flags & GF_LEVELS) {
|
if(shader_flags & GF_LEVELS) {
|
||||||
fsh += "uniform mediump float uLevelLines;\n";
|
fsh += "uniform mediump float uLevelLines;\n";
|
||||||
@ -282,7 +285,7 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
|||||||
" pt.xy += vec2(.5, .5);\n"
|
" pt.xy += vec2(.5, .5);\n"
|
||||||
" return texture2D(tAirMap, pt.xy);\n"
|
" return texture2D(tAirMap, pt.xy);\n"
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
vmain +=
|
vmain +=
|
||||||
"vec4 ending = uRadarTransform * t;\n"
|
"vec4 ending = uRadarTransform * t;\n"
|
||||||
"float len = acosh(ending.w);\n"
|
"float len = acosh(ending.w);\n"
|
||||||
@ -300,6 +303,18 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
|||||||
"if(fogs < 0.) fogs = 0.;\n"
|
"if(fogs < 0.) fogs = 0.;\n"
|
||||||
"fog.xyz /= fog.w;\n"
|
"fog.xyz /= fog.w;\n"
|
||||||
"vColor.xyz = vColor.xyz * fogs + fog.xyz * (1.0-fogs);\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 != "") {
|
else if(distfun != "") {
|
||||||
vmain += "mediump float fogs = (uFogBase - " + distfun + " / uFog);\n";
|
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";
|
vmain += "gl_Position = uP * t;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(have_texture)
|
||||||
|
fmain += "gl_FragColor *= texture2D(tTexture, vTexCoord);\n";
|
||||||
|
|
||||||
vsh +=
|
vsh +=
|
||||||
"uniform mediump mat4 uMV;\n"
|
"uniform mediump mat4 uMV;\n"
|
||||||
"uniform mediump mat4 uP;\n";
|
"uniform mediump mat4 uP;\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user