Skip to content

Commit

Permalink
refactor: adapter 1.4 digital human shader (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxudong authored Jan 23, 2025
1 parent fe73415 commit 5efb3d4
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ void PBRFragment(Varyings varyings) {
surfaceData.normal =calculateEyeNormal(varyings.uv, tbn, gl_FrontFacing);
surfaceData.f0 = 0.04;


// Can modify surfaceData here
initBRDFData(surfaceData, brdfData);

vec4 color = vec4(0, 0, 0, surfaceData.opacity);
vec3 totalDiffuseColor = vec3(0, 0, 0);
vec3 totalSpecularColor = vec3(0, 0, 0);

// Get shadow attenuation
float shadowAttenuation = 1.0;
Expand All @@ -102,10 +102,13 @@ void PBRFragment(Varyings varyings) {
#endif

// Evaluate direct lighting
evaluateDirectRadiance(varyings, surfaceData, brdfData, shadowAttenuation, color.rgb);
evaluateDirectRadiance(varyings, surfaceData, brdfData, shadowAttenuation, totalDiffuseColor, totalSpecularColor);

// IBL
evaluateIBL(varyings, surfaceData, brdfData, color.rgb);
evaluateIBL(varyings, surfaceData, brdfData, totalDiffuseColor, totalSpecularColor);

// Final color
vec4 color = vec4(totalDiffuseColor + totalSpecularColor, surfaceData.opacity);

// Emissive
color.rgb += surfaceData.emissiveColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ void PBRFragment(Varyings varyings) {
// Can modify surfaceData here
initBRDFData(surfaceData, brdfData);

vec4 color = vec4(0, 0, 0, surfaceData.opacity);

vec3 totalDiffuseColor = vec3(0, 0, 0);
vec3 totalSpecularColor = vec3(0, 0, 0);

// Get shadow attenuation
float shadowAttenuation = 1.0;
Expand All @@ -86,10 +88,13 @@ void PBRFragment(Varyings varyings) {
#endif

// Evaluate direct lighting
evaluateDirectRadiance(varyings, surfaceData, brdfData, shadowAttenuation, color.rgb);
evaluateDirectRadiance(varyings, surfaceData, brdfData, shadowAttenuation, totalDiffuseColor, totalSpecularColor);

// IBL
evaluateIBL(varyings, surfaceData, brdfData, color.rgb);
evaluateIBL(varyings, surfaceData, brdfData, totalDiffuseColor, totalSpecularColor);

// Final color
vec4 color = vec4(totalDiffuseColor + totalSpecularColor, surfaceData.opacity);

// Emissive
color.rgb += surfaceData.emissiveColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ void PBRFragment(Varyings varyings) {
// Can modify surfaceData here
initBRDFData(surfaceData, brdfData);

vec4 color = vec4(0, 0, 0, surfaceData.opacity);

vec3 totalDiffuseColor = vec3(0, 0, 0);
vec3 totalSpecularColor = vec3(0, 0, 0);
// Get shadow attenuation
float shadowAttenuation = 1.0;
#if defined(SCENE_DIRECT_LIGHT_COUNT) && defined(NEED_CALCULATE_SHADOWS)
Expand All @@ -86,10 +86,13 @@ void PBRFragment(Varyings varyings) {
#endif

// Evaluate direct lighting
evaluateDirectRadiance(varyings, surfaceData, brdfData, shadowAttenuation, color.rgb);
evaluateDirectRadiance(varyings, surfaceData, brdfData, shadowAttenuation, totalDiffuseColor, totalSpecularColor);

// IBL
evaluateIBL(varyings, surfaceData, brdfData, color.rgb);
evaluateIBL(varyings, surfaceData, brdfData, totalDiffuseColor, totalSpecularColor);

// Final color
vec4 color = vec4(totalDiffuseColor + totalSpecularColor, surfaceData.opacity);

// Emissive
color.rgb += surfaceData.emissiveColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "ReflectionLobe.glsl"
#include "./SSSFunction.glsl"

void surfaceShadingSSS(Varyings varyings, SurfaceData surfaceData, BRDFData brdfData, vec3 incidentDirection, vec3 lightColor, inout vec3 color) {
void surfaceShadingSSS(Varyings varyings, SurfaceData surfaceData, BRDFData brdfData, vec3 incidentDirection, vec3 lightColor, inout vec3 totalDiffuseColor, inout vec3 totalSpecularColor) {

vec3 diffuseColor = vec3(0);
vec3 specularColor = vec3(0);
Expand All @@ -31,7 +31,9 @@ void surfaceShadingSSS(Varyings varyings, SurfaceData surfaceData, BRDFData brdf
if(surfaceData.dotNV > EPSILON){
specularLobe(varyings, surfaceData, brdfData, incidentDirection, attenuationIrradiance, specularColor);
}
color += diffuseColor + specularColor;

totalDiffuseColor += diffuseColor;
totalSpecularColor += specularColor;
}

#include "LightDirectPBR.glsl"

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5efb3d4

Please sign in to comment.