12 #ifndef hifi_LightingModel_h
13 #define hifi_LightingModel_h
15 #include <gpu/Resource.h>
17 #include <render/Forward.h>
18 #include <render/DrawTask.h>
23 using UniformBufferView = gpu::BufferView;
28 void setUnlit(
bool enable);
29 bool isUnlitEnabled()
const;
31 void setEmissive(
bool enable);
32 bool isEmissiveEnabled()
const;
33 void setLightmap(
bool enable);
34 bool isLightmapEnabled()
const;
36 void setBackground(
bool enable);
37 bool isBackgroundEnabled()
const;
39 void setHaze(
bool enable);
40 bool isHazeEnabled()
const;
41 void setBloom(
bool enable);
42 bool isBloomEnabled()
const;
44 void setObscurance(
bool enable);
45 bool isObscuranceEnabled()
const;
47 void setScattering(
bool enable);
48 bool isScatteringEnabled()
const;
49 void setDiffuse(
bool enable);
50 bool isDiffuseEnabled()
const;
51 void setSpecular(
bool enable);
52 bool isSpecularEnabled()
const;
54 void setAlbedo(
bool enable);
55 bool isAlbedoEnabled()
const;
57 void setMaterialTexturing(
bool enable);
58 bool isMaterialTexturingEnabled()
const;
60 void setAmbientLight(
bool enable);
61 bool isAmbientLightEnabled()
const;
62 void setDirectionalLight(
bool enable);
63 bool isDirectionalLightEnabled()
const;
64 void setPointLight(
bool enable);
65 bool isPointLightEnabled()
const;
66 void setSpotLight(
bool enable);
67 bool isSpotLightEnabled()
const;
69 void setShowLightContour(
bool enable);
70 bool isShowLightContourEnabled()
const;
72 void setWireframe(
bool enable);
73 bool isWireframeEnabled()
const;
74 void setSkinning(
bool enable);
75 bool isSkinningEnabled()
const;
76 void setBlendshape(
bool enable);
77 bool isBlendshapeEnabled()
const;
80 void setAmbientOcclusion(
bool enable);
81 bool isAmbientOcclusionEnabled()
const;
82 void setShadow(
bool enable);
83 bool isShadowEnabled()
const;
85 UniformBufferView getParametersBuffer()
const {
return _parametersBuffer; }
86 gpu::TexturePointer getAmbientFresnelLUT()
const {
return _ambientFresnelLUT; }
95 float enableUnlit{ 1.0f };
96 float enableEmissive{ 1.0f };
97 float enableLightmap{ 1.0f };
98 float enableBackground{ 1.0f };
100 float enableScattering{ 1.0f };
101 float enableDiffuse{ 1.0f };
102 float enableSpecular{ 1.0f };
103 float enableAlbedo{ 1.0f };
105 float enableAmbientLight{ 1.0f };
106 float enableDirectionalLight{ 1.0f };
107 float enablePointLight{ 1.0f };
108 float enableSpotLight{ 1.0f };
110 float showLightContour { 0.0f };
112 float enableObscurance{ 1.0f };
114 float enableMaterialTexturing { 1.0f };
115 float enableWireframe { 0.0f };
117 float enableHaze{ 1.0f };
118 float enableBloom{ 1.0f };
119 float enableSkinning{ 1.0f };
120 float enableBlendshape{ 1.0f };
122 float enableAmbientOcclusion{ 0.0f };
123 float enableShadow{ 1.0f };
124 float spare1{ 1.0f };
125 float spare2{ 1.0f };
129 UniformBufferView _parametersBuffer;
130 static gpu::TexturePointer _ambientFresnelLUT;
133 using LightingModelPointer = std::shared_ptr<LightingModel>;
138 class MakeLightingModelConfig :
public render::Job::Config {
141 Q_PROPERTY(
bool enableUnlit MEMBER enableUnlit NOTIFY dirty)
142 Q_PROPERTY(
bool enableEmissive MEMBER enableEmissive NOTIFY dirty)
143 Q_PROPERTY(
bool enableLightmap MEMBER enableLightmap NOTIFY dirty)
144 Q_PROPERTY(
bool enableBackground MEMBER enableBackground NOTIFY dirty)
145 Q_PROPERTY(
bool enableHaze MEMBER enableHaze NOTIFY dirty)
147 Q_PROPERTY(
bool enableObscurance MEMBER enableObscurance NOTIFY dirty)
149 Q_PROPERTY(
bool enableScattering MEMBER enableScattering NOTIFY dirty)
150 Q_PROPERTY(
bool enableDiffuse MEMBER enableDiffuse NOTIFY dirty)
151 Q_PROPERTY(
bool enableSpecular MEMBER enableSpecular NOTIFY dirty)
152 Q_PROPERTY(
bool enableAlbedo MEMBER enableAlbedo NOTIFY dirty)
154 Q_PROPERTY(
bool enableMaterialTexturing MEMBER enableMaterialTexturing NOTIFY dirty)
156 Q_PROPERTY(
bool enableAmbientLight MEMBER enableAmbientLight NOTIFY dirty)
157 Q_PROPERTY(
bool enableDirectionalLight MEMBER enableDirectionalLight NOTIFY dirty)
158 Q_PROPERTY(
bool enablePointLight MEMBER enablePointLight NOTIFY dirty)
159 Q_PROPERTY(
bool enableSpotLight MEMBER enableSpotLight NOTIFY dirty)
161 Q_PROPERTY(
bool enableWireframe MEMBER enableWireframe NOTIFY dirty)
162 Q_PROPERTY(
bool showLightContour MEMBER showLightContour NOTIFY dirty)
164 Q_PROPERTY(
bool enableBloom MEMBER enableBloom NOTIFY dirty)
165 Q_PROPERTY(
bool enableSkinning MEMBER enableSkinning NOTIFY dirty)
166 Q_PROPERTY(
bool enableBlendshape MEMBER enableBlendshape NOTIFY dirty)
168 Q_PROPERTY(
bool enableAmbientOcclusion READ isAmbientOcclusionEnabled WRITE setAmbientOcclusion NOTIFY dirty)
169 Q_PROPERTY(
bool enableShadow READ isShadowEnabled WRITE setShadow NOTIFY dirty)
173 MakeLightingModelConfig() : render::Job::Config() {}
175 bool enableUnlit{
true };
176 bool enableEmissive{
true };
177 bool enableLightmap{
true };
178 bool enableBackground{
true };
179 bool enableObscurance{
true };
181 bool enableScattering{
true };
182 bool enableDiffuse{
true };
183 bool enableSpecular{
true };
185 bool enableAlbedo{
true };
186 bool enableMaterialTexturing {
true };
188 bool enableAmbientLight{
true };
189 bool enableDirectionalLight{
true };
190 bool enablePointLight{
true };
191 bool enableSpotLight{
true };
193 bool showLightContour {
false };
195 bool enableWireframe {
false };
196 bool enableHaze{
true };
197 bool enableBloom{
true };
198 bool enableSkinning{
true };
199 bool enableBlendshape{
true };
201 bool enableAmbientOcclusion{
false };
202 bool enableShadow{
true };
205 void setAmbientOcclusion(
bool enable) { enableAmbientOcclusion = enable; emit dirty();}
206 bool isAmbientOcclusionEnabled()
const {
return enableAmbientOcclusion; }
207 void setShadow(
bool enable) { enableShadow = enable; emit dirty(); }
208 bool isShadowEnabled()
const {
return enableShadow; }
214 class MakeLightingModel {
216 using Config = MakeLightingModelConfig;
217 using JobModel = render::Job::ModelO<MakeLightingModel, LightingModelPointer, Config>;
221 void configure(
const Config& config);
222 void run(
const render::RenderContextPointer& renderContext, LightingModelPointer& lightingModel);
225 LightingModelPointer _lightingModel;