diff options
| author | Dave Parks <davep@lindenlab.com> | 2022-06-28 15:16:15 -0500 | 
|---|---|---|
| committer | Dave Parks <davep@lindenlab.com> | 2022-06-28 15:16:15 -0500 | 
| commit | 423b6c72e9f8978cd16c9aaa9bb14b03cdea73a4 (patch) | |
| tree | 9cc9c2cc50c5f10bcf6a49597ee72576015971df | |
| parent | 57805cac68bbc67ecb8a8e76c0ced2ce9b622dd1 (diff) | |
| parent | 7fdb05d7ef449d2cc9b96c77c7bfa41bf7c15ede (diff) | |
Merge branch 'DRTVWR-559' of ssh://bitbucket.org/lindenlab/viewer into DRTVWR-559
4 files changed, 82 insertions, 22 deletions
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 6b4778c270..68e1a8954d 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -52,7 +52,7 @@ public:      bool hasShadows;      bool hasAmbientOcclusion;  	bool hasSrgb; -    bool encodesNormal; +    bool encodesNormal; // include: shaders\class1\environment\encodeNormF.glsl      bool isDeferred;      bool hasIndirect;  	S32 mIndexedTextureChannels; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index a2606ed771..82338069a8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -78,23 +78,24 @@ VARYING vec2 vary_texcoord0;  void main()  { +	vec4 pos4 = vec4(position,1.0);  #ifdef HAS_SKIN  	mat4 mat = getObjectSkinnedTransform();  	mat = modelview_matrix * mat; -	vec3 pos = (mat*vec4(position.xyz,1.0)).xyz; +	vec3 pos = (mat*pos4).xyz;  #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)  	vary_position = pos;  #endif -	gl_Position = projection_matrix*vec4(pos,1.0); +	gl_Position = projection_matrix*pos4;  #else  	//transform vertex -	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);  +	gl_Position = modelview_projection_matrix * pos4;  #endif  	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 243f1c4498..ff2b87b9df 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -26,12 +26,14 @@  #define DEBUG_PBR_PACKORM0        0 // Rough=0, Metal=0  #define DEBUG_PBR_PACKORM1        0 // Rough=1, Metal=1  #define DEBUG_PBR_TANGENT1        1 // Tangent = 1,0,0 +#define DEBUG_PBR_VERT2CAM1       0 // vertex2camera = 0,0,1  #define DEBUG_PBR_RAW_DIFF         0 // Output: use diffuse in G-Buffer  #define DEBUG_PBR_RAW_SPEC         0 // Output: use spec in G-Buffer  #define DEBUG_PBR_IRRADIANCE       0 // Output: Diffuse Irradiance  #define DEBUG_PBR_DIFFUSE          0 // Output: Radiance Lambertian  #define DEBUG_PBR_ORM              0 // Output: Packed Occlusion Roughness Metal +#define DEBUG_PBR_OCCLUSION        0 // Output: Occlusion map  #define DEBUG_PBR_ROUGH_PERCEPTUAL 0 // Output: grayscale Perceptual Roughenss  #define DEBUG_PBR_ROUGH_ALPHA      0 // Output: grayscale Alpha Roughness  #define DEBUG_PBR_METAL            0 // Output: grayscale metal @@ -41,12 +43,22 @@  #define DEBUG_PBR_SPEC             0 // Output: Final spec  #define DEBUG_PBR_SPEC_REFLECTION  0 // Output: reflection  #define DEBUG_PBR_NORMAL           0 // Output: passed in normal. To see raw normal map: set DEBUG_PBR_RAW_DIFF 1, and in pbropaqueF set DEBUG_NORMAL_RAW -#define DEBUG_PBR_VIEW             0 // Output: view_dir +#define DEBUG_PBR_TANGENT          0 // Output: Tangent +#define DEBUG_PBR_BITANGET         0 // Output: Bitangnet +#define DEBUG_PBR_V2C_RAW          0 // Output: vertex2camera +#define DEBUG_PBR_V2C_REMAP        0 // Output: vertex2camera (remap [-1,1] -> [0,1])  #define DEBUG_PBR_BRDF             0 // Output: Environment BRDF -#define DEBUG_PBR_DOT_NV           0 // Output: grayscale dot(Normal,ViewDir) -#define DEBUG_PBR_DOT_TV           0 // Output: -#define DEBUG_PBR_DOT_BV           0 // Output: +#define DEBUG_PBR_DOT_NV           0 // Output: grayscale dot(Normal   ,Vertex2Camera) +#define DEBUG_PBR_DOT_TV           0 // Output: grayscale dot(Tangent  ,Vertex2Camera) +#define DEBUG_PBR_DOT_BV           0 // Output: graysacle dot(Bitangent,Vertex2Camera)  #define DEBUG_PBR_FRESNEL          0 // Output: roughness dependent fresnel +#define DEBUG_PBR_KSPEC            0 // Output: K spec +#define DEBUG_PBR_IOR              0 // Output: grayscale IOR +#define DEBUG_PBR_REFLECT0_BASE    0 // Output: black reflect0 default from ior +#define DEBUG_PBR_REFLECT0_MIX     0 // Output: diffuse reflect0 calculated from ior +#define DEBUG_PBR_FE_GGX           0 // Output: FssEssGGX +#define DEBUG_PBR_FE_LAMBERT       0 // Output: FssEssLambert +#define DEBUG_PBR_DIFFUSE_K        0 // Output: diffuse FssEssLambert + FmsEms  #extension GL_ARB_texture_rectangle : enable  #extension GL_ARB_shader_texture_lod : enable @@ -184,6 +196,8 @@ void main()      vec3 legacyenv;      sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity); +    amblit = max(ambenv, amblit); +      bool hasPBR = GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR);      if (hasPBR)      { @@ -201,15 +215,21 @@ void main()  #if DEBUG_PBR_PACK_ORM1               packedORM        = vec3(1,1,1);  #endif -        float IOR             = 1.5;         // default Index Of Reflection 1.5 +        float IOR             = 1.5;         // default Index Of Refraction 1.5 (dielectrics)          vec3  reflect0        = vec3(0.04);  // -> incidence reflectance 0.04 - -        IOR = 0.0; // TODO: Set from glb -        reflect0 = calcBaseReflect0(IOR); +#if HAS_IOR +              reflect0        = calcBaseReflect0(IOR); +#endif +#if DEBUG_PBR_REFLECT0_BASE +        vec3  debug_reflect0  = reflect0; +#endif          float metal      = packedORM.b;          vec3  reflect90  = vec3(0); -        vec3  v          = view_dir; +        vec3  v          = -normalize(pos.xyz); +#if DEBUG_PBR_VERT2CAM1 +              v = vec3(0,0,1); +#endif          vec3  n          = norm.xyz;  //      vec3  t          = texture2DRect(tangentMap, tc).rgb;  #if DEBUG_PBR_TANGENT1 @@ -219,8 +239,8 @@ void main()          vec3  reflectVN  = normalize(reflect(-v,n));          float dotNV = clamp(dot(n,v),0,1); -        float dotTV = clamp(dot(n,t),0,1); -        float dotBV = clamp(dot(n,b),0,1); +        float dotTV = clamp(dot(t,v),0,1); +        float dotBV = clamp(dot(b,v),0,1);          // Reference: getMetallicRoughnessInfo          float perceptualRough = packedORM.g; @@ -228,7 +248,9 @@ void main()          vec3  colorDiff      = mix( diffuse.rgb, vec3(0)    , metal);                reflect0       = mix( reflect0   , diffuse.rgb, metal); // reflect at 0 degrees                reflect90      = vec3(1);                               // reflect at 90 degrees +#if DEBUG_PBR_REFLECTANCE          float reflectance    = max( max( reflect0.r, reflect0.g ), reflect0.b ); +#endif          // Common to RadianceGGX and RadianceLambertian          float specWeight = 1.0; @@ -238,12 +260,13 @@ void main()          vec3  kSpec      = reflect0 + fresnelR*pow(1.0 - dotNV, 5.0);          // Reference: getIBLRadianceGGX +        vec3 reflection = normalize(reflect(-v,n));          vec3 specLight  = getSpecularPBR(reflection);  #if HAS_IBL          kSpec          = mix( kSpec, iridescenceFresnel, iridescenceFactor);  #endif -        vec3 FssEssRadiance = kSpec*vScaleBias.x + vScaleBias.y; -        colorSpec += specWeight * specLight * FssEssRadiance; +        vec3 FssEssGGX = kSpec*vScaleBias.x + vScaleBias.y; +        colorSpec += specWeight * specLight * FssEssGGX;          // Reference: getIBLRadianceLambertian          vec3  irradiance    = getDiffuseLightPBR(n); @@ -255,7 +278,11 @@ void main()          vec3  kDiffuse     = colorDiffuse * (1.0 - FssEssLambert + FmsEms);          colorDiffuse      += (FmsEms + kDiffuse) * irradiance; -        color.rgb  = colorDiffuse + colorEmissive + colorSpec; +        float occlusion_strength = 1.0; // TODO: From glb +        float ao     = packedORM.r; +        colorDiffuse = mix(colorDiffuse, colorDiffuse * ao, occlusion_strength); + +        color.rgb = colorDiffuse + colorEmissive + colorSpec;      #if DEBUG_PBR_BRDF_UV          color.rgb = vec3(brdfPoint,0.0); @@ -266,12 +293,24 @@ void main()      #if DEBUG_PBR_FRESNEL          color.rgb = fresnelR;      #endif +    #if DEBUG_PBR_IOR +        color.rgb = vec3(IOR); +    #endif +    #if DEBUG_PBR_KSPEC +        color.rgb = kSpec; +    #endif      #if DEBUG_PBR_RAW_DIFF          color.rgb = diffuse.rgb;      #endif      #if DEBUG_PBR_RAW_SPEC          color.rgb = spec.rgb;      #endif +    #if DEBUG_PBR_REFLECT0_BASE +        color.rgb = vec3(debug_reflect0); +    #endif +    #if DEBUG_PBR_REFLECT0_MIX +        color.rgb = vec3(reflect0); +    #endif      #if DEBUG_PBR_REFLECTANCE          color.rgb = vec3(reflectance);      #endif @@ -281,6 +320,9 @@ void main()      #if DEBUG_PBR_DIFFUSE          color.rgb = colorDiffuse;      #endif +    #if DEBUG_PBR_DIFFUSE_K +        color.rgb = kDiffuse; +    #endif      #if DEBUG_PBR_EMISSIVE          color.rgb = colorEmissive;      #endif @@ -299,14 +341,26 @@ void main()      #if DEBUG_PBR_SPEC_REFLECTION          color.rgb = specLight;      #endif +    #if DEBUG_PBR_OCCLUSION +        color.rgb = vec3(packedORM.r); +    #endif      #if DEBUG_PBR_ORM          color.rgb = packedORM;      #endif      #if DEBUG_PBR_NORMAL          color.rgb = norm.xyz;      #endif -    #if DEBUG_PBR_VIEW -        color.rgb = view_dir; +    #if DEBUG_PBR_TANGENT +        color.rgb = t; +    #endif +    #if DEBUG_PBR_BITANGENT +        color.rgb = b; +    #endif +    #if DEBUG_PBR_V2C_RAW +        color.rgb = v; +    #endif +    #if DEBUG_PBR_V2C_REMAP +        color.rgb = v*0.5 + vec3(0.5);      #endif      #if DEBUG_PBR_DOT_NV          color.rgb = vec3(dotNV); @@ -317,10 +371,15 @@ void main()      #if DEBUG_PBR_DOT_BV          color.rgb = vec3(dotBV);      #endif +    #if DEBUG_PBR_FE_GGX +        color.rgb = FssEssGGX; // spec +    #endif +    #if DEBUG_PBR_FE_LAMBERT +        color.rgb = FssEssLambert; // diffuse +    #endif      }  else  { -    amblit = max(ambenv, amblit);      color.rgb = amblit*ambocc;      //float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index b0f1867e9a..86d73de14e 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -130,7 +130,7 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass)          if (params.mEmissiveMap)          { -            gDeferredPBROpaqueProgram.bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap); // Packed Occlusion Roughness Metal +            gDeferredPBROpaqueProgram.bindTexture(LLShaderMgr::EMISSIVE_MAP, params.mEmissiveMap);          }          else          {  | 
