-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shaders: Add GLSL port of accum_volumetric.
- Loading branch information
Showing
21 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "common.h" | ||
#include "iostructs\v_volume.h" | ||
|
||
////////////////////////////////////////////////////////////////////////////////////////// | ||
uniform float4x4 m_texgen; | ||
#ifdef USE_SJITTER | ||
uniform float4x4 m_texgen_J; | ||
#endif | ||
|
||
////////////////////////////////////////////////////////////////////////////////////////// | ||
// Vertex | ||
v2p_volume _main ( float4 P ) | ||
{ | ||
v2p_volume O; | ||
O.hpos = mul( m_WVP, P ); | ||
O.tc = mul( m_texgen, P ); | ||
#ifdef USE_SJITTER | ||
O.tcJ = mul( m_texgen_J, P ); | ||
#endif | ||
return O; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "common.h" | ||
#include "iostructs\v_volumetric.h" | ||
|
||
//cbuffer VolumetricLights | ||
//{ | ||
uniform float3 vMinBounds; | ||
uniform float3 vMaxBounds; | ||
uniform float4 FrustumClipPlane[6]; | ||
//} | ||
|
||
v2p _main ( float3 P ) | ||
{ | ||
v2p o; | ||
float4 vPos; | ||
vPos.xyz = lerp( vMinBounds, vMaxBounds, P); // Position in camera space | ||
vPos.w = 1; | ||
o.hpos = mul (m_P, vPos); // xform, input in camera coordinates | ||
|
||
o.lightToPos = vPos.xyz - Ldynamic_pos.xyz; | ||
o.vPos = vPos.xyz; | ||
|
||
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0f; | ||
// o.fDensity = (vMaxBounds.z-vMinBounds.z)/2000.0f*2; | ||
o.fDensity = 1.0f/40.0f; | ||
// o.fDensity = 1.0f/20.0f; | ||
|
||
for (int i=0; i<3; ++i) | ||
{ | ||
o.clip0[i] = dot( o.hpos, FrustumClipPlane[i]); | ||
o.clip1[i] = dot( o.hpos, FrustumClipPlane[i+3]); | ||
} | ||
|
||
return o; | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "accum_volumetric.vs" |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
out vec4 SV_Target; | ||
#ifdef MSAA_OPTIMIZATION | ||
in int gl_SampleID; | ||
#endif | ||
|
||
struct v2p | ||
{ | ||
float3 lightToPos ; // TEXCOORD0; // light center to plane vector | ||
float3 vPos ; // TEXCOORD1; // position in camera space | ||
float fDensity ; // TEXCOORD2; // plane density along Z axis | ||
// float2 tNoise ; // TEXCOORD3; // projective noise | ||
}; | ||
|
||
layout(location = TEXCOORD0) in float3 v2p_lightToPos ; // TEXCOORD0; // light center to plane vector | ||
layout(location = TEXCOORD1) in float3 v2p_vPos ; // TEXCOORD1; // position in camera space | ||
layout(location = TEXCOORD2) in float v2p_fDensity ; // TEXCOORD2; // plane density along Z axis | ||
//layout(location = TEXCOORD3) in float2 v2p_tNoise ; // TEXCOORD3; // projective noise | ||
|
||
#ifdef MSAA_OPTIMIZATION | ||
float4 _main ( v2p I, uint iSample ); | ||
#else | ||
float4 _main ( v2p I ); | ||
#endif | ||
|
||
void main() | ||
{ | ||
v2p I; | ||
I.lightToPos = v2p_lightToPos; | ||
I.vPos = v2p_vPos; | ||
I.fDensity = v2p_fDensity; | ||
// I.tNoise = v2p_tNoise; | ||
|
||
#ifdef MSAA_OPTIMIZATION | ||
SV_Target = _main ( I, gl_SampleID ); | ||
#else | ||
SV_Target = _main ( I ); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
out gl_PerVertex | ||
{ | ||
vec4 gl_Position; | ||
float gl_ClipDistance[6]; | ||
}; | ||
|
||
struct v2p | ||
{ | ||
float3 lightToPos ; // TEXCOORD0; // light center to plane vector | ||
float3 vPos ; // TEXCOORD1; // position in camera space | ||
float fDensity ; // TEXCOORD2; // plane density alon Z axis | ||
// float2 tNoise ; // TEXCOORD3; // projective noise | ||
float3 clip0 ; // SV_ClipDistance0; | ||
float3 clip1 ; // SV_ClipDistance1; | ||
float4 hpos ; // SV_Position; | ||
}; | ||
|
||
layout(location = POSITION) in float3 v_volumetric_P; | ||
|
||
layout(location = TEXCOORD0) out float3 v2p_lightToPos ; // TEXCOORD0; // light center to plane vector | ||
layout(location = TEXCOORD1) out float3 v2p_vPos ; // TEXCOORD1; // position in camera space | ||
layout(location = TEXCOORD2) out float v2p_fDensity ; // TEXCOORD2; // plane density alon Z axis | ||
//layout(location = TEXCOORD3) out float2 v2p_tNoise ; // TEXCOORD3; // projective noise | ||
|
||
v2p _main ( float3 P ); | ||
|
||
void main() | ||
{ | ||
v2p O = _main ( v_volumetric_P ); | ||
v2p_lightToPos = O.lightToPos; | ||
v2p_vPos = O.vPos; | ||
v2p_fDensity = O.fDensity; | ||
// v2p_tNoise = O.tNoise; | ||
gl_Position = O.hpos; | ||
for (int i=0; i<3; ++i) | ||
{ | ||
gl_ClipDistance[i] = O.clip0[i]; | ||
gl_ClipDistance[i+3] = O.clip1[i]; | ||
} | ||
} |