source: trunk/src/engine/shadow.cc @ 539

Last change on this file since 539 was 535, checked in by epyon, 8 years ago
  • unified pixel_format instead of image_format
File size: 1.6 KB
Line 
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
9using namespace nv;
10
11void 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 ), DEPTH24, 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
32void 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 ), RGBA16F, 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}
Note: See TracBrowser for help on using the repository browser.