@@ -88,6 +88,13 @@ void OvEditor::Core::EditorRenderer::InitMaterials()
88
88
m_cameraMaterial.Set (" u_Diffuse" , FVector4 (0 .0f , 0 .3f , 0 .7f , 1 .0f ));
89
89
m_cameraMaterial.Set <OvRendering::Resources::Texture*>(" u_DiffuseMap" , nullptr );
90
90
91
+ /* Light Material */
92
+ m_lightMaterial.SetShader (m_context.editorResources ->GetShader (" Billboard" ));
93
+ m_lightMaterial.Set (" u_Diffuse" , FVector4 (1 .f , 1 .f , 0 .5f , 0 .5f ));
94
+ m_lightMaterial.SetBackfaceCulling (false );
95
+ m_lightMaterial.SetBlendable (true );
96
+ m_lightMaterial.SetDepthTest (false );
97
+
91
98
/* Stencil Fill Material */
92
99
m_stencilFillMaterial.SetShader (m_context.shaderManager [" :Shaders\\ Unlit.glsl" ]);
93
100
m_stencilFillMaterial.SetBackfaceCulling (true );
@@ -133,14 +140,14 @@ void OvEditor::Core::EditorRenderer::InitMaterials()
133
140
m_actorPickingMaterial.SetBackfaceCulling (false );
134
141
}
135
142
136
- void OvEditor::Core::EditorRenderer::PreparePickingMaterial (OvCore::ECS::Actor& p_actor)
143
+ void OvEditor::Core::EditorRenderer::PreparePickingMaterial (OvCore::ECS::Actor& p_actor, OvCore::Resources::Material& p_material )
137
144
{
138
145
uint32_t actorID = static_cast <uint32_t >(p_actor.GetID ());
139
146
140
147
auto bytes = reinterpret_cast <uint8_t *>(&actorID);
141
148
auto color = FVector4{ bytes[0 ] / 255 .0f , bytes[1 ] / 255 .0f , bytes[2 ] / 255 .0f , 1 .0f };
142
149
143
- m_actorPickingMaterial .Set (" u_Diffuse" , color);
150
+ p_material .Set (" u_Diffuse" , color);
144
151
}
145
152
146
153
OvMaths::FMatrix4 OvEditor::Core::EditorRenderer::CalculateCameraModelMatrix (OvCore::ECS::Actor& p_actor)
@@ -178,7 +185,7 @@ void OvEditor::Core::EditorRenderer::RenderSceneForActorPicking()
178
185
const OvCore::ECS::Components::CMaterialRenderer::MaterialList& materials = materialRenderer->GetMaterials ();
179
186
const auto & modelMatrix = actor.transform .GetWorldMatrix ();
180
187
181
- PreparePickingMaterial (actor);
188
+ PreparePickingMaterial (actor, m_actorPickingMaterial );
182
189
183
190
for (auto mesh : model->GetMeshes ())
184
191
{
@@ -214,13 +221,36 @@ void OvEditor::Core::EditorRenderer::RenderSceneForActorPicking()
214
221
215
222
if (actor.IsActive ())
216
223
{
217
- PreparePickingMaterial (actor);
224
+ PreparePickingMaterial (actor, m_actorPickingMaterial );
218
225
auto & model = *m_context.editorResources ->GetModel (" Camera" );
219
226
auto modelMatrix = CalculateCameraModelMatrix (actor);
220
227
221
228
m_context.renderer ->DrawModelWithSingleMaterial (model, m_actorPickingMaterial, &modelMatrix);
222
229
}
223
230
}
231
+
232
+ /* Render lights */
233
+ if (Settings::EditorSettings::LightBillboardScale > 0 .001f )
234
+ {
235
+ m_context.renderer ->Clear (false , true , false );
236
+
237
+ m_lightMaterial.SetDepthTest (true );
238
+ m_lightMaterial.Set <float >(" u_Scale" , Settings::EditorSettings::LightBillboardScale * 0 .1f );
239
+ m_lightMaterial.Set <OvRendering::Resources::Texture*>(" u_DiffuseMap" , nullptr );
240
+
241
+ for (auto light : m_context.sceneManager .GetCurrentScene ()->GetFastAccessComponents ().lights )
242
+ {
243
+ auto & actor = light->owner ;
244
+
245
+ if (actor.IsActive ())
246
+ {
247
+ PreparePickingMaterial (actor, m_lightMaterial);
248
+ auto & model = *m_context.editorResources ->GetModel (" Vertical_Plane" );
249
+ auto modelMatrix = FMatrix4::Translation (actor.transform .GetWorldPosition ());
250
+ m_context.renderer ->DrawModelWithSingleMaterial (model, m_lightMaterial, &modelMatrix);
251
+ }
252
+ }
253
+ }
224
254
}
225
255
226
256
void OvEditor::Core::EditorRenderer::RenderUI ()
@@ -246,6 +276,41 @@ void OvEditor::Core::EditorRenderer::RenderCameras()
246
276
}
247
277
}
248
278
279
+ void OvEditor::Core::EditorRenderer::RenderLights ()
280
+ {
281
+ using namespace OvMaths ;
282
+
283
+ m_lightMaterial.SetDepthTest (false );
284
+ m_lightMaterial.Set <float >(" u_Scale" , Settings::EditorSettings::LightBillboardScale * 0 .1f );
285
+
286
+ for (auto light : m_context.sceneManager .GetCurrentScene ()->GetFastAccessComponents ().lights )
287
+ {
288
+ auto & actor = light->owner ;
289
+
290
+ if (actor.IsActive ())
291
+ {
292
+ auto & model = *m_context.editorResources ->GetModel (" Vertical_Plane" );
293
+ auto modelMatrix = FMatrix4::Translation (actor.transform .GetWorldPosition ());
294
+
295
+ OvRendering::Resources::Texture* texture = nullptr ;
296
+
297
+ switch (static_cast <OvRendering::Entities::Light::Type>(static_cast <int >(light->GetData ().type )))
298
+ {
299
+ case OvRendering::Entities::Light::Type::POINT: texture = m_context.editorResources ->GetTexture (" Bill_Point_Light" ); break ;
300
+ case OvRendering::Entities::Light::Type::SPOT: texture = m_context.editorResources ->GetTexture (" Bill_Spot_Light" ); break ;
301
+ case OvRendering::Entities::Light::Type::DIRECTIONAL: texture = m_context.editorResources ->GetTexture (" Bill_Directional_Light" ); break ;
302
+ case OvRendering::Entities::Light::Type::AMBIENT_BOX: texture = m_context.editorResources ->GetTexture (" Bill_Ambient_Box_Light" ); break ;
303
+ case OvRendering::Entities::Light::Type::AMBIENT_SPHERE: texture = m_context.editorResources ->GetTexture (" Bill_Ambient_Sphere_Light" ); break ;
304
+ }
305
+
306
+ const auto & lightColor = light->GetColor ();
307
+ m_lightMaterial.Set <OvRendering::Resources::Texture*>(" u_DiffuseMap" , texture);
308
+ m_lightMaterial.Set <OvMaths::FVector4>(" u_Diffuse" , OvMaths::FVector4 (lightColor.x , lightColor.y , lightColor.z , 0 .75f ));
309
+ m_context.renderer ->DrawModelWithSingleMaterial (model, m_lightMaterial, &modelMatrix);
310
+ }
311
+ }
312
+ }
313
+
249
314
void OvEditor::Core::EditorRenderer::RenderGizmo (const OvMaths::FVector3& p_position, const OvMaths::FQuaternion& p_rotation, OvEditor::Core::EGizmoOperation p_operation, bool p_pickable)
250
315
{
251
316
using namespace OvMaths ;
0 commit comments