simplerr / UtopianEngine

A game engine in early development
MIT License
52 stars 5 forks source link

Unify shared uniforms #94

Closed simplerr closed 4 years ago

simplerr commented 4 years ago

For example the water shader and the deferred shader shares the shadow calculation uniforms. The water and the terrain shader shares the tessallation uniforms etc.

Implement a common place where

    // Note: Todo: Temporary
    // Note: Duplicate from DeferredJob.cpp
    for (uint32_t i = 0; i < SHADOW_MAP_CASCADE_COUNT; i++)
    {
        mCascadeBlock.data.cascadeSplits[i] = jobInput.sceneInfo.cascades[i].splitDepth;
        mCascadeBlock.data.cascadeViewProjMat[i] = jobInput.sceneInfo.cascades[i].viewProjMatrix;
    }

    // Note: This should probably be moved. We need the fragment position in view space
    // when comparing it's Z value to find out which shadow map cascade it should sample from.
    mCascadeBlock.data.cameraViewMat = jobInput.sceneInfo.viewMatrix;
    mCascadeBlock.data.shadowSampleSize = jobInput.renderingSettings.shadowSampleSize;
    mCascadeBlock.data.shadowsEnabled = jobInput.renderingSettings.shadowsEnabled;
    mCascadeBlock.UpdateMemory();

Can be called so the Jobs only need to do the binding themself.

simplerr commented 4 years ago

Made shared uniforms for camera data used in all shaders. The duplicate of shadow calculation uniforms and tessallation uniforms will be leaved as is for now.