Revisión | d8e83d6c3af9eaec14cdbe1eaa7f993aec7a282c (tree) |
---|---|
Tiempo | 2019-09-16 12:52:40 |
Autor | Matias N. Goldberg <dark_ <sylinc@yaho...> |
Commiter | Matias N. Goldberg <dark_ |
Ported radial density mask to D3D11
Bugfix: RdmMedium quality behaving like RdmLow
@@ -240,7 +240,7 @@ | ||
240 | 240 | mReconstructJob->setPiece( "Quality", qualityStr[quality] ); |
241 | 241 | for( int32 i = 0; i < 3; ++i ) |
242 | 242 | mReconstructJob->setProperty( qualityProp[i], i + 1 ); |
243 | - mReconstructJob->setProperty( "quality", static_cast<int32>( quality ) ); | |
243 | + mReconstructJob->setProperty( "quality", static_cast<int32>( quality ) + 1 ); | |
244 | 244 | } |
245 | 245 | //------------------------------------------------------------------------- |
246 | 246 | void RadialDensityMask::setEyesCenter( const Vector2 &leftEyeCenter, const Vector2 &rightEyeCenter ) |
@@ -140,9 +140,11 @@ | ||
140 | 140 | mHMD->GetRecommendedRenderTargetSize( &width, &height ); |
141 | 141 | |
142 | 142 | Ogre::TextureGpuManager *textureManager = mRoot->getRenderSystem()->getTextureGpuManager(); |
143 | + //Radial Density Mask requires the VR texture to be UAV & reinterpretable | |
143 | 144 | mVrTexture = textureManager->createOrRetrieveTexture( "OpenVR Both Eyes", |
144 | 145 | Ogre::GpuPageOutStrategy::Discard, |
145 | 146 | Ogre::TextureFlags::RenderToTexture | |
147 | + Ogre::TextureFlags::Uav | | |
146 | 148 | Ogre::TextureFlags::Reinterpretable, |
147 | 149 | Ogre::TextureTypes::Type2D ); |
148 | 150 | mVrTexture->setResolution( width << 1u, height ); |
@@ -35,5 +35,5 @@ | ||
35 | 35 | else if( !((iFragCoordHalf.x & 0x03u) != 0u || (iFragCoordHalf.y & 0x03u) != 0u) ) |
36 | 36 | discard; |
37 | 37 | |
38 | - fragColour = vec4( 0 ); | |
38 | + fragColour = float4( 0, 0, 0, 0 ); | |
39 | 39 | } |
@@ -0,0 +1,35 @@ | ||
1 | + | |
2 | +#define p_leftEyeCenter leftEyeCenter_rightEyeCenter.xy | |
3 | +#define p_rightEyeCenter leftEyeCenter_rightEyeCenter.zw | |
4 | +#define p_rightEyeStart rightEyeStart_radius.x | |
5 | +#define p_radius rightEyeStart_radius.yzw | |
6 | +#define p_invBlockResolution invBlockResolution | |
7 | + | |
8 | +float4 main | |
9 | +( | |
10 | + float4 gl_FragCoord : SV_Position, | |
11 | + | |
12 | + uniform float4 rightEyeStart_radius, | |
13 | + uniform float4 leftEyeCenter_rightEyeCenter, | |
14 | + uniform float2 invBlockResolution | |
15 | +) : SV_Target | |
16 | +{ | |
17 | + float2 eyeCenter = gl_FragCoord.x >= p_rightEyeStart ? p_rightEyeCenter : p_leftEyeCenter; | |
18 | + | |
19 | + //We must work in blocks so the reconstruction filter can work properly | |
20 | + float2 toCenter = trunc(gl_FragCoord.xy * 0.125f) * p_invBlockResolution.xy - eyeCenter; | |
21 | + toCenter.x *= 2.0f; //Twice because of stereo (each eye is half the size of the full res) | |
22 | + float distToCenter = length( toCenter ); | |
23 | + | |
24 | + uint2 iFragCoordHalf = uint2( gl_FragCoord.xy * 0.5f ); | |
25 | + if( distToCenter < p_radius.x ) | |
26 | + discard; | |
27 | + else if( (iFragCoordHalf.x & 0x01u) == (iFragCoordHalf.y & 0x01u) && distToCenter < p_radius.y ) | |
28 | + discard; | |
29 | + else if( !((iFragCoordHalf.x & 0x01u) != 0u || (iFragCoordHalf.y & 0x01u) != 0u) && distToCenter < p_radius.z ) | |
30 | + discard; | |
31 | + else if( !((iFragCoordHalf.x & 0x03u) != 0u || (iFragCoordHalf.y & 0x03u) != 0u) ) | |
32 | + discard; | |
33 | + | |
34 | + return float4( 0, 0, 0, 0 ); | |
35 | +} |
@@ -0,0 +1,31 @@ | ||
1 | +struct VS_INPUT | |
2 | +{ | |
3 | + float2 vertex : POSITION; | |
4 | + uint vertexId : SV_VertexID; | |
5 | + #define gl_VertexID input.vertexId | |
6 | +}; | |
7 | + | |
8 | +struct PS_INPUT | |
9 | +{ | |
10 | + float4 gl_Position : SV_Position; | |
11 | + uint gl_ViewportIndex : SV_ViewportArrayIndex; | |
12 | +}; | |
13 | + | |
14 | +PS_INPUT main | |
15 | +( | |
16 | + VS_INPUT input, | |
17 | + | |
18 | + uniform float ogreBaseVertex, | |
19 | + uniform float2 rsDepthRange, | |
20 | + uniform matrix worldViewProj | |
21 | +) | |
22 | +{ | |
23 | + PS_INPUT outVs; | |
24 | + | |
25 | + outVs.gl_Position.xy= mul( worldViewProj, float4( input.vertex.xy, 0.0f, 1.0f ) ).xy; | |
26 | + outVs.gl_Position.z = rsDepthRange.x; | |
27 | + outVs.gl_Position.w = 1.0f; | |
28 | + outVs.gl_ViewportIndex = gl_VertexID >= (3 * 4) ? 1 : 0; | |
29 | + | |
30 | + return outVs; | |
31 | +} |
@@ -12,6 +12,10 @@ | ||
12 | 12 | |
13 | 13 | uniform sampler2D srcTex; |
14 | 14 | |
15 | +layout( local_size_x = @value( threads_per_group_x ), | |
16 | + local_size_y = @value( threads_per_group_y ), | |
17 | + local_size_z = @value( threads_per_group_z ) ) in; | |
18 | + | |
15 | 19 | @insertpiece( HeaderCS ) |
16 | 20 | |
17 | 21 | void main() |
@@ -15,11 +15,12 @@ | ||
15 | 15 | |
16 | 16 | #define short2 int2 |
17 | 17 | #define ushort2 uint2 |
18 | -#define OGRE_imageWrite3D4( outImage, iuv, value ) outImage[uint2( iuv )] = value | |
18 | +#define OGRE_imageWrite2D4( outImage, iuv, value ) outImage[uint2( iuv )] = value | |
19 | 19 | |
20 | 20 | RWTexture2D<@insertpiece(uav0_pf_type)> dstTex : register(u0); |
21 | 21 | |
22 | -Texture2D srcTex : register(t0); | |
22 | +Texture2D srcTex : register(t0); | |
23 | +SamplerState bilinearSampler : register(s0); | |
23 | 24 | |
24 | 25 | @insertpiece( HeaderCS ) |
25 | 26 |
@@ -14,10 +14,6 @@ | ||
14 | 14 | #define invBlockResolution invBlockResolution_invResolution.xy |
15 | 15 | #define invResolution invBlockResolution_invResolution.zw |
16 | 16 | |
17 | - layout( local_size_x = @value( threads_per_group_x ), | |
18 | - local_size_y = @value( threads_per_group_y ), | |
19 | - local_size_z = @value( threads_per_group_z ) ) in; | |
20 | - | |
21 | 17 | @insertpiece( DeclSRgbFuncs ) |
22 | 18 | |
23 | 19 | /** Takes the pattern (low quality): |