Manually unroll rh shader
This commit is contained in:
parent
07bff38427
commit
4829b8ddd8
@ -32,26 +32,10 @@ vec4 DirToSh(vec3 dir, float flux)
|
|||||||
return SHBasis (dir) * flux;
|
return SHBasis (dir) * flux;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
void loop(in int i,
|
||||||
|
in vec3 RHcenter,in vec3 RHCellSize, in vec2 RHuv, in float RHdepth,
|
||||||
|
inout vec4 SHr, inout vec4 SHg, inout vec4 SHb)
|
||||||
{
|
{
|
||||||
vec3 normalizedRHCenter = 2. * vec3(gl_FragCoord.xy, slice) / resolution - 1.;
|
|
||||||
vec3 RHcenter = (RHMatrix * vec4(normalizedRHCenter * extents, 1.)).xyz;
|
|
||||||
|
|
||||||
vec4 ShadowProjectedRH = RSMMatrix * vec4(RHcenter, 1.);
|
|
||||||
|
|
||||||
vec3 RHCellSize = extents / resolution;
|
|
||||||
vec2 RHuv = .5 * ShadowProjectedRH.xy / ShadowProjectedRH.w + .5;
|
|
||||||
float RHdepth = .5 * ShadowProjectedRH.z / ShadowProjectedRH.w + .5;
|
|
||||||
|
|
||||||
vec4 SHr = vec4(0.);
|
|
||||||
vec4 SHg = vec4(0.);
|
|
||||||
vec4 SHb = vec4(0.);
|
|
||||||
|
|
||||||
int x = int(gl_FragCoord.x), y = int(gl_FragCoord.y);
|
|
||||||
float phi = 30. * (x ^ y) + 10. * x * y;
|
|
||||||
|
|
||||||
for (int i = 0; i < SAMPLES; i++)
|
|
||||||
{
|
|
||||||
// produce a new sample location on the RSM texture
|
// produce a new sample location on the RSM texture
|
||||||
float alpha = (i + .5) / SAMPLES;
|
float alpha = (i + .5) / SAMPLES;
|
||||||
float theta = 2. * 3.14 * 7. * alpha;
|
float theta = 2. * 3.14 * 7. * alpha;
|
||||||
@ -83,7 +67,28 @@ void main(void)
|
|||||||
SHr += DirToSh(RSM_to_RH_dir, color.r);
|
SHr += DirToSh(RSM_to_RH_dir, color.r);
|
||||||
SHg += DirToSh(RSM_to_RH_dir, color.g);
|
SHg += DirToSh(RSM_to_RH_dir, color.g);
|
||||||
SHb += DirToSh(RSM_to_RH_dir, color.b);
|
SHb += DirToSh(RSM_to_RH_dir, color.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
vec3 normalizedRHCenter = 2. * vec3(gl_FragCoord.xy, slice) / resolution - 1.;
|
||||||
|
vec3 RHcenter = (RHMatrix * vec4(normalizedRHCenter * extents, 1.)).xyz;
|
||||||
|
|
||||||
|
vec4 ShadowProjectedRH = RSMMatrix * vec4(RHcenter, 1.);
|
||||||
|
|
||||||
|
vec3 RHCellSize = extents / resolution;
|
||||||
|
vec2 RHuv = .5 * ShadowProjectedRH.xy / ShadowProjectedRH.w + .5;
|
||||||
|
float RHdepth = .5 * ShadowProjectedRH.z / ShadowProjectedRH.w + .5;
|
||||||
|
|
||||||
|
vec4 SHr = vec4(0.);
|
||||||
|
vec4 SHg = vec4(0.);
|
||||||
|
vec4 SHb = vec4(0.);
|
||||||
|
|
||||||
|
int x = int(gl_FragCoord.x), y = int(gl_FragCoord.y);
|
||||||
|
float phi = 30. * (x ^ y) + 10. * x * y;
|
||||||
|
|
||||||
|
loop(0, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||||
|
loop(1, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||||
|
|
||||||
SHr /= 3.14159 * SAMPLES;
|
SHr /= 3.14159 * SAMPLES;
|
||||||
SHg /= 3.14159 * SAMPLES;
|
SHg /= 3.14159 * SAMPLES;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user