git.s-ol.nu ~forks/DiligentFX / 69034da
Merge pull request #7 from luzpaz/typos Fix misc. typos Assiduous authored a month ago GitHub committed a month ago
15 changed file(s) with 41 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
9595 }
9696 ```
9797
98 When using filterable represenations, the shadow map must be post-processed before it can be used in a shader:
98 When using filterable representations, the shadow map must be post-processed before it can be used in a shader:
9999
100100 ```cpp
101101 if (m_ShadowSettings.iShadowMode > SHADOW_MODE_PCF)
6161 /// Shadow mode (see SHADOW_MODE_* defines in BasicStructures.fxh), must not be 0.
6262 int ShadowMode = 0;
6363
64 /// Wether to use 32-bit or 16-bit filterable textures
64 /// Whether to use 32-bit or 16-bit filterable textures
6565 bool Is32BitFilterableFmt = false;
6666
6767 /// Optional comparison sampler to be set in the shadow map resource view
9090 /// Pointer to light direction, must not be null.
9191 const float3* pLightDir = nullptr;
9292
93 /// Wether to snap cascades to texels in light view space
93 /// Whether to snap cascades to texels in light view space
9494 bool SnapCascades = true;
9595
96 /// Wether to stabilize cascade extents in light view space
96 /// Whether to stabilize cascade extents in light view space
9797 bool StabilizeExtents = true;
9898
99 /// Wether to use same extents for X and Y axis. Enabled automatically if StabilizeExtents == true
99 /// Whether to use same extents for X and Y axis. Enabled automatically if StabilizeExtents == true
100100 bool EqualizeExtents = true;
101101
102102 /// Cascade partitioning factor that defines the ratio between fully linear (0.0) and
103103 /// fully logarithmic (1.0) partitioning.
104104 float fPartitioningFactor = 0.95f;
105105
106 /// Wether to use right-handed or left-handed light view transform matrix
106 /// Whether to use right-handed or left-handed light view transform matrix
107107 bool UseRightHandedLightViewTransform = true;
108108
109109 /// Callback that allows the application to adjust z range of every cascade.
55
66 ![](screenshots/flight_helmet.jpg)
77
8 The renderer uses the refernce
8 The renderer uses the reference
99 [GLTF2.0 lighting model](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-b-brdf-implementation).
1010
1111 |[Khronos GLTF viewer][1]| Diligent Engine |
5151 The renderer itself does not implement any loading functionality. Use
5252 [Asset Loader](https://github.com/DiligentGraphics/DiligentTools/tree/master/AssetLoader) to load GLTF
5353 models. When model is loaded, it is important to call `InitializeResourceBindings()` method
54 to let the renderer intiailize internal shader resource binding objects:
54 to let the renderer initialize internal shader resource binding objects:
5555
5656 ```cpp
5757 m_Model.reset(new GLTF::Model(m_pDevice, m_pImmediateContext, Path));
134134 {
135135 CreateUniformBuffer(pDevice, sizeof(GLTFNodeShaderTransforms), "GLTF node transforms CB", &m_TransformsCB);
136136 CreateUniformBuffer(pDevice, sizeof(GLTFMaterialShaderInfo) + sizeof(GLTFRendererShaderParameters), "GLTF attribs CB", &m_GLTFAttribsCB);
137 CreateUniformBuffer(pDevice, static_cast<Uint32>(sizeof(float4x4) * m_Settings.MaxJointCount), "GLTF joint tranforms", &m_JointsBuffer);
137 CreateUniformBuffer(pDevice, static_cast<Uint32>(sizeof(float4x4) * m_Settings.MaxJointCount), "GLTF joint transforms", &m_JointsBuffer);
138138
139139 // clang-format off
140140 StateTransitionDesc Barriers[] =
977977 GLTFRendererShaderParameters RenderParameters;
978978 GLTF::Material::ShaderAttribs MaterialInfo;
979979 static_assert(sizeof(GLTFMaterialShaderInfo) == sizeof(GLTF::Material::ShaderAttribs),
980 "The sizeof(GLTFMaterialShaderInfo) is incosistent with sizeof(GLTF::Material::ShaderAttribs)");
980 "The sizeof(GLTFMaterialShaderInfo) is inconsistent with sizeof(GLTF::Material::ShaderAttribs)");
981981 };
982982 static_assert(sizeof(GLTFAttribs) <= 256, "Size of dynamic GLTFAttribs buffer exceeds 256 bytes. "
983983 "It may be worth trying to reduce the size or just live with it.");
2727 produce more samples and higher quality, but at a higher performance cost.
2828 * bShowSampling - Whether to show epipolar sampling.
2929 * bCorrectScatteringAtDepthBreaks - Whether to correct inscattering at depth discontinuities. Improves quality
30 for additional cost. It may be preferrable to increase the number of slices
30 for additional cost. It may be preferable to increase the number of slices
3131 and or maximum number of samples on an epipolar line instead.
3232 * bShowDepthBreaks - Whether to display pixels which are classified as depth discontinuities and which
3333 will be corrected. Only has effect when bCorrectScatteringAtDepthBreaks is TRUE.
3434 * bShowLightingOnly - Whether to show lighting only
3535 * bOptimizeSampleLocations - Optimize sample locations to avoid oversampling. This should generally be TRUE.
36 * bEnableLightShafts - Wether to enable light shafts or render unshadowed inscattering.
36 * bEnableLightShafts - Whether to enable light shafts or render unshadowed inscattering.
3737 Setting this to FALSE increases performance, but reduces visual quality.
3838 * uiInstrIntegralSteps - Number of inscattering integral steps taken when computing unshadowed inscattering
3939 Default value is OK and should not be changed.
6767 * uiExtinctionEvalMode - Atmospheric extinction evaluation mode.
6868 * bUseCustomSctrCoeffs - Whether to use custom scattering coefficients.
6969 * fAerosolDensityScale - Aerosol density scale to use for scattering coefficient computation.
70 * fAerosolAbsorbtionScale - Aerosol absorbtion scale to use for scattering coefficient computation.
70 * fAerosolAbsorbtionScale - Aerosol absorption scale to use for scattering coefficient computation.
7171 * f4CustomRlghBeta - Custom Rayleigh coefficients.
7272 * f4CustomMieBeta - Custom Mie coefficients.
7373
8080 * Light and color attributes
8181
8282 The code snippet below shows how to use the epipolar light scattering post-processing effect.
83 For the full soure code, see [Atmospheric scattering sample](https://github.com/DiligentGraphics/DiligentSamples/tree/master/Samples/Atmosphere).
83 For the full source code, see [Atmospheric scattering sample](https://github.com/DiligentGraphics/DiligentSamples/tree/master/Samples/Atmosphere).
8484
8585 ```cpp
8686 EpipolarLightScattering::FrameAttribs FrameAttribs;
5757 // Pixel shader discards pixels that should not be further processed, thus keeping the
5858 // stencil value untouched.
5959 // For instance, pixel shader performing epipolar coordinates generation discards all
60 // sampes, whoose coordinates are outside the screen [-1,1]x[-1,1] area.
60 // sampes, whose coordinates are outside the screen [-1,1]x[-1,1] area.
6161 static const DepthStencilStateDesc DSS_IncStencilAlways
6262 {
6363 False, // DepthEnable
8585
8686 // Disable depth testing, stencil testing function equal, increment stencil.
8787 // This state is used to process only those pixels that were marked at the previous pass.
88 // All pixels whith different stencil value are discarded from further processing as well
88 // All pixels with different stencil value are discarded from further processing as well
8989 // as some pixels can also be discarded during the draw call.
9090 // For instance, pixel shader marking ray marching samples processes only those pixels which are inside
9191 // the screen. It also discards all but those samples that are interpolated from themselves.
902902 auto* tex2DAverageLuminanceSRV = tex2DAverageLuminance->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE);
903903 m_ptex2DAverageLuminanceRTV = tex2DAverageLuminance->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET);
904904 tex2DAverageLuminanceSRV->SetSampler(m_pLinearClampSampler);
905 // Set intial luminance to 1
905 // Set initial luminance to 1
906906 ITextureView* pRTVs[] = {m_ptex2DAverageLuminanceRTV};
907907 pDeviceCtx->SetRenderTargets(1, pRTVs, nullptr, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
908908 pDeviceCtx->ClearRenderTarget(m_ptex2DAverageLuminanceRTV, TexDesc.ClearValue.Color, RESOURCE_STATE_TRANSITION_MODE_TRANSITION);
17471747 UnwarpAndRenderLuminanceTech.SRBDependencyFlags = SRBDependencies;
17481748 }
17491749
1750 // Unwarp inscattering image and apply it to attenuated backgorund
1750 // Unwarp inscattering image and apply it to attenuated background
17511751 if (bRenderLuminance)
17521752 {
17531753 UnwarpAndRenderLuminanceTech.PrepareSRB(m_FrameAttribs.pDevice, m_pResMapping, BIND_SHADER_RESOURCES_KEEP_EXISTING);
3838 and you agree that the content is free of any Intellectual Property claims and you have the right to license it under those terms.
3939
4040 Diligent Engine uses [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to ensure
41 consistent source code style throught the code base. The format is validated by appveyor and travis
41 consistent source code style throughout the code base. The format is validated by appveyor and travis
4242 for each commit and pull request, and the build will fail if any code formatting issue is found. Please refer
4343 to [this page](https://github.com/DiligentGraphics/DiligentCore/blob/master/doc/code_formatting.md) for instructions
4444 on how to set up clang-format and automatic code formatting.
190190 fDistToRayEnd = max(fDistToRayEnd, f2RayAtmTopIsecs.x);
191191
192192 // To properly compute scattering from the space, we must
193 // set up ray end position before extiting the loop
193 // set up ray end position before exiting the loop
194194 f3RayEnd = f3CameraPos + f3ViewDir * fDistToRayEnd;
195195 f3RayStart = f3CameraPos + f3ViewDir * fDistToRayStart;
196196
266266 }
267267 #endif
268268
269 // Calcualte ray step length in world space
269 // Calculate ray step length in world space
270270 float fRayStepLengthWS = fRayLength * (fShadowMapUVStepLen / fTraceLenInShadowMapUVSpace);
271271 // Note that fTraceLenInShadowMapUVSpace can be very small when looking directly at sun
272272 // Since fShadowMapUVStepLen is at least one shadow map texel in size,
7878 if( bIsValidThread )
7979 {
8080 #if REFINEMENT_CRITERION == REFINEMENT_CRITERION_DEPTH_DIFF
81 // Load camera space Z for this sample and for its right neighbour (remeber to use global sample index)
81 // Load camera space Z for this sample and for its right neighbour (remember to use global sample index)
8282 float fCamSpaceZ = g_tex2DEpipolarCamSpaceZ.Load( int3(uiGlobalSampleInd, uiSliceInd, 0) );
8383 float fRightNeighbCamSpaceZ = g_tex2DEpipolarCamSpaceZ.Load( int3( int(uiGlobalSampleInd)+1, uiSliceInd, 0) );
8484 float fMaxZ = max(fCamSpaceZ, fRightNeighbCamSpaceZ);
9494 // Compute minimum inscattering threshold based on the average scene luminance
9595 float fAverageLum = GetAverageSceneLuminance(g_tex2DAverageLuminance);
9696 // Inscattering threshold should be proportional to the average scene luminance and
97 // inversely proportional to the middle gray level (the higher middle gray, the briter the scene,
98 // thus the less the theshold)
97 // inversely proportional to the middle gray level (the higher middle gray, the brighter the scene,
98 // thus the less the threshold)
9999 // It should also account for the fact that rgb channels contribute differently
100 // to the percieved brightness. For r channel the threshold should be smallest,
100 // to the perceived brightness. For r channel the threshold should be smallest,
101101 // for b channel - the largest
102102 float3 f3MinInsctrThreshold = (0.02 * fAverageLum / RGB_TO_LUMINANCE.xyz) / g_PPAttribs.ToneMapping.fMiddleGray;
103103
142142 }
143143 uint uiInitialSample1Ind = uiInitialSample0Ind + uiInitialSampleStep;
144144
145 // Remeber that the last sample in each epipolar slice must be ray marching one
145 // Remember that the last sample in each epipolar slice must be ray marching one
146146 uint uiInterpolationTexWidth, uiInterpolationTexHeight;
147147 g_rwtex2DInterpolationSource.GetDimensions(uiInterpolationTexWidth, uiInterpolationTexHeight);
148148 if( Gid.x == uiInterpolationTexWidth/uint(THREAD_GROUP_SIZE) - 1u )
5252 float4 f4Boundaries = GetOutermostScreenPixelCoords(g_PPAttribs.f4ScreenResolution);
5353 bool4 b4IsCorrectIntersectionFlag = Greater( abs(f2RayDir.xyxy), 1e-5 * float4(1.0, 1.0, 1.0, 1.0) );
5454 float4 f4DistToBoundaries = (f4Boundaries - g_PPAttribs.f4LightScreenPos.xyxy) / (f2RayDir.xyxy + BoolToFloat( Not(b4IsCorrectIntersectionFlag) ) );
55 // Addition of !b4IsCorrectIntersectionFlag is required to prevent divison by zero
55 // Addition of !b4IsCorrectIntersectionFlag is required to prevent division by zero
5656 // Note that such incorrect lanes will be masked out anyway
5757
5858 // We now need to find first intersection BEFORE the intersection with the exit boundary
134134
135135 // Note that in fact the outermost visible screen pixels do not lie exactly on the boundary (+1 or -1), but are biased by
136136 // 0.5 screen pixel size inwards. Using these adjusted boundaries improves precision and results in
137 // samller number of pixels which require inscattering correction
137 // smaller number of pixels which require inscattering correction
138138 float4 f4OutermostScreenPixelCoords = GetOutermostScreenPixelCoords(g_PPAttribs.f4ScreenResolution);// xyzw = (left, bottom, right, top)
139139
140140 // Check if there can definitely be no correct intersection with the boundary:
127127 BOOL bShowLightingOnly DEFAULT_VALUE(FALSE);
128128 // Optimize sample locations to avoid oversampling. This should generally be TRUE.
129129 BOOL bOptimizeSampleLocations DEFAULT_VALUE(TRUE);
130 // Wether to enable light shafts or render unshadowed inscattering.
130 // Whether to enable light shafts or render unshadowed inscattering.
131131 // Setting this to FALSE increases performance, but reduces visual quality.
132132 BOOL bEnableLightShafts DEFAULT_VALUE(TRUE);
133133 // Number of inscattering integral steps taken when computing unshadowed inscattering (default is OK).
181181 BOOL bUseCustomSctrCoeffs DEFAULT_VALUE(FALSE);
182182 // Aerosol density scale to use for scattering coefficient computation.
183183 float fAerosolDensityScale DEFAULT_VALUE(1.f);
184 // Aerosol absorbtion scale to use for scattering coefficient computation.
184 // Aerosol absorption scale to use for scattering coefficient computation.
185185 float fAerosolAbsorbtionScale DEFAULT_VALUE(0.1f);
186186
187187 // Custom Rayleigh coefficients.
127127 " BOOL bShowLightingOnly DEFAULT_VALUE(FALSE);\n"
128128 " // Optimize sample locations to avoid oversampling. This should generally be TRUE.\n"
129129 " BOOL bOptimizeSampleLocations DEFAULT_VALUE(TRUE);\n"
130 " // Wether to enable light shafts or render unshadowed inscattering.\n"
130 " // Whether to enable light shafts or render unshadowed inscattering.\n"
131131 " // Setting this to FALSE increases performance, but reduces visual quality.\n"
132132 " BOOL bEnableLightShafts DEFAULT_VALUE(TRUE);\n"
133133 " // Number of inscattering integral steps taken when computing unshadowed inscattering (default is OK).\n"
181181 " BOOL bUseCustomSctrCoeffs DEFAULT_VALUE(FALSE);\n"
182182 " // Aerosol density scale to use for scattering coefficient computation.\n"
183183 " float fAerosolDensityScale DEFAULT_VALUE(1.f);\n"
184 " // Aerosol absorbtion scale to use for scattering coefficient computation.\n"
184 " // Aerosol absorption scale to use for scattering coefficient computation.\n"
185185 " float fAerosolAbsorbtionScale DEFAULT_VALUE(0.1f);\n"
186186 "\n"
187187 " // Custom Rayleigh coefficients.\n"
190190 " fDistToRayEnd = max(fDistToRayEnd, f2RayAtmTopIsecs.x);\n"
191191 " \n"
192192 " // To properly compute scattering from the space, we must \n"
193 " // set up ray end position before extiting the loop\n"
193 " // set up ray end position before exiting the loop\n"
194194 " f3RayEnd = f3CameraPos + f3ViewDir * fDistToRayEnd;\n"
195195 " f3RayStart = f3CameraPos + f3ViewDir * fDistToRayStart;\n"
196196 "\n"
266266 " }\n"
267267 " #endif\n"
268268 "\n"
269 " // Calcualte ray step length in world space\n"
269 " // Calculate ray step length in world space\n"
270270 " float fRayStepLengthWS = fRayLength * (fShadowMapUVStepLen / fTraceLenInShadowMapUVSpace);\n"
271271 " // Note that fTraceLenInShadowMapUVSpace can be very small when looking directly at sun\n"
272272 " // Since fShadowMapUVStepLen is at least one shadow map texel in size, \n"
7878 " if( bIsValidThread )\n"
7979 " {\n"
8080 "#if REFINEMENT_CRITERION == REFINEMENT_CRITERION_DEPTH_DIFF\n"
81 " // Load camera space Z for this sample and for its right neighbour (remeber to use global sample index)\n"
81 " // Load camera space Z for this sample and for its right neighbour (remember to use global sample index)\n"
8282 " float fCamSpaceZ = g_tex2DEpipolarCamSpaceZ.Load( int3(uiGlobalSampleInd, uiSliceInd, 0) );\n"
8383 " float fRightNeighbCamSpaceZ = g_tex2DEpipolarCamSpaceZ.Load( int3( int(uiGlobalSampleInd)+1, uiSliceInd, 0) );\n"
8484 " float fMaxZ = max(fCamSpaceZ, fRightNeighbCamSpaceZ);\n"
9494 " // Compute minimum inscattering threshold based on the average scene luminance\n"
9595 " float fAverageLum = GetAverageSceneLuminance(g_tex2DAverageLuminance);\n"
9696 " // Inscattering threshold should be proportional to the average scene luminance and\n"
97 " // inversely proportional to the middle gray level (the higher middle gray, the briter the scene,\n"
98 " // thus the less the theshold)\n"
97 " // inversely proportional to the middle gray level (the higher middle gray, the brighter the scene,\n"
98 " // thus the less the threshold)\n"
9999 " // It should also account for the fact that rgb channels contribute differently\n"
100 " // to the percieved brightness. For r channel the threshold should be smallest, \n"
100 " // to the perceived brightness. For r channel the threshold should be smallest, \n"
101101 " // for b channel - the largest\n"
102102 " float3 f3MinInsctrThreshold = (0.02 * fAverageLum / RGB_TO_LUMINANCE.xyz) / g_PPAttribs.ToneMapping.fMiddleGray;\n"
103103 "\n"
142142 " }\n"
143143 " uint uiInitialSample1Ind = uiInitialSample0Ind + uiInitialSampleStep;\n"
144144 "\n"
145 " // Remeber that the last sample in each epipolar slice must be ray marching one\n"
145 " // Remember that the last sample in each epipolar slice must be ray marching one\n"
146146 " uint uiInterpolationTexWidth, uiInterpolationTexHeight;\n"
147147 " g_rwtex2DInterpolationSource.GetDimensions(uiInterpolationTexWidth, uiInterpolationTexHeight);\n"
148148 " if( Gid.x == uiInterpolationTexWidth/uint(THREAD_GROUP_SIZE) - 1u )\n"
5252 " float4 f4Boundaries = GetOutermostScreenPixelCoords(g_PPAttribs.f4ScreenResolution);\n"
5353 " bool4 b4IsCorrectIntersectionFlag = Greater( abs(f2RayDir.xyxy), 1e-5 * float4(1.0, 1.0, 1.0, 1.0) );\n"
5454 " float4 f4DistToBoundaries = (f4Boundaries - g_PPAttribs.f4LightScreenPos.xyxy) / (f2RayDir.xyxy + BoolToFloat( Not(b4IsCorrectIntersectionFlag) ) );\n"
55 " // Addition of !b4IsCorrectIntersectionFlag is required to prevent divison by zero\n"
55 " // Addition of !b4IsCorrectIntersectionFlag is required to prevent division by zero\n"
5656 " // Note that such incorrect lanes will be masked out anyway\n"
5757 "\n"
5858 " // We now need to find first intersection BEFORE the intersection with the exit boundary\n"
134134 "\n"
135135 " // Note that in fact the outermost visible screen pixels do not lie exactly on the boundary (+1 or -1), but are biased by\n"
136136 " // 0.5 screen pixel size inwards. Using these adjusted boundaries improves precision and results in\n"
137 " // samller number of pixels which require inscattering correction\n"
137 " // smaller number of pixels which require inscattering correction\n"
138138 " float4 f4OutermostScreenPixelCoords = GetOutermostScreenPixelCoords(g_PPAttribs.f4ScreenResolution);// xyzw = (left, bottom, right, top)\n"
139139 "\n"
140140 " // Check if there can definitely be no correct intersection with the boundary:\n"