summaryrefslogtreecommitdiffstats
path: root/shaders_inc/CoarseInsctr.fx.h
blob: 36f82167219094e8515048c21273bae9abcc4b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"// CoarseInsctr.fx:\n"
"// Renders coarse unshadowed inscattering for EVERY epipolar sample and computes extinction.\n"
"// Coarse inscattering is used to refine sampling, while extinction is then transformed to \n"
"// screen space, if extinction evaluation mode is EXTINCTION_EVAL_MODE_EPIPOLAR\n"
"\n"
"#include \"BasicStructures.fxh\"\n"
"#include \"AtmosphereShadersCommon.fxh\"\n"
"\n"
"cbuffer cbParticipatingMediaScatteringParams\n"
"{\n"
"    AirScatteringAttribs g_MediaParams;\n"
"}\n"
"\n"
"cbuffer cbCameraAttribs\n"
"{\n"
"    CameraAttribs g_CameraAttribs;\n"
"}\n"
"\n"
"cbuffer cbLightParams\n"
"{\n"
"    LightAttribs g_LightAttribs;\n"
"}\n"
"\n"
"cbuffer cbPostProcessingAttribs\n"
"{\n"
"    EpipolarLightScatteringAttribs g_PPAttribs;\n"
"};\n"
"\n"
"Texture2D<float2> g_tex2DOccludedNetDensityToAtmTop;\n"
"SamplerState      g_tex2DOccludedNetDensityToAtmTop_sampler;\n"
"\n"
"Texture2D<float>  g_tex2DEpipolarCamSpaceZ;\n"
"\n"
"Texture2D<float2> g_tex2DCoordinates;\n"
"\n"
"Texture3D<float3> g_tex3DSingleSctrLUT;\n"
"SamplerState      g_tex3DSingleSctrLUT_sampler;\n"
"\n"
"Texture3D<float3> g_tex3DHighOrderSctrLUT;\n"
"SamplerState      g_tex3DHighOrderSctrLUT_sampler;\n"
"\n"
"Texture3D<float3> g_tex3DMultipleSctrLUT;\n"
"SamplerState      g_tex3DMultipleSctrLUT_sampler;\n"
"\n"
"#include \"LookUpTables.fxh\"\n"
"#include \"ScatteringIntegrals.fxh\"\n"
"#include \"Extinction.fxh\"\n"
"#include \"UnshadowedScattering.fxh\"\n"
"\n"
"void ShaderFunctionInternal(in float4  f4Pos,\n"
"                            out float3 f3Inscattering, \n"
"                            out float3 f3Extinction)\n"
"{\n"
"    // Compute unshadowed inscattering from the camera to the ray end point using few steps\n"
"    float fCamSpaceZ =  g_tex2DEpipolarCamSpaceZ.Load( uint3(f4Pos.xy, 0) );\n"
"    float2 f2SampleLocation = g_tex2DCoordinates.Load( uint3(f4Pos.xy, 0) );\n"
"\n"
"    ComputeUnshadowedInscattering(f2SampleLocation, fCamSpaceZ, \n"
"                                  7u, // Use hard-coded constant here so that compiler can optimize the code\n"
"                                      // more efficiently\n"
"                                  g_PPAttribs.f4EarthCenter.xyz,\n"
"                                  f3Inscattering, f3Extinction);\n"
"    f3Inscattering *= g_LightAttribs.f4Intensity.rgb;\n"
"}\n"
"\n"
"// Render inscattering only\n"
"void RenderCoarseUnshadowedInsctrPS(FullScreenTriangleVSOutput VSOut, \n"
"                                    // IMPORTANT: non-system generated pixel shader input\n"
"                                    // arguments must have the exact same name as vertex shader \n"
"                                    // outputs and must go in the same order.\n"
"                                    // Moreover, even if the shader is not using the argument,\n"
"                                    // it still must be declared.\n"
"\n"
"                                    out float4 f4Inscattering : SV_Target0) \n"
"{\n"
"    float3 f3Extinction = float3(1.0, 1.0, 1.0);\n"
"    ShaderFunctionInternal(VSOut.f4PixelPos, f4Inscattering.rgb, f3Extinction );\n"
"    f4Inscattering.a = 1.0;\n"
"}\n"
"\n"
"// Render inscattering and extinction\n"
"void RenderCoarseUnshadowedInsctrAndExtinctionPS(FullScreenTriangleVSOutput VSOut,\n"
"                                                 out float4 f4Inscattering : SV_Target0,\n"
"                                                 out float4 f4Extinction   : SV_Target1) \n"
"{\n"
"    ShaderFunctionInternal(VSOut.f4PixelPos, f4Inscattering.rgb, f4Extinction.rgb );\n"
"    f4Inscattering.a = 0.0;\n"
"    f4Extinction.a = 0.0;\n"
"}\n"