49 Q_UNUSED( frameGraph )
50 mColorTextureParameter =
new Qt3DRender::QParameter( QStringLiteral(
"colorTexture" ), frameGraph->
forwardRenderColorTexture() );
51 mDepthTextureParameter =
new Qt3DRender::QParameter( QStringLiteral(
"depthTexture" ), frameGraph->
forwardRenderDepthTexture() );
52 mShadowMapParameter =
new Qt3DRender::QParameter( QStringLiteral(
"shadowTexture" ), frameGraph->
shadowMapTexture() );
54 mMaterial->addParameter( mColorTextureParameter );
55 mMaterial->addParameter( mDepthTextureParameter );
56 mMaterial->addParameter( mShadowMapParameter );
57 mMaterial->addParameter( mAmbientOcclusionTextureParameter );
62 mFarPlaneParameter =
new Qt3DRender::QParameter( QStringLiteral(
"farPlane" ), mMainCamera->farPlane() );
63 mMaterial->addParameter( mFarPlaneParameter );
64 connect( mMainCamera, &Qt3DRender::QCamera::farPlaneChanged, mFarPlaneParameter, [&](
float farPlane )
66 mFarPlaneParameter->setValue( farPlane );
68 mNearPlaneParameter =
new Qt3DRender::QParameter( QStringLiteral(
"nearPlane" ), mMainCamera->nearPlane() );
69 mMaterial->addParameter( mNearPlaneParameter );
70 connect( mMainCamera, &Qt3DRender::QCamera::nearPlaneChanged, mNearPlaneParameter, [&](
float nearPlane )
72 mNearPlaneParameter->setValue( nearPlane );
75 mLightFarPlaneParameter =
new Qt3DRender::QParameter( QStringLiteral(
"lightFarPlane" ), mLightCamera->farPlane() );
76 mMaterial->addParameter( mLightFarPlaneParameter );
77 connect( mLightCamera, &Qt3DRender::QCamera::farPlaneChanged, mLightFarPlaneParameter, [&](
float farPlane )
79 mLightFarPlaneParameter->setValue( farPlane );
81 mLightNearPlaneParameter =
new Qt3DRender::QParameter( QStringLiteral(
"lightNearPlane" ), mLightCamera->nearPlane() );
82 mMaterial->addParameter( mLightNearPlaneParameter );
83 connect( mLightCamera, &Qt3DRender::QCamera::nearPlaneChanged, mLightNearPlaneParameter, [&](
float nearPlane )
85 mLightNearPlaneParameter->setValue( nearPlane );
88 mMainCameraInvViewMatrixParameter =
new Qt3DRender::QParameter( QStringLiteral(
"invertedCameraView" ), mMainCamera->viewMatrix().inverted() );
89 mMaterial->addParameter( mMainCameraInvViewMatrixParameter );
90 mMainCameraInvProjMatrixParameter =
new Qt3DRender::QParameter( QStringLiteral(
"invertedCameraProj" ), mMainCamera->projectionMatrix().inverted() );
91 mMaterial->addParameter( mMainCameraInvProjMatrixParameter );
92 connect( mMainCamera, &Qt3DRender::QCamera::projectionMatrixChanged, mMainCameraInvProjMatrixParameter, [&](
const QMatrix4x4 & projectionMatrix )
94 mMainCameraInvProjMatrixParameter->setValue( projectionMatrix.inverted() );
96 connect( mMainCamera, &Qt3DRender::QCamera::viewMatrixChanged, mMainCameraInvViewMatrixParameter, [&]()
98 mMainCameraInvViewMatrixParameter->setValue( mMainCamera->viewMatrix().inverted() );
101 mShadowMinX =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMinX" ), QVariant::fromValue( 0.0f ) );
102 mShadowMaxX =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMaxX" ), QVariant::fromValue( 0.0f ) );
103 mShadowMinY =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMinY" ), QVariant::fromValue( 0.0f ) );
104 mShadowMaxY =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMaxY" ), QVariant::fromValue( 0.0f ) );
110 mRenderShadowsParameter =
new Qt3DRender::QParameter( QStringLiteral(
"renderShadows" ), QVariant::fromValue( 0 ) );
111 mMaterial->addParameter( mRenderShadowsParameter );
113 mShadowBiasParameter =
new Qt3DRender::QParameter( QStringLiteral(
"shadowBias" ), QVariant::fromValue( 0.00001f ) );
114 mMaterial->addParameter( mShadowBiasParameter );
116 mEyeDomeLightingEnabledParameter =
new Qt3DRender::QParameter( QStringLiteral(
"edlEnabled" ), QVariant::fromValue( 0 ) );
117 mEyeDomeLightingStrengthParameter =
new Qt3DRender::QParameter( QStringLiteral(
"edlStrength" ), QVariant::fromValue( 1000.0f ) );
118 mEyeDomeLightingDistanceParameter =
new Qt3DRender::QParameter( QStringLiteral(
"edlDistance" ), QVariant::fromValue( 2.0f ) );
119 mMaterial->addParameter( mEyeDomeLightingEnabledParameter );
120 mMaterial->addParameter( mEyeDomeLightingStrengthParameter );
121 mMaterial->addParameter( mEyeDomeLightingDistanceParameter );
123 mAmbientOcclusionEnabledParameter =
new Qt3DRender::QParameter( QStringLiteral(
"ssaoEnabled" ), QVariant::fromValue( 0 ) );
124 mMaterial->addParameter( mAmbientOcclusionEnabledParameter );
126 mLightPosition =
new Qt3DRender::QParameter( QStringLiteral(
"lightPosition" ), QVariant::fromValue( QVector3D() ) );
127 mLightDirection =
new Qt3DRender::QParameter( QStringLiteral(
"lightDirection" ), QVariant::fromValue( QVector3D() ) );
128 mMaterial->addParameter( mLightPosition );
129 mMaterial->addParameter( mLightDirection );
131 const QString vertexShaderPath = QStringLiteral(
"qrc:/shaders/postprocess.vert" );
132 const QString fragmentShaderPath = QStringLiteral(
"qrc:/shaders/postprocess.frag" );
134 mShader->setVertexShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( vertexShaderPath ) ) );
135 mShader->setFragmentShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( fragmentShaderPath ) ) );