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 ) {
65 mFarPlaneParameter->setValue( farPlane );
67 mNearPlaneParameter =
new Qt3DRender::QParameter( QStringLiteral(
"nearPlane" ), mMainCamera->nearPlane() );
68 mMaterial->addParameter( mNearPlaneParameter );
69 connect( mMainCamera, &Qt3DRender::QCamera::nearPlaneChanged, mNearPlaneParameter, [&](
float nearPlane ) {
70 mNearPlaneParameter->setValue( nearPlane );
73 mLightFarPlaneParameter =
new Qt3DRender::QParameter( QStringLiteral(
"lightFarPlane" ), mLightCamera->farPlane() );
74 mMaterial->addParameter( mLightFarPlaneParameter );
75 connect( mLightCamera, &Qt3DRender::QCamera::farPlaneChanged, mLightFarPlaneParameter, [&](
float farPlane ) {
76 mLightFarPlaneParameter->setValue( farPlane );
78 mLightNearPlaneParameter =
new Qt3DRender::QParameter( QStringLiteral(
"lightNearPlane" ), mLightCamera->nearPlane() );
79 mMaterial->addParameter( mLightNearPlaneParameter );
80 connect( mLightCamera, &Qt3DRender::QCamera::nearPlaneChanged, mLightNearPlaneParameter, [&](
float nearPlane ) {
81 mLightNearPlaneParameter->setValue( nearPlane );
84 mMainCameraInvViewMatrixParameter =
new Qt3DRender::QParameter( QStringLiteral(
"invertedCameraView" ), mMainCamera->viewMatrix().inverted() );
85 mMaterial->addParameter( mMainCameraInvViewMatrixParameter );
86 mMainCameraInvProjMatrixParameter =
new Qt3DRender::QParameter( QStringLiteral(
"invertedCameraProj" ), mMainCamera->projectionMatrix().inverted() );
87 mMaterial->addParameter( mMainCameraInvProjMatrixParameter );
88 connect( mMainCamera, &Qt3DRender::QCamera::projectionMatrixChanged, mMainCameraInvProjMatrixParameter, [&](
const QMatrix4x4 &projectionMatrix ) {
89 mMainCameraInvProjMatrixParameter->setValue( projectionMatrix.inverted() );
91 connect( mMainCamera, &Qt3DRender::QCamera::viewMatrixChanged, mMainCameraInvViewMatrixParameter, [&]() {
92 mMainCameraInvViewMatrixParameter->setValue( mMainCamera->viewMatrix().inverted() );
95 mShadowMinX =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMinX" ), QVariant::fromValue( 0.0f ) );
96 mShadowMaxX =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMaxX" ), QVariant::fromValue( 0.0f ) );
97 mShadowMinY =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMinY" ), QVariant::fromValue( 0.0f ) );
98 mShadowMaxY =
new Qt3DRender::QParameter( QStringLiteral(
"shadowMaxY" ), QVariant::fromValue( 0.0f ) );
104 mRenderShadowsParameter =
new Qt3DRender::QParameter( QStringLiteral(
"renderShadows" ), QVariant::fromValue( 0 ) );
105 mMaterial->addParameter( mRenderShadowsParameter );
107 mShadowBiasParameter =
new Qt3DRender::QParameter( QStringLiteral(
"shadowBias" ), QVariant::fromValue( 0.00001f ) );
108 mMaterial->addParameter( mShadowBiasParameter );
110 mEyeDomeLightingEnabledParameter =
new Qt3DRender::QParameter( QStringLiteral(
"edlEnabled" ), QVariant::fromValue( 0 ) );
111 mEyeDomeLightingStrengthParameter =
new Qt3DRender::QParameter( QStringLiteral(
"edlStrength" ), QVariant::fromValue( 1000.0f ) );
112 mEyeDomeLightingDistanceParameter =
new Qt3DRender::QParameter( QStringLiteral(
"edlDistance" ), QVariant::fromValue( 2.0f ) );
113 mMaterial->addParameter( mEyeDomeLightingEnabledParameter );
114 mMaterial->addParameter( mEyeDomeLightingStrengthParameter );
115 mMaterial->addParameter( mEyeDomeLightingDistanceParameter );
117 mAmbientOcclusionEnabledParameter =
new Qt3DRender::QParameter( QStringLiteral(
"ssaoEnabled" ), QVariant::fromValue( 0 ) );
118 mMaterial->addParameter( mAmbientOcclusionEnabledParameter );
120 mLightPosition =
new Qt3DRender::QParameter( QStringLiteral(
"lightPosition" ), QVariant::fromValue( QVector3D() ) );
121 mLightDirection =
new Qt3DRender::QParameter( QStringLiteral(
"lightDirection" ), QVariant::fromValue( QVector3D() ) );
122 mMaterial->addParameter( mLightPosition );
123 mMaterial->addParameter( mLightDirection );
125 const QString vertexShaderPath = QStringLiteral(
"qrc:/shaders/postprocess.vert" );
126 const QString fragmentShaderPath = QStringLiteral(
"qrc:/shaders/postprocess.frag" );
128 mShader->setVertexShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( vertexShaderPath ) ) );
129 mShader->setFragmentShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl( fragmentShaderPath ) ) );