Replies: 5 comments 11 replies
-
Sure, this sounds to make sense. Let me think. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Can I assign myself this? I'd like to familiarise myself with the parser. |
Beta Was this translation helpful? Give feedback.
1 reply
-
kage: discard gl: discard; metal:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
or is a function preferred? |
Beta Was this translation helpful? Give feedback.
9 replies
-
Kage Code: package shader
var Time float
var Cursor vec2
var ScreenSize vec2
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
col := vec4(1, 0, 0, 1)
if int(position.x)%2 == int(0) {
discard()
}
return col
} Emitted Code: #if defined(GL_ES)
precision highp float;
#else
#define lowp
#define mediump
#define highp
#endif
int modInt(int x, int y) {
return x - y*(x/y);
}
uniform vec2 U0;
uniform vec2 U1[4];
uniform vec2 U2;
uniform vec2 U3;
uniform vec2 U4[3];
uniform vec2 U5;
uniform vec2 U6;
uniform float U7;
uniform vec2 U8;
uniform vec2 U9;
uniform sampler2D T0;
uniform sampler2D T1;
uniform sampler2D T2;
uniform sampler2D T3;
varying vec2 V0;
varying vec4 V1;
void main(void) {
vec4 l0 = vec4(0);
l0 = vec4(1.0, 0.0, 0.0, 1.0);
if ((modInt((int((gl_FragCoord).x)), (2))) == (int(0.0))) {
discard;
}
gl_FragColor = l0;
return;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello~!
In working with Tetra3D, I've found I get visual glitches on certain (Intel?) GPUs if I don't return a vec4() color in my Fragment shader (an example can be seen in this issue here). Just to clarify, this is only even possible by using an if statement to return a vec4 in
Fragment()
, but not returning anything outside of that if statement, as can be seen in the below example:The reason I'm doing this is because I don't want to write a fragment unless the comparison returns true. The easiest way to not write a fragment in a GLSL shader is to use discard to discard the fragment, thereby not altering the texture the shader is writing to - whatever was originally below the fragment being altered is left alone, essentially.
Would it be feasible to add a
discard
statement / function to Kage? I believe I could make my own solution more efficient and work around this issue fairly easily, but I wanted ask becausediscard
can be useful when programming shaders.EDIT: I've resolved it, so this isn't a pressing issue. A
discard
statement could still be useful if it's supported by the shader backends that Kage supports, though~Beta Was this translation helpful? Give feedback.
All reactions