mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
[Postprocessing] Stereo integration
This commit is contained in:
parent
15c7ed774c
commit
b0e4c7e76a
29 changed files with 578 additions and 179 deletions
|
@ -29,6 +29,19 @@ namespace
|
|||
#endif
|
||||
omw_Out vec2 omw_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
omw_Position = vec4(omw_Vertex.xy, 0.0, 1.0);
|
||||
omw_TexCoord = omw_Position.xy * 0.5 + 0.5;
|
||||
})GLSL";
|
||||
|
||||
constexpr char s_DefaultVertexMultiview[] = R"GLSL(
|
||||
layout(num_views = 2) in;
|
||||
#if OMW_USE_BINDINGS
|
||||
omw_In vec2 omw_Vertex;
|
||||
#endif
|
||||
omw_Out vec2 omw_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
omw_Position = vec4(omw_Vertex.xy, 0.0, 1.0);
|
||||
|
@ -81,6 +94,11 @@ uniform @builtinSampler omw_SamplerNormals;
|
|||
uniform vec4 omw_PointLights[@pointLightCount];
|
||||
uniform int omw_PointLightsCount;
|
||||
|
||||
#if OMW_MULTIVIEW
|
||||
uniform mat4 projectionMatrixMultiView[2];
|
||||
uniform mat4 invProjectionMatrixMultiView[2];
|
||||
#endif
|
||||
|
||||
int omw_GetPointLightCount()
|
||||
{
|
||||
return omw_PointLightsCount;
|
||||
|
@ -112,6 +130,25 @@ float omw_GetPointLightRadius(int index)
|
|||
uniform _omw_data omw;
|
||||
#endif
|
||||
|
||||
|
||||
mat4 omw_ProjectionMatrix()
|
||||
{
|
||||
#if OMW_MULTIVIEW
|
||||
return projectionMatrixMultiView[gl_ViewID_OVR];
|
||||
#else
|
||||
return omw.projectionMatrix;
|
||||
#endif
|
||||
}
|
||||
|
||||
mat4 omw_InvProjectionMatrix()
|
||||
{
|
||||
#if OMW_MULTIVIEW
|
||||
return invProjectionMatrixMultiView[gl_ViewID_OVR];
|
||||
#else
|
||||
return omw.invProjectionMatrix;
|
||||
#endif
|
||||
}
|
||||
|
||||
float omw_GetDepth(vec2 uv)
|
||||
{
|
||||
#if OMW_MULTIVIEW
|
||||
|
@ -266,7 +303,7 @@ float omw_GetPointLightRadius(int index)
|
|||
if (mType == Type::Pixel)
|
||||
{
|
||||
if (!mVertex)
|
||||
mVertex = new osg::Shader(osg::Shader::VERTEX, s_DefaultVertex);
|
||||
mVertex = new osg::Shader(osg::Shader::VERTEX, Stereo::getMultiview() ? s_DefaultVertexMultiview : s_DefaultVertex);
|
||||
|
||||
mVertex->setShaderSource(getPassHeader(technique, preamble).append(mVertex->getShaderSource()));
|
||||
mFragment->setShaderSource(getPassHeader(technique, preamble, true).append(mFragment->getShaderSource()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue