| 1 |
#include "drivers/gles3/shader_gles3.h" |
| 2 |
|
| 3 |
class VertexFragmentShaderGLES3 : public ShaderGLES3 { |
| 4 |
public: |
| 5 |
enum ShaderVariant { |
| 6 |
MODE_NINEPATCH, |
| 7 |
}; |
| 8 |
|
| 9 |
enum Specializations { |
| 10 |
DISABLE_LIGHTING = 1, |
| 11 |
}; |
| 12 |
|
| 13 |
_FORCE_INLINE_ bool version_bind_shader(RID p_version, ShaderVariant p_variant, uint64_t p_specialization = 0) { |
| 14 |
return _version_bind_shader(p_version, p_variant, p_specialization); |
| 15 |
} |
| 16 |
|
| 17 |
protected: |
| 18 |
virtual void _init() override { |
| 19 |
static const char **_uniform_strings = nullptr; |
| 20 |
static const char *_variant_defines[] = { |
| 21 |
"#define USE_NINEPATCH", |
| 22 |
}; |
| 23 |
static TexUnitPair *_texunit_pairs = nullptr; |
| 24 |
static UBOPair *_ubo_pairs = nullptr; |
| 25 |
static Specialization _spec_pairs[] = { |
| 26 |
{ "DISABLE_LIGHTING", false }, |
| 27 |
}; |
| 28 |
static const Feedback *_feedbacks = nullptr; |
| 29 |
static const char _vertex_code[] = { |
| 30 |
R"<!>( |
| 31 |
precision highp float; |
| 32 |
precision highp int; |
| 33 |
/* clang-format on */ |
| 34 |
layout(location = 0) in highp vec3 vertex; |
| 35 |
|
| 36 |
out highp vec4 position_interp; |
| 37 |
|
| 38 |
void main() { |
| 39 |
position_interp = vec4(vertex.x, 1, 0, 1); |
| 40 |
} |
| 41 |
|
| 42 |
)<!>" |
| 43 |
}; |
| 44 |
|
| 45 |
static const char _fragment_code[] = { |
| 46 |
R"<!>( |
| 47 |
precision highp float; |
| 48 |
precision highp int; |
| 49 |
|
| 50 |
in highp vec4 position_interp; |
| 51 |
|
| 52 |
void main() { |
| 53 |
highp float depth = ((position_interp.z / position_interp.w) + 1.0); |
| 54 |
frag_color = vec4(depth); |
| 55 |
} |
| 56 |
)<!>" |
| 57 |
}; |
| 58 |
|
| 59 |
_setup(_vertex_code, _fragment_code, "VertexFragmentShaderGLES3", |
| 60 |
0, _uniform_strings, 0, _ubo_pairs, |
| 61 |
0, _feedbacks, 0, _texunit_pairs, |
| 62 |
1, _spec_pairs, 1, _variant_defines); |
| 63 |
} |
| 64 |
}; |