Line data Source code
1 : /**
2 : Copyright (c) 2023 Stappler LLC <admin@stappler.dev>
3 :
4 : Permission is hereby granted, free of charge, to any person obtaining a copy
5 : of this software and associated documentation files (the "Software"), to deal
6 : in the Software without restriction, including without limitation the rights
7 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 : copies of the Software, and to permit persons to whom the Software is
9 : furnished to do so, subject to the following conditions:
10 :
11 : The above copyright notice and this permission notice shall be included in
12 : all copies or substantial portions of the Software.
13 :
14 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 : THE SOFTWARE.
21 : **/
22 :
23 : #ifndef XENOLITH_RENDERER_BASIC2D_GLSL_INCLUDE_XL2DGLSLDATA_H_
24 : #define XENOLITH_RENDERER_BASIC2D_GLSL_INCLUDE_XL2DGLSLDATA_H_
25 :
26 : #include "SPGlsl.h"
27 :
28 : #ifndef SP_GLSL
29 : namespace STAPPLER_VERSIONIZED stappler::glsl {
30 : #endif
31 :
32 : #define XL_GLSL_MATERIAL_FLAG_HAS_ATLAS_INDEX 1
33 : #define XL_GLSL_MATERIAL_FLAG_HAS_ATLAS_DATA 2
34 : #define XL_GLSL_MATERIAL_FLAG_HAS_ATLAS 3 // (XL_GLSL_MATERIAL_FLAG_HAS_ATLAS_INDEX | XL_GLSL_MATERIAL_FLAG_HAS_ATLAS_DATA)
35 : #define XL_GLSL_MATERIAL_FLAG_ATLAS_POW2_INDEX_BIT_OFFSET 24
36 :
37 : struct Vertex {
38 : vec4 pos;
39 : vec4 color;
40 : vec2 tex;
41 : uint material;
42 : uint object;
43 : };
44 :
45 : struct MaterialData {
46 : uint samplerImageIdx;
47 : uint setIdx;
48 : uint atlasIdx;
49 : uint flags;
50 : uint gradient;
51 : uint padding0;
52 : uint padding1;
53 : uint padding2;
54 : };
55 :
56 : struct TransformData {
57 : mat4 transform;
58 : vec4 mask;
59 : vec4 offset;
60 : vec4 shadow;
61 : vec4 padding;
62 :
63 : #ifndef SP_GLSL
64 5745 : TransformData() :
65 5745 : transform(mat4::IDENTITY),
66 5745 : mask(vec4(1.0f, 1.0f, 0.0f, 0.0f)),
67 5745 : offset(vec4(0.0f, 0.0f, 0.0f, 1.0f)),
68 5745 : shadow(vec4::ZERO)
69 5745 : { }
70 :
71 122805 : TransformData(const mat4 &m) :
72 122805 : transform(m),
73 122805 : mask(vec4(1.0f, 1.0f, 0.0f, 0.0f)),
74 122793 : offset(vec4(0.0f, 0.0f, 0.0f, 1.0f)),
75 122796 : shadow(vec4::ZERO)
76 122794 : { }
77 : #endif
78 : };
79 :
80 : struct DataAtlasIndex {
81 : uint key;
82 : uint value;
83 : };
84 :
85 : struct DataAtlasValue {
86 : vec2 pos;
87 : vec2 tex;
88 : };
89 :
90 : #ifndef SP_GLSL
91 : }
92 : #endif
93 :
94 : #endif /* XENOLITH_RENDERER_BASIC2D_GLSL_INCLUDE_XL2DGLSLDATA_H_ */
|