mirror of https://github.com/AxioDL/metaforce.git
Use frag_position in FOG_SHADER
This commit is contained in:
parent
73c7755e4c
commit
5c3267c69d
|
@ -518,52 +518,57 @@ using NoColorAttachment = NoColorAttachmentExt<AlphaWrite ? AlphaMode::AlphaWrit
|
||||||
|
|
||||||
#define FOG_SHADER(fog) \
|
#define FOG_SHADER(fog) \
|
||||||
float fogZ; \
|
float fogZ; \
|
||||||
float fogF = hsh::saturate(((fog).m_A / ((fog).m_B - this->position.z)) - (fog).m_C); \
|
{ \
|
||||||
switch ((fog).m_mode) { \
|
float fogF = hsh::saturate(((fog).m_A / ((fog).m_B - this->frag_position.z)) - (fog).m_C); \
|
||||||
case ERglFogMode::PerspLin: \
|
switch ((fog).m_mode) { \
|
||||||
fogZ = fogF; \
|
case ERglFogMode::PerspLin: \
|
||||||
break; \
|
fogZ = fogF; \
|
||||||
case ERglFogMode::PerspExp: \
|
break; \
|
||||||
fogZ = 1.0 - hsh::exp2(-8.0 * fogF); \
|
case ERglFogMode::PerspExp: \
|
||||||
break; \
|
fogZ = 1.0 - hsh::exp2(-8.0 * fogF); \
|
||||||
case ERglFogMode::PerspExp2: \
|
break; \
|
||||||
fogZ = 1.0 - hsh::exp2(-8.0 * fogF * fogF); \
|
case ERglFogMode::PerspExp2: \
|
||||||
break; \
|
fogZ = 1.0 - hsh::exp2(-8.0 * fogF * fogF); \
|
||||||
case ERglFogMode::PerspRevExp: \
|
break; \
|
||||||
fogZ = hsh::exp2(-8.0 * (1.0 - fogF)); \
|
case ERglFogMode::PerspRevExp: \
|
||||||
break; \
|
fogZ = hsh::exp2(-8.0 * (1.0 - fogF)); \
|
||||||
case ERglFogMode::PerspRevExp2: \
|
break; \
|
||||||
fogF = 1.0 - fogF; \
|
case ERglFogMode::PerspRevExp2: \
|
||||||
fogZ = hsh::exp2(-8.0 * fogF * fogF); \
|
fogF = 1.0 - fogF; \
|
||||||
break; \
|
fogZ = hsh::exp2(-8.0 * fogF * fogF); \
|
||||||
default: \
|
break; \
|
||||||
fogZ = 0.0; \
|
default: \
|
||||||
break; \
|
fogZ = 0.0; \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOG_SHADER_UNIFORM(fogUniBuf) \
|
#define FOG_SHADER_UNIFORM(fogUniBuf) \
|
||||||
float fogZ; \
|
float fogZ; \
|
||||||
float fogF = hsh::saturate(((fogUniBuf)->m_A / ((fogUniBuf)->m_B - this->position.z)) - (fogUniBuf)->m_C); \
|
{ \
|
||||||
switch ((fogUniBuf)->m_mode) { \
|
float fogF = \
|
||||||
case ERglFogMode::PerspLin: \
|
hsh::saturate(((fogUniBuf)->m_A / ((fogUniBuf)->m_B - this->frag_position.z)) - (fogUniBuf)->m_C); \
|
||||||
fogZ = fogF; \
|
switch ((fogUniBuf)->m_mode) { \
|
||||||
break; \
|
case ERglFogMode::PerspLin: \
|
||||||
case ERglFogMode::PerspExp: \
|
fogZ = fogF; \
|
||||||
fogZ = 1.0 - hsh::exp2(-8.0 * fogF); \
|
break; \
|
||||||
break; \
|
case ERglFogMode::PerspExp: \
|
||||||
case ERglFogMode::PerspExp2: \
|
fogZ = 1.0 - hsh::exp2(-8.0 * fogF); \
|
||||||
fogZ = 1.0 - hsh::exp2(-8.0 * fogF * fogF); \
|
break; \
|
||||||
break; \
|
case ERglFogMode::PerspExp2: \
|
||||||
case ERglFogMode::PerspRevExp: \
|
fogZ = 1.0 - hsh::exp2(-8.0 * fogF * fogF); \
|
||||||
fogZ = hsh::exp2(-8.0 * (1.0 - fogF)); \
|
break; \
|
||||||
break; \
|
case ERglFogMode::PerspRevExp: \
|
||||||
case ERglFogMode::PerspRevExp2: \
|
fogZ = hsh::exp2(-8.0 * (1.0 - fogF)); \
|
||||||
fogF = 1.0 - fogF; \
|
break; \
|
||||||
fogZ = hsh::exp2(-8.0 * fogF * fogF); \
|
case ERglFogMode::PerspRevExp2: \
|
||||||
break; \
|
fogF = 1.0 - fogF; \
|
||||||
default: \
|
fogZ = hsh::exp2(-8.0 * fogF * fogF); \
|
||||||
fogZ = 0.0; \
|
break; \
|
||||||
break; \
|
default: \
|
||||||
|
fogZ = 0.0; \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOG_OUT(out, fog, colorIn) \
|
#define FOG_OUT(out, fog, colorIn) \
|
||||||
|
|
|
@ -25,8 +25,6 @@ struct CEnvFxShadersPipeline
|
||||||
hsh::float4 color = vbo->color * envFxUniBuf->moduColor * flakeTexel * envTexel;
|
hsh::float4 color = vbo->color * envFxUniBuf->moduColor * flakeTexel * envTexel;
|
||||||
this->position = envFxUniBuf->proj * (envFxUniBuf->mv * posIn);
|
this->position = envFxUniBuf->proj * (envFxUniBuf->mv * posIn);
|
||||||
FOG_SHADER_UNIFORM(fogUniBuf)
|
FOG_SHADER_UNIFORM(fogUniBuf)
|
||||||
// FIXME: hsh binds fog uniform to fragment stage
|
|
||||||
// only because of m_color reference in here. can/should we avoid that?
|
|
||||||
FOG_OUT_UNIFORM(this->color_out[0], fogUniBuf, color)
|
FOG_OUT_UNIFORM(this->color_out[0], fogUniBuf, color)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue