mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 00:59:56 +02:00
work in progress
This commit is contained in:
parent
0fcfacdd72
commit
6c63dc0444
3 changed files with 28 additions and 10 deletions
|
@ -245,6 +245,12 @@ gpu::FramebufferPointer _copyFBO;
|
|||
void DeferredLightingEffect::render(RenderArgs* args) {
|
||||
gpu::Batch batch;
|
||||
|
||||
// Allocate the parameters buffer used by all the deferred shaders
|
||||
if (!_parametersBuffer._buffer) {
|
||||
Parameters parameters[2];
|
||||
_parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(2 * sizeof(Parameters), (const gpu::Byte*) ¶meters));
|
||||
}
|
||||
|
||||
// Framebuffer copy operations cannot function as multipass stereo operations.
|
||||
batch.enableStereo(false);
|
||||
|
||||
|
@ -270,6 +276,8 @@ void DeferredLightingEffect::render(RenderArgs* args) {
|
|||
|
||||
batch.setResourceTexture(3, framebufferCache->getPrimaryDepthTexture());
|
||||
|
||||
|
||||
|
||||
float sMin = args->_viewport.x / (float)framebufferSize.width();
|
||||
float sWidth = args->_viewport.z / (float)framebufferSize.width();
|
||||
float tMin = args->_viewport.y / (float)framebufferSize.height();
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
void setGlobalAtmosphere(const model::AtmospherePointer& atmosphere) { _atmosphere = atmosphere; }
|
||||
|
||||
void setGlobalSkybox(const model::SkyboxPointer& skybox);
|
||||
|
||||
|
||||
private:
|
||||
DeferredLightingEffect() {}
|
||||
virtual ~DeferredLightingEffect() { }
|
||||
|
@ -169,6 +169,24 @@ private:
|
|||
int _ambientLightMode = 0;
|
||||
model::AtmospherePointer _atmosphere;
|
||||
model::SkyboxPointer _skybox;
|
||||
|
||||
// Class describing the uniform buffer with all the parameters common to the deferred shaders
|
||||
class Parameters {
|
||||
public:
|
||||
|
||||
float nearVal{ 1.0f };
|
||||
float depthScale{ 1.0f };
|
||||
glm::vec2 spare0; // 2 spare scalars here
|
||||
glm::vec2 depthTexCoordOffset{ 0.0f };
|
||||
glm::vec2 depthTexCoordScale{ 1.0f };
|
||||
|
||||
Parameters() {}
|
||||
};
|
||||
typedef gpu::BufferView UniformBufferView;
|
||||
UniformBufferView _parametersBuffer;
|
||||
|
||||
const UniformBufferView& getParametersBuffer() const { return _parametersBuffer; }
|
||||
|
||||
};
|
||||
|
||||
class SimpleProgramKey {
|
||||
|
|
|
@ -21,12 +21,9 @@
|
|||
// Everything about light
|
||||
<@include model/Light.slh@>
|
||||
|
||||
<@include gpu/Transform.slh@>
|
||||
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
// The view Matrix
|
||||
//uniform mat4 invViewMat;
|
||||
uniform mat4 invViewMat;
|
||||
|
||||
in vec4 _texCoord0;
|
||||
out vec4 _fragColor;
|
||||
|
@ -42,10 +39,6 @@ void main(void) {
|
|||
discard;
|
||||
}
|
||||
|
||||
// Need the camera inv view mat
|
||||
TransformCamera cam = getTransformCamera();
|
||||
mat4 invViewMat = cam._viewInverse;
|
||||
|
||||
// Need the light now
|
||||
Light light = getLight();
|
||||
|
||||
|
@ -96,6 +89,5 @@ void main(void) {
|
|||
}
|
||||
|
||||
|
||||
_fragColor = vec4(frag.position.xyz, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue