13 #ifndef hifi_LightingModel_h
14 #define hifi_LightingModel_h
16 #include <gpu/Resource.h>
18 #include <render/Forward.h>
19 #include <render/DrawTask.h>
24 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;
79 void setAmbientOcclusion(
bool enable);
80 bool isAmbientOcclusionEnabled()
const;
81 void setLocalLightingEnabled(
bool enable);
82 bool isLocalLightingEnabled()
const;
83 void setShadow(
bool enable);
84 bool isShadowEnabled()
const;
86 void setNormalMapAttenuation(
float min,
float max);
88 UniformBufferView getParametersBuffer()
const {
return _parametersBuffer; }
89 gpu::TexturePointer getAmbientFresnelLUT()
const {
return _ambientFresnelLUT; }
92 bool _enableLocalLighting {
true };
98 float enableUnlit { 1.0f };
99 float enableEmissive { 1.0f };
100 float enableLightmap { 1.0f };
101 float enableBackground { 1.0f };
103 float enableScattering { 1.0f };
104 float enableDiffuse { 1.0f };
105 float enableSpecular { 1.0f };
106 float enableAlbedo { 1.0f };
108 float enableAmbientLight { 1.0f };
109 float enableDirectionalLight { 1.0f };
110 float enablePointLight { 1.0f };
111 float enableSpotLight { 1.0f };
113 float showLightContour { 0.0f };
115 float enableObscurance { 1.0f };
117 float enableMaterialTexturing { 1.0f };
118 float enableWireframe { 0.0f };
120 float enableHaze { 1.0f };
121 float enableBloom { 1.0f };
122 float enableSkinning { 1.0f };
123 float enableBlendshape { 1.0f };
125 float enableAmbientOcclusion { 1.0f };
126 float enableShadow { 1.0f };
127 float normalMapAttenuationMin { 1.0f };
128 float normalMapAttenuationMax { 1.0f };
132 UniformBufferView _parametersBuffer;
133 static gpu::TexturePointer _ambientFresnelLUT;
135 using LightingModelPointer = std::shared_ptr<LightingModel>;
137 class MakeLightingModelConfig :
public render::Job::Config {
140 Q_PROPERTY(
bool enableUnlit MEMBER enableUnlit NOTIFY dirty)
141 Q_PROPERTY(
bool enableEmissive MEMBER enableEmissive NOTIFY dirty)
142 Q_PROPERTY(
bool enableLightmap MEMBER enableLightmap NOTIFY dirty)
143 Q_PROPERTY(
bool enableBackground MEMBER enableBackground NOTIFY dirty)
144 Q_PROPERTY(
bool enableHaze MEMBER enableHaze NOTIFY dirty)
146 Q_PROPERTY(
bool enableObscurance MEMBER enableObscurance NOTIFY dirty)
148 Q_PROPERTY(
bool enableScattering MEMBER enableScattering NOTIFY dirty)
149 Q_PROPERTY(
bool enableDiffuse MEMBER enableDiffuse NOTIFY dirty)
150 Q_PROPERTY(
bool enableSpecular MEMBER enableSpecular NOTIFY dirty)
151 Q_PROPERTY(
bool enableAlbedo MEMBER enableAlbedo NOTIFY dirty)
153 Q_PROPERTY(
bool enableMaterialTexturing MEMBER enableMaterialTexturing NOTIFY dirty)
155 Q_PROPERTY(
bool enableAmbientLight MEMBER enableAmbientLight NOTIFY dirty)
156 Q_PROPERTY(
bool enableDirectionalLight MEMBER enableDirectionalLight NOTIFY dirty)
157 Q_PROPERTY(
bool enablePointLight MEMBER enablePointLight NOTIFY dirty)
158 Q_PROPERTY(
bool enableSpotLight MEMBER enableSpotLight NOTIFY dirty)
160 Q_PROPERTY(
bool enableWireframe MEMBER enableWireframe NOTIFY dirty)
161 Q_PROPERTY(
bool showLightContour MEMBER showLightContour NOTIFY dirty)
163 Q_PROPERTY(
bool enableBloom MEMBER enableBloom NOTIFY dirty)
164 Q_PROPERTY(
bool enableSkinning MEMBER enableSkinning NOTIFY dirty)
165 Q_PROPERTY(
bool enableBlendshape MEMBER enableBlendshape NOTIFY dirty)
167 Q_PROPERTY(
bool enableAmbientOcclusion READ isAmbientOcclusionEnabled WRITE setAmbientOcclusion NOTIFY dirty)
168 Q_PROPERTY(
bool enableLocalLighting READ isLocalLightingEnabled WRITE setLocalLighting NOTIFY dirty)
169 Q_PROPERTY(
bool enableShadow READ isShadowEnabled WRITE setShadow NOTIFY dirty)
172 MakeLightingModelConfig() : render::Job::Config() {}
174 bool enableUnlit {
true };
175 bool enableEmissive {
true };
176 bool enableLightmap {
true };
177 bool enableBackground {
true };
178 bool enableObscurance {
true };
180 bool enableScattering {
true };
181 bool enableDiffuse {
true };
182 bool enableSpecular {
true };
184 bool enableAlbedo {
true };
185 bool enableMaterialTexturing {
true };
187 bool enableAmbientLight {
true };
188 bool enableDirectionalLight {
true };
189 bool enablePointLight {
true };
190 bool enableSpotLight {
true };
192 bool showLightContour {
false };
194 bool enableWireframe {
false };
195 bool enableHaze {
true };
196 bool enableBloom {
true };
197 bool enableSkinning {
true };
198 bool enableBlendshape {
true };
200 bool enableAmbientOcclusion {
true };
201 bool enableLocalLighting {
true };
202 bool enableShadow {
true };
204 void setAmbientOcclusion(
bool enable) { enableAmbientOcclusion = enable; emit dirty();}
205 bool isAmbientOcclusionEnabled()
const {
return enableAmbientOcclusion; }
206 void setLocalLighting(
bool enable) { enableLocalLighting = enable; emit dirty();}
207 bool isLocalLightingEnabled()
const {
return enableLocalLighting; }
208 void setShadow(
bool enable) { enableShadow = enable; emit dirty(); }
209 bool isShadowEnabled()
const {
return enableShadow; }
210 void setHaze(
bool enable) { enableHaze = enable; emit dirty(); }
211 void setBloom(
bool enable) { enableBloom = enable; emit dirty(); }
217 class MakeLightingModel {
219 using Config = MakeLightingModelConfig;
220 using JobModel = render::Job::ModelO<MakeLightingModel, LightingModelPointer, Config>;
224 void configure(
const Config& config);
225 void run(
const render::RenderContextPointer& renderContext, LightingModelPointer& lightingModel);
228 LightingModelPointer _lightingModel;