diff --git a/Docs/src/manual/Ogre3.0.Changes.md b/Docs/src/manual/Ogre3.0.Changes.md index 0ecc6229ea0..811f2d8a909 100644 --- a/Docs/src/manual/Ogre3.0.Changes.md +++ b/Docs/src/manual/Ogre3.0.Changes.md @@ -48,6 +48,12 @@ Default material BRDF settings have changed in 3.0; thus materials will look dif See [PBR / PBS Changes in 3.0](@ref PBSChangesIn30) to how make them look like they did in 2.3 and what these changes mean. +## Hlms Shader piece changes + +The piece block `LoadNormalData` got split into `LoadGeomNormalData` & `LoadNormalData` in order to support Decals in Terra. + +If you were overriding `LoadNormalData` in a custom piece, make sure to account for the new `LoadGeomNormalData`. + ## Move to C++11 and general cleanup Lots of dead \& long-deprecated code was removed. diff --git a/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp b/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp index d39ea869474..dbc82f6e17c 100644 --- a/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp +++ b/Samples/2.0/Tutorials/Tutorial_Terrain/src/Terra/Hlms/OgreHlmsTerra.cpp @@ -783,6 +783,7 @@ namespace Ogre outLibraryFoldersPaths.push_back( "Hlms/Pbs/Any/Atmosphere" ); #endif outLibraryFoldersPaths.push_back( "Hlms/Pbs/Any/Main" ); + outLibraryFoldersPaths.push_back( "Hlms/Pbs/" + shaderSyntax ); outLibraryFoldersPaths.push_back( "Hlms/Terra/Any" ); // Fill the data folder path diff --git a/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any b/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any index da650d5b98d..194503bda24 100644 --- a/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any +++ b/Samples/Media/Hlms/Pbs/Any/ForwardPlus_DecalsCubemaps_piece_ps.any @@ -69,17 +69,15 @@ float3 absLocalPos = abs( localPos.xyz ); bool isOutsideDecal = absLocalPos.x > 0.5f || absLocalPos.y > 0.5f || absLocalPos.z > 0.5f; - //Mask away objects looking away from the decal. Please note that inPs.normal is not unit-length - //and is before any TBN for normal mapping. In other words it's the geometric normal - //geomNormal is not available because it gets decalred after decals run + //Mask away objects looking away from the decal. //We assume invWorldView is orthogonal, thus the transpose = inverse, hance invWorldView1.xyz //works as the decal's direction // //Use a smooth fade to avoid flickering due to floating point precision when the normal //and the decal are perpendicular to each other. (tolerance set to 0.0002) midf3 decalDir = normalize( midf3_c( invWorldView1.xyz ) ); - //isOutsideDecal = dot( decalDir.xyz, inPs.normal.xyz ) <= 0.0 ? true : isOutsideDecal; - midf normalAway = saturate( (dot( decalDir.xyz, inPs.normal.xyz ) + _h( 0.0002 ) ) / _h( 0.0002 ) ); + //isOutsideDecal = dot( decalDir.xyz, pixelData.geomNormal.xyz ) <= 0.0 ? true : isOutsideDecal; + midf normalAway = saturate( (dot( decalDir.xyz, pixelData.geomNormal.xyz ) + _h( 0.0002 ) ) / _h( 0.0002 ) ); normalAway = isOutsideDecal ? _h( 0.0f ) : normalAway; midf decalMask = normalAway; diff --git a/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any b/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any index 99752eb78ca..82b650406bc 100644 --- a/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any +++ b/Samples/Media/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any @@ -371,11 +371,12 @@ @piece( two_sided_flip_normal )* (gl_FrontFacing ? 1.0 : -1.0)@end @end @end +@piece( LoadGeomNormalData ) + // Geometric normal + pixelData.geomNormal = normalize( inPs.normal ) @insertpiece( two_sided_flip_normal ); +@end @piece( LoadNormalData ) - @property( !normal_map ) - // Geometric normal - pixelData.normal = normalize( inPs.normal ) @insertpiece( two_sided_flip_normal ); - @else + @property( normal_map ) //Normal mapping. pixelData.geomNormal = normalize( inPs.normal ) @insertpiece( two_sided_flip_normal ); midf3 vTangent = normalize( inPs.tangent ); @@ -791,6 +792,10 @@ pixelData.specular.xyz = float3( 0.0f, 0.0f, 0.0f ); @end + @property( !hlms_use_prepass ) + @insertpiece( LoadGeomNormalData ) + @end + @insertpiece( forwardPlusDoDecals ) @property( !hlms_use_prepass ) diff --git a/Samples/Media/Hlms/Terra/Any/800.PixelShader_piece_ps.any b/Samples/Media/Hlms/Terra/Any/800.PixelShader_piece_ps.any index fff0d10f965..ff5b8419ca1 100644 --- a/Samples/Media/Hlms/Terra/Any/800.PixelShader_piece_ps.any +++ b/Samples/Media/Hlms/Terra/Any/800.PixelShader_piece_ps.any @@ -182,6 +182,7 @@ @end @end +@undefpiece( LoadGeomNormalData ) @undefpiece( LoadNormalData ) @piece( LoadNormalData ) // Geometric normal @@ -227,6 +228,7 @@ @insertpiece( LoadDetailWeights ) @property( !hlms_use_prepass ) + @insertpiece( LoadGeomNormalData ) @insertpiece( LoadNormalData ) @insertpiece( SampleAndApplyDetailNormalMaps@property( detail_triplanar_normal )Triplanar@end ) @end