Skip to content

Commit

Permalink
Traktor: Minor fixes to new PBR model and specular reflections.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Jan 16, 2024
1 parent 5b807f6 commit 463c6e5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 78 deletions.
20 changes: 5 additions & 15 deletions data/Source/System/Shaders/Modules/PBR.xdi
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,19 @@ vec3 CalculateLighting(vec3 N, vec3 V, vec3 L, vec3 albedo, float metallic, floa
return (kD * albedo / PI + specular) * radiance * NdotL;
}
vec3 CalculateReflection(vec3 N, vec3 V, vec3 albedo, float metallic, float roughness)
vec3 CalculateReflection(vec3 N, vec3 V, vec3 albedo, float metallic)
{
// Use the view reflection vector as light direction.
const vec3 L = -reflect(V, N);
const vec3 H = normalize(V + L);
const float NdotL = max(dot(N, L), 0.0f);
const float NdotV = max(dot(N, V), 0.0f);
const vec3 F0 = mix(vec3(0.04), albedo, metallic);
const vec3 F = FresnelSchlick(max(dot(H, V), 0.0), F0);
const float HdotV = max(dot(H, V), 0.0f);
const float NDF = DistributionGGX(N, H, roughness);
const float G = GeometrySmith(N, V, L, roughness);
const vec3 numerator = NDF * G * F;
const float denominator = 4.0f * NdotV * NdotL + 0.0001f;
const vec3 specular = numerator / denominator;
const vec3 F0 = mix(vec3(0.1f), albedo, metallic);
const vec3 F = FresnelSchlick(HdotV, F0);
return clamp(specular, 0.0f, 1.0f);
return clamp(F * 1.0f, 0.0f, 1.0f);
}
]]>
</text>
</object>
102 changes: 39 additions & 63 deletions data/Source/System/World/Light/Shaders/Deferred/Lights.xdi
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,8 @@
<id>{BC1582DC-5A5D-F347-8685-1ED14D2FF1B4}</id>
<comment/>
<position>
<first>6534</first>
<second>1794</second>
<first>6865</first>
<second>1744</second>
</position>
</item>
<item type="traktor.render.Variable" version="2,traktor.render.Node:1">
Expand Down Expand Up @@ -1549,8 +1549,8 @@ Check max shadow distance
<id>{F9E67DE5-3704-224A-96AE-9228482CEB38}</id>
<comment/>
<position>
<first>6314</first>
<second>1767</second>
<first>6393</first>
<second>1703</second>
</position>
<name>L_Irradiance</name>
</item>
Expand Down Expand Up @@ -2418,17 +2418,17 @@ $Output = vec4(Lout.xyz, 0.0f);
<id>{6493D852-89DC-7D45-96A5-43172F633200}</id>
<comment/>
<position>
<first>6612</first>
<second>1889</second>
<first>6405</first>
<second>1751</second>
</position>
<name>L_Albedo</name>
</item>
<item type="traktor.render.Mul" version="traktor.render.Node:1">
<id>{D6AA86B0-7BAA-E947-B1A8-45729FA00832}</id>
<comment/>
<position>
<first>6814</first>
<second>1814</second>
<first>6616</first>
<second>1699</second>
</position>
</item>
<item type="traktor.render.Script" version="6,traktor.render.Node:1">
Expand Down Expand Up @@ -2465,10 +2465,6 @@ $Output = vec4(Lout.xyz, 0.0f);
<id>{CD77DAB2-298A-A04F-BA9E-C535D9F7039D}</id>
<name>Metallic</name>
</item>
<item>
<id>{0AE24D2B-EF65-2A44-8272-F5B8084A3051}</id>
<name>Roughness</name>
</item>
</inputPins>
<outputPins>
<item>
Expand All @@ -2483,62 +2479,52 @@ const vec3 N = $N.xyz;
const vec3 V = $V.xyz;
const vec3 albedo = $Albedo.xyz;
const float metallic = $Metallic.x;
const float roughness = $Roughness.x;
const vec3 r = CalculateReflection(
N,
V,
albedo,
metallic,
roughness
metallic
);
$Output = vec4(r, 0.0f);
]]>
</script>
</item>
<item type="traktor.render.Variable" version="2,traktor.render.Node:1">
<id>{06A6E503-4F41-E447-8982-C83339D34812}</id>
<comment/>
<position>
<first>5708</first>
<second>1882</second>
<first>5769</first>
<second>1961</second>
</position>
<name>L_Albedo</name>
</item>
<item type="traktor.render.Variable" version="2,traktor.render.Node:1">
<id>{D5188A3E-251B-894A-95B6-11FB8E397D9F}</id>
<comment/>
<position>
<first>5689</first>
<second>1919</second>
<first>5753</first>
<second>1995</second>
</position>
<name>L_Metalness</name>
</item>
<item type="traktor.render.Variable" version="2,traktor.render.Node:1">
<id>{1B2864A9-E4FE-C24E-BF5A-36D2EA6A4C70}</id>
<comment/>
<position>
<first>5673</first>
<second>1959</second>
<first>5753</first>
<second>1893</second>
</position>
<name>L_ViewNormal</name>
</item>
<item type="traktor.render.Variable" version="2,traktor.render.Node:1">
<id>{9225CBF0-0C5E-A24E-8CF7-F01164FDB458}</id>
<comment/>
<position>
<first>5673</first>
<second>1999</second>
</position>
<name>L_Roughness</name>
</item>
<item type="traktor.render.Variable" version="2,traktor.render.Node:1">
<id>{BD6C147B-861D-F14A-A9F2-5584F1DF6D5D}</id>
<comment/>
<position>
<first>5657</first>
<second>2039</second>
<first>5737</first>
<second>1927</second>
</position>
<name>L_ViewDirection</name>
</item>
Expand Down Expand Up @@ -4502,16 +4488,6 @@ $Output = vec4(r, 0.0f);
<id>{CD77DAB2-298A-A04F-BA9E-C535D9F7039D}</id>
</destination>
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[206]"/>
<id>{84BF3C26-64A7-4032-B775-1D369052B243}</id>
</source>
<destination>
<node ref="/object/nodes/item[202]"/>
<id>{0AE24D2B-EF65-2A44-8272-F5B8084A3051}</id>
</destination>
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[205]"/>
Expand All @@ -4524,7 +4500,7 @@ $Output = vec4(r, 0.0f);
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[207]"/>
<node ref="/object/nodes/item[206]"/>
<id>{84BF3C26-64A7-4032-B775-1D369052B243}</id>
</source>
<destination>
Expand All @@ -4538,28 +4514,28 @@ $Output = vec4(r, 0.0f);
<id>{26124FFB-5851-A149-800A-2611E58573AD}</id>
</source>
<destination>
<node ref="/object/nodes/item[208]"/>
<node ref="/object/nodes/item[207]"/>
<id>{D2D716D6-C4A1-471F-894A-D718515F6281}</id>
</destination>
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[70]"/>
<id>{9E839249-E9B9-4736-8BDD-A95A1C892B42}</id>
<node ref="/object/nodes/item[138]"/>
<id>{32FD3DAA-16C1-44C8-8A1E-E9ECF97F31D2}</id>
</source>
<destination>
<node ref="/object/nodes/item[208]"/>
<id>{69997292-C813-490C-910C-620B9AD3A2BB}</id>
<node ref="/object/nodes/item[55]"/>
<id>{11585EBC-914D-4E6D-A10D-D01694FF9840}</id>
</destination>
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[208]"/>
<node ref="/object/nodes/item[70]"/>
<id>{9E839249-E9B9-4736-8BDD-A95A1C892B42}</id>
</source>
<destination>
<node ref="/object/nodes/item[67]"/>
<id>{9F45B2C3-B513-4646-B0C1-663748FD169C}</id>
<node ref="/object/nodes/item[207]"/>
<id>{69997292-C813-490C-910C-620B9AD3A2BB}</id>
</destination>
</item>
<item type="traktor.render.Edge" version="1">
Expand All @@ -4568,24 +4544,24 @@ $Output = vec4(r, 0.0f);
<id>{84BF3C26-64A7-4032-B775-1D369052B243}</id>
</source>
<destination>
<node ref="/object/nodes/item[67]"/>
<id>{3DE04294-4DEA-4A13-A460-2274647357EA}</id>
<node ref="/object/nodes/item[201]"/>
<id>{69997292-C813-490C-910C-620B9AD3A2BB}</id>
</destination>
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[67]"/>
<id>{32FD3DAA-16C1-44C8-8A1E-E9ECF97F31D2}</id>
<node ref="/object/nodes/item[201]"/>
<id>{9E839249-E9B9-4736-8BDD-A95A1C892B42}</id>
</source>
<destination>
<node ref="/object/nodes/item[201]"/>
<id>{69997292-C813-490C-910C-620B9AD3A2BB}</id>
<node ref="/object/nodes/item[67]"/>
<id>{3DE04294-4DEA-4A13-A460-2274647357EA}</id>
</destination>
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[201]"/>
<id>{9E839249-E9B9-4736-8BDD-A95A1C892B42}</id>
<node ref="/object/nodes/item[67]"/>
<id>{32FD3DAA-16C1-44C8-8A1E-E9ECF97F31D2}</id>
</source>
<destination>
<node ref="/object/nodes/item[138]"/>
Expand All @@ -4594,12 +4570,12 @@ $Output = vec4(r, 0.0f);
</item>
<item type="traktor.render.Edge" version="1">
<source>
<node ref="/object/nodes/item[138]"/>
<id>{32FD3DAA-16C1-44C8-8A1E-E9ECF97F31D2}</id>
<node ref="/object/nodes/item[207]"/>
<id>{9E839249-E9B9-4736-8BDD-A95A1C892B42}</id>
</source>
<destination>
<node ref="/object/nodes/item[55]"/>
<id>{11585EBC-914D-4E6D-A10D-D01694FF9840}</id>
<node ref="/object/nodes/item[67]"/>
<id>{9F45B2C3-B513-4646-B0C1-663748FD169C}</id>
</destination>
</item>
</edges>
Expand Down

0 comments on commit 463c6e5

Please sign in to comment.