@@ -16,9 +16,11 @@ namespace OverEngine
1616
1717 Color a_Color = Color(1 .0f );
1818 int a_TexSlot = -1 ;
19- Vector4 a_TexCoord = Vector4(0 . 0f );
19+ Vector4 a_TexCoord = Vector4(0 , 0 , 1 , 1 );
2020 Vector4 a_TexRegion = Vector4(0 .0f );
2121 int a_TexRepeat = 0 ;
22+
23+ int a_LiquidGlass = false ;
2224 };
2325
2426 // Hard-coded Limits
@@ -66,7 +68,9 @@ namespace OverEngine
6668 { ShaderDataType::Int, " a_TexSlot" },
6769 { ShaderDataType::Float4, " a_TexCoord" },
6870 { ShaderDataType::Float4, " a_TexRegion" },
69- { ShaderDataType::Int, " a_TexRepeat" }
71+ { ShaderDataType::Int, " a_TexRepeat" },
72+
73+ { ShaderDataType::Int, " a_LiquidGlass" }
7074 });
7175 s_Data->QuadVA ->AddVertexBuffer (s_Data->QuadVB );
7276
@@ -87,15 +91,7 @@ namespace OverEngine
8791 s_Data->QuadBufferPtr = s_Data->QuadBufferBasePtr ;
8892
8993 s_Data->Shader = Shader::Create (" assets/shaders/BatchRenderer2D.glsl" );
90- {
91- int textureIDs[MaxTextureCount];
92-
93- for (int i = 0 ; i < (int )MaxTextureCount; i++)
94- textureIDs[i] = i;
95-
96- s_Data->Shader ->Bind ();
97- s_Data->Shader ->UploadUniformIntArray (" u_Slots" , textureIDs, MaxTextureCount);
98- }
94+ InitShader ();
9995
10096 s_Statistics.Reset ();
10197 }
@@ -111,6 +107,22 @@ namespace OverEngine
111107 return s_Data->Shader ;
112108 }
113109
110+ void Renderer2D::ReloadShader ()
111+ {
112+ s_Data->Shader ->Reload ();
113+ InitShader ();
114+ }
115+
116+ void Renderer2D::InitShader ()
117+ {
118+ int textureIDs[MaxTextureCount];
119+ for (int i = 0 ; i < (int )MaxTextureCount; i++)
120+ textureIDs[i] = i;
121+
122+ s_Data->Shader ->Bind ();
123+ s_Data->Shader ->UploadUniformIntArray (" u_Slots" , textureIDs, MaxTextureCount);
124+ }
125+
114126 void Renderer2D::Reset ()
115127 {
116128 s_Data->QuadBufferPtr = s_Data->QuadBufferBasePtr ;
@@ -188,17 +200,17 @@ namespace OverEngine
188200 DrawQuad (Vector3 (position, 0 .0f ), rotation, size, color);
189201 }
190202
191- void Renderer2D::DrawQuad (const Vector3& position, float rotation, const Vector2& size, const Color& color)
203+ void Renderer2D::DrawQuad (const Vector3& position, float rotation, const Vector2& size, const Color& color, int liquidGlass )
192204 {
193205 Mat4x4 transform =
194206 glm::translate (Mat4x4 (1 .0f ), position) *
195207 glm::rotate (Mat4x4 (1 .0f ), rotation, Vector3 (0 , 0 , 1 )) *
196208 glm::scale (Mat4x4 (1 .0f ), Vector3 (size, 1 .0f ));
197209
198- DrawQuad (transform, color);
210+ DrawQuad (transform, color, liquidGlass );
199211 }
200212
201- void Renderer2D::DrawQuad (const Mat4x4& transform, const Color& color)
213+ void Renderer2D::DrawQuad (const Mat4x4& transform, const Color& color, int liquidGlass )
202214 {
203215 if (color.a == 0 )
204216 return ;
@@ -212,10 +224,18 @@ namespace OverEngine
212224 s_Data->QuadBufferPtr ->a_Position1 = Vector3 (mat * Vector4 ( 0.5 , -0.5 , 0.0 , 1.0 ));
213225 s_Data->QuadBufferPtr ->a_Position2 = Vector3 (mat * Vector4 (-0.5 , 0.5 , 0.0 , 1.0 ));
214226 s_Data->QuadBufferPtr ->a_Position3 = Vector3 (mat * Vector4 ( 0.5 , 0.5 , 0.0 , 1.0 ));
215-
227+
228+ // OE_CORE_INFO("Emitting {}: ({}, {}) ({}, {}) ({}, {}) ({}, {})", liquidGlass,
229+ // s_Data->QuadBufferPtr->a_Position0.x, s_Data->QuadBufferPtr->a_Position0.y,
230+ // s_Data->QuadBufferPtr->a_Position1.x, s_Data->QuadBufferPtr->a_Position1.y,
231+ // s_Data->QuadBufferPtr->a_Position2.x, s_Data->QuadBufferPtr->a_Position2.y,
232+ // s_Data->QuadBufferPtr->a_Position3.x, s_Data->QuadBufferPtr->a_Position3.y);
233+
216234 s_Data->QuadBufferPtr ->a_Color = color;
217235 s_Data->QuadBufferPtr ->a_TexSlot = -1 ;
218236
237+ s_Data->QuadBufferPtr ->a_LiquidGlass = liquidGlass;
238+
219239 s_Data->QuadBufferPtr ++;
220240 s_Data->QuadCount ++;
221241 s_Statistics.QuadCount ++;
@@ -259,7 +279,7 @@ namespace OverEngine
259279 if (it == end)
260280 {
261281 uint8_t slot = s_Data->TextureCount ;
262- if (slot + 1u > RenderCommand::GetMaxTextureSlotCount () )
282+ if (slot + 1u > MaxTextureCount )
263283 {
264284 NextBatch ();
265285 slot = 0 ;
0 commit comments