mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-24 14:06:29 +01:00
Discard discard
- Do not guard discard predicate on a compile definition because it doesn't matter for ubershaders.
This commit is contained in:
parent
78975e8cad
commit
a8067d388d
6 changed files with 7 additions and 12 deletions
|
@ -21,13 +21,12 @@ import com.jozufozu.flywheel.glsl.generate.GlslSwitch;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class MaterialAdapterComponent implements SourceComponent {
|
||||
// TODO: material id handling in pipeline shader
|
||||
private final ResourceLocation name;
|
||||
private final GlslExpr switchArg;
|
||||
private final List<AdaptedFn> functionsToAdapt;
|
||||
private final List<StringSubstitutionSourceComponent> adaptedComponents;
|
||||
|
||||
public MaterialAdapterComponent(ResourceLocation name, GlslExpr switchArg, List<AdaptedFn> functionsToAdapt, List<StringSubstitutionSourceComponent> adaptedComponents) {
|
||||
private MaterialAdapterComponent(ResourceLocation name, GlslExpr switchArg, List<AdaptedFn> functionsToAdapt, List<StringSubstitutionSourceComponent> adaptedComponents) {
|
||||
this.name = name;
|
||||
this.switchArg = switchArg;
|
||||
this.functionsToAdapt = functionsToAdapt;
|
||||
|
|
|
@ -29,10 +29,7 @@ vec2 flw_fragLight;
|
|||
vec4 flw_fogFilter(vec4 color);
|
||||
|
||||
/*
|
||||
* May be implemented by materials.
|
||||
* If implemented, a material must define FLW_DISCARD
|
||||
*
|
||||
* Guard calls with FLW_DISCARD
|
||||
* Must be implemented by materials.
|
||||
*/
|
||||
bool flw_discardPredicate(vec4 finalColor);
|
||||
#endif
|
||||
|
|
|
@ -34,11 +34,9 @@ void flw_initFragment() {
|
|||
void flw_contextFragment() {
|
||||
vec4 color = flw_fragColor;
|
||||
|
||||
#ifdef FLW_DISCARD
|
||||
if (flw_discardPredicate(color)) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
fragColor = flw_fogFilter(color);
|
||||
}
|
||||
|
|
|
@ -28,11 +28,9 @@ void flw_contextFragment() {
|
|||
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
|
||||
color *= lightColor;
|
||||
|
||||
#ifdef FLW_DISCARD
|
||||
if (flw_discardPredicate(color)) {
|
||||
if (flw_discardPredicate(color)) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
fragColor = flw_fogFilter(color);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
void flw_materialFragment() {
|
||||
}
|
||||
|
||||
#define FLW_DISCARD
|
||||
bool flw_discardPredicate(vec4 finalColor) {
|
||||
return finalColor.a < 0.1;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
void flw_materialFragment() {
|
||||
}
|
||||
|
||||
bool flw_discardPredicate(vec4 finalColor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vec4 flw_fogFilter(vec4 color) {
|
||||
return linear_fog(color, flw_distance, flywheel.fogRange.x, flywheel.fogRange.y, flywheel.fogColor);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue