[508] | 1 | // Copyright (C) 2016-2016 ChaosForge Ltd
|
---|
| 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
| 4 | // This file is part of Nova libraries.
|
---|
| 5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
| 6 |
|
---|
| 7 | #include "nv/engine/shadow.hh"
|
---|
| 8 |
|
---|
| 9 | using namespace nv;
|
---|
| 10 |
|
---|
| 11 | void shadow_data::initialize( context* context, uint32 count, uint32 map_size, const render_pass& pass_base )
|
---|
| 12 | {
|
---|
| 13 | m_map_size = map_size;
|
---|
| 14 | m_maps = context->create_texture( TEXTURE_2D_ARRAY, ivec3( map_size, map_size, count ), image_format( DEPTH24, UINT ), sampler( sampler::LINEAR, sampler::CLAMP_TO_EDGE ), nullptr );
|
---|
| 15 | m_passes.resize( count );
|
---|
| 16 | for ( uint32 i = 0; i < count; ++i )
|
---|
| 17 | {
|
---|
| 18 | framebuffer shadow_fbuffer = context->create_framebuffer();
|
---|
| 19 | if ( m_color_maps )
|
---|
| 20 | context->attach( shadow_fbuffer, OUTPUT_0, m_color_maps, i );
|
---|
| 21 | context->attach( shadow_fbuffer, m_maps, i );
|
---|
| 22 | context->check( FRAMEBUFFER );
|
---|
| 23 | context->bind( framebuffer() );
|
---|
| 24 |
|
---|
| 25 | m_passes[i] = pass_base;
|
---|
| 26 | m_passes[i].output[0] = OUTPUT_NONE;
|
---|
| 27 | m_passes[i].output_count = 1;
|
---|
| 28 | m_passes[i].fbuffer = shadow_fbuffer;
|
---|
| 29 | }
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | void nv::shadow_data::initialize( context* context, uint32 count, uint32 map_size, const render_pass& pass_base, const render_pass& color_base )
|
---|
| 33 | {
|
---|
| 34 | m_color_maps = context->create_texture( TEXTURE_2D_ARRAY, ivec3( map_size, map_size, count ), image_format( RGBA16F, FLOAT ), sampler( sampler::LINEAR, sampler::CLAMP_TO_EDGE ), nullptr );
|
---|
| 35 |
|
---|
| 36 | initialize( context, count, map_size, pass_base );
|
---|
| 37 |
|
---|
| 38 | m_color_passes.resize( count );
|
---|
| 39 | for ( uint32 i = 0; i < count; ++i )
|
---|
| 40 | {
|
---|
| 41 | m_color_passes[i] = color_base;
|
---|
| 42 | m_color_passes[i].output[0] = OUTPUT_0;
|
---|
| 43 | m_color_passes[i].output_count = 1;
|
---|
| 44 | m_color_passes[i].fbuffer = m_passes[i].fbuffer;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | }
|
---|