WIP, falloff things.
# Conflicts: # resources/Schema/Components/PointLight.xsd # resources/Shaders/ForwardPlus.frag.glsl
This commit is contained in:
@@ -35,8 +35,6 @@ private:
|
||||
//----------------------Variables----------------------//
|
||||
EventBroker* m_EventBroker;
|
||||
|
||||
int m_bi = 0;
|
||||
|
||||
std::shared_ptr<DebugCameraInputController<Renderer>> m_DebugCameraInputController;
|
||||
|
||||
Texture* m_ErrorTexture;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<xs:element name="Color" type="t:Color" minOccurs="0"/>
|
||||
<xs:element name="Radius" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="Intensity" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="Falloff" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="Falloff" type="t:double" minOccurs="0" minInclusive="0" maxInclusive="1"/>
|
||||
<xs:element name="Visible" type="t:bool" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
|
||||
@@ -56,7 +56,7 @@ struct LightResult {
|
||||
vec4 Specular;
|
||||
};
|
||||
|
||||
float CalcAttenuation(float radius, float dist) {
|
||||
float CalcAttenuation(float radius, float dist, float falloff) {
|
||||
return 1.0 - smoothstep(radius * 0.3, radius, dist);
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ vec4 CalcDiffuse(vec4 lightColor, vec4 lightVec, vec4 normal) {
|
||||
return lightColor * power;
|
||||
}
|
||||
|
||||
LightResult CalcPointLight(vec4 lightPos, float lightRadius, vec4 lightColor, float intensity, vec4 viewVec, vec4 position, vec4 normal)
|
||||
LightResult CalcPointLight(vec4 lightPos, float lightRadius, vec4 lightColor, float intensity, vec4 viewVec, vec4 position, vec4 normal, float falloff)
|
||||
{
|
||||
vec4 L = lightPos - position;
|
||||
float dist = length(L);
|
||||
L = normalize(L);
|
||||
|
||||
float attenuation = CalcAttenuation(lightRadius, dist);
|
||||
float attenuation = CalcAttenuation(lightRadius, dist, falloff);
|
||||
|
||||
LightResult result;
|
||||
result.Diffuse = CalcDiffuse(lightColor, L, normal) * attenuation * intensity;
|
||||
@@ -108,7 +108,7 @@ void main()
|
||||
{
|
||||
int l = int(LightIndex[i]);
|
||||
|
||||
LightResult result = CalcPointLight(V * PointLights.List[l].Position, PointLights.List[l].Radius, PointLights.List[l].Color, PointLights.List[l].Intensity, viewVec, position, normal);
|
||||
LightResult result = CalcPointLight(V * PointLights.List[l].Position, PointLights.List[l].Radius, PointLights.List[l].Color, PointLights.List[l].Intensity, viewVec, position, normal, PointLights.List[i].Falloff);
|
||||
|
||||
totalLighting.Diffuse += result.Diffuse;
|
||||
totalLighting.Specular += result.Specular;
|
||||
|
||||
@@ -91,14 +91,6 @@ void Renderer::Update(double dt)
|
||||
void Renderer::Draw(RenderQueueCollection& rq)
|
||||
{
|
||||
FillDepth(rq);
|
||||
if (m_bi == 1) {
|
||||
for (auto i : rq.Forward) {
|
||||
printf("D: %f| \n", i->Depth);
|
||||
}
|
||||
m_bi = 0;
|
||||
printf("------THE END------");
|
||||
}
|
||||
m_bi++;
|
||||
m_PickingPass->Draw(rq);
|
||||
//DrawScreenQuad(m_PickingPass->PickingTexture());
|
||||
m_LightCullingPass->FillLightList(rq);
|
||||
|
||||
Reference in New Issue
Block a user