Eevee: Initial commit
Basic support for lamps. Only diffuse.
This commit is contained in:
@@ -26,7 +26,7 @@ class LAMP_MT_sunsky_presets(Menu):
|
||||
bl_label = "Sun & Sky Presets"
|
||||
preset_subdir = "sunsky"
|
||||
preset_operator = "script.execute_preset"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
draw = Menu.draw_preset
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class DataButtonsPanel:
|
||||
class DATA_PT_context_lamp(DataButtonsPanel, Panel):
|
||||
bl_label = ""
|
||||
bl_options = {'HIDE_HEADER'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -68,7 +68,7 @@ class DATA_PT_context_lamp(DataButtonsPanel, Panel):
|
||||
|
||||
class DATA_PT_preview(DataButtonsPanel, Panel):
|
||||
bl_label = "Preview"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
|
||||
def draw(self, context):
|
||||
self.layout.template_preview(context.lamp)
|
||||
@@ -76,7 +76,7 @@ class DATA_PT_preview(DataButtonsPanel, Panel):
|
||||
|
||||
class DATA_PT_lamp(DataButtonsPanel, Panel):
|
||||
bl_label = "Lamp"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -312,7 +312,7 @@ class DATA_PT_shadow(DataButtonsPanel, Panel):
|
||||
|
||||
class DATA_PT_area(DataButtonsPanel, Panel):
|
||||
bl_label = "Area Shape"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
@@ -338,7 +338,7 @@ class DATA_PT_area(DataButtonsPanel, Panel):
|
||||
|
||||
class DATA_PT_spot(DataButtonsPanel, Panel):
|
||||
bl_label = "Spot Shape"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
@@ -374,7 +374,7 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
|
||||
class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
|
||||
bl_label = "Falloff Curve"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
@@ -390,7 +390,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
|
||||
|
||||
|
||||
class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel):
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
||||
_context_path = "object.data"
|
||||
_property_type = bpy.types.Lamp
|
||||
|
||||
|
@@ -27,6 +27,7 @@ set(INC
|
||||
.
|
||||
intern
|
||||
engines/clay
|
||||
engines/eevee
|
||||
modes
|
||||
|
||||
../blenkernel
|
||||
@@ -56,7 +57,15 @@ set(SRC
|
||||
intern/draw_cache.c
|
||||
intern/draw_view.c
|
||||
intern/draw_armature.c
|
||||
|
||||
engines/clay/clay.c
|
||||
engines/clay/clay.h
|
||||
|
||||
engines/eevee/eevee.c
|
||||
engines/eevee/eevee_lights.c
|
||||
engines/eevee/eevee.h
|
||||
engines/eevee/eevee_private.h
|
||||
|
||||
modes/object_mode.c
|
||||
modes/edit_armature_mode.c
|
||||
modes/edit_curve_mode.c
|
||||
@@ -76,7 +85,6 @@ set(SRC
|
||||
intern/draw_common.h
|
||||
intern/draw_cache.h
|
||||
intern/draw_view.h
|
||||
engines/clay/clay.h
|
||||
modes/draw_mode_engines.h
|
||||
|
||||
./DRW_engine.h
|
||||
@@ -91,6 +99,10 @@ data_to_c_simple(engines/clay/shaders/clay_vert.glsl SRC)
|
||||
data_to_c_simple(engines/clay/shaders/ssao_alchemy.glsl SRC)
|
||||
data_to_c_simple(engines/clay/shaders/ssao_groundtruth.glsl SRC)
|
||||
|
||||
data_to_c_simple(engines/eevee/shaders/lit_surface_frag.glsl SRC)
|
||||
data_to_c_simple(engines/eevee/shaders/lit_surface_vert.glsl SRC)
|
||||
data_to_c_simple(engines/eevee/shaders/tonemap_frag.glsl SRC)
|
||||
|
||||
data_to_c_simple(modes/shaders/edit_overlay_frag.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/edit_overlay_vert.glsl SRC)
|
||||
data_to_c_simple(modes/shaders/edit_overlay_geom_tri.glsl SRC)
|
||||
|
196
source/blender/draw/engines/eevee/eevee.c
Normal file
196
source/blender/draw/engines/eevee/eevee.c
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright 2016, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributor(s): Blender Institute
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file eevee.c
|
||||
* \ingroup DNA
|
||||
*/
|
||||
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "eevee.h"
|
||||
#include "eevee_private.h"
|
||||
|
||||
#define EEVEE_ENGINE "BLENDER_EEVEE"
|
||||
|
||||
/* *********** STATIC *********** */
|
||||
static struct {
|
||||
struct GPUShader *default_lit;
|
||||
struct GPUShader *tonemap;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
static struct {
|
||||
DRWShadingGroup *default_lit_grp;
|
||||
EEVEE_Data *vedata;
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
extern char datatoc_lit_surface_frag_glsl[];
|
||||
extern char datatoc_lit_surface_vert_glsl[];
|
||||
extern char datatoc_tonemap_frag_glsl[];
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
static void EEVEE_engine_init(void)
|
||||
{
|
||||
g_data.vedata = DRW_viewport_engine_data_get(EEVEE_ENGINE);
|
||||
EEVEE_TextureList *txl = g_data.vedata->txl;
|
||||
EEVEE_FramebufferList *fbl = g_data.vedata->fbl;
|
||||
EEVEE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
DRWFboTexture tex = {&txl->color, DRW_BUF_RGBA_32};
|
||||
|
||||
float *viewport_size = DRW_viewport_size_get();
|
||||
DRW_framebuffer_init(&fbl->main,
|
||||
(int)viewport_size[0], (int)viewport_size[1],
|
||||
&tex, 1);
|
||||
|
||||
if (!e_data.default_lit) {
|
||||
e_data.default_lit = DRW_shader_create(datatoc_lit_surface_vert_glsl, NULL, datatoc_lit_surface_frag_glsl, "#define MAX_LIGHT 128\n");
|
||||
}
|
||||
|
||||
if (!e_data.tonemap) {
|
||||
e_data.tonemap = DRW_shader_create_fullscreen(datatoc_tonemap_frag_glsl, NULL);
|
||||
}
|
||||
UNUSED_VARS(stl);
|
||||
|
||||
if (stl->lights_info == NULL)
|
||||
EEVEE_lights_init(stl);
|
||||
|
||||
// EEVEE_lights_update(stl);
|
||||
}
|
||||
|
||||
static void EEVEE_cache_init(void)
|
||||
{
|
||||
g_data.vedata = DRW_viewport_engine_data_get(EEVEE_ENGINE);
|
||||
EEVEE_PassList *psl = g_data.vedata->psl;
|
||||
EEVEE_TextureList *txl = g_data.vedata->txl;
|
||||
EEVEE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
{
|
||||
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
|
||||
psl->pass = DRW_pass_create("Default Light Pass", state);
|
||||
|
||||
g_data.default_lit_grp = DRW_shgroup_create(e_data.default_lit, psl->pass);
|
||||
DRW_shgroup_uniform_block(g_data.default_lit_grp, "light_block", stl->lights_ubo, 0);
|
||||
DRW_shgroup_uniform_int(g_data.default_lit_grp, "light_count", &stl->lights_info->light_count, 1);
|
||||
}
|
||||
|
||||
{
|
||||
/* Final pass : Map HDR color to LDR color.
|
||||
* Write result to the default color buffer */
|
||||
psl->tonemap = DRW_pass_create("Tone Mapping", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND);
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(e_data.tonemap, psl->tonemap);
|
||||
DRW_shgroup_uniform_buffer(grp, "hdrColorBuf", &txl->color, 0);
|
||||
|
||||
struct Batch *geom = DRW_cache_fullscreen_quad_get();
|
||||
DRW_shgroup_call_add(grp, geom, NULL);
|
||||
}
|
||||
|
||||
EEVEE_lights_cache_init(stl);
|
||||
}
|
||||
|
||||
static void EEVEE_cache_populate(Object *ob)
|
||||
{
|
||||
EEVEE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
struct Batch *geom = DRW_cache_surface_get(ob);
|
||||
|
||||
DRW_shgroup_call_add(g_data.default_lit_grp, geom, ob->obmat);
|
||||
}
|
||||
else if (ob->type == OB_LAMP) {
|
||||
EEVEE_lights_cache_add(stl, ob);
|
||||
}
|
||||
}
|
||||
|
||||
static void EEVEE_cache_finish(void)
|
||||
{
|
||||
EEVEE_StorageList *stl = g_data.vedata->stl;
|
||||
|
||||
EEVEE_lights_cache_finish(stl);
|
||||
}
|
||||
|
||||
static void EEVEE_draw_scene(void)
|
||||
{
|
||||
EEVEE_Data *ved = DRW_viewport_engine_data_get(EEVEE_ENGINE);
|
||||
EEVEE_PassList *psl = ved->psl;
|
||||
EEVEE_FramebufferList *fbl = ved->fbl;
|
||||
|
||||
/* Default framebuffer and texture */
|
||||
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
||||
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
|
||||
|
||||
/* Attach depth to the hdr buffer and bind it */
|
||||
DRW_framebuffer_texture_detach(dtxl->depth);
|
||||
DRW_framebuffer_texture_attach(fbl->main, dtxl->depth, 0);
|
||||
DRW_framebuffer_bind(fbl->main);
|
||||
|
||||
/* Clear Depth */
|
||||
/* TODO do background */
|
||||
float clearcol[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
DRW_framebuffer_clear(true, true, clearcol, 1.0f);
|
||||
|
||||
DRW_draw_pass(psl->pass);
|
||||
|
||||
/* Restore default framebuffer */
|
||||
DRW_framebuffer_texture_detach(dtxl->depth);
|
||||
DRW_framebuffer_texture_attach(dfbl->default_fb, dtxl->depth, 0);
|
||||
DRW_framebuffer_bind(dfbl->default_fb);
|
||||
|
||||
DRW_draw_pass(psl->tonemap);
|
||||
}
|
||||
|
||||
static void EEVEE_engine_free(void)
|
||||
{
|
||||
if (e_data.default_lit)
|
||||
DRW_shader_free(e_data.default_lit);
|
||||
if (e_data.tonemap)
|
||||
DRW_shader_free(e_data.tonemap);
|
||||
}
|
||||
|
||||
static void EEVEE_collection_settings_create(RenderEngine *UNUSED(engine), CollectionEngineSettings *ces)
|
||||
{
|
||||
BLI_assert(ces);
|
||||
// BKE_collection_engine_property_add_int(ces, "high_quality_sphere_lamps", false);
|
||||
}
|
||||
|
||||
DrawEngineType draw_engine_eevee_type = {
|
||||
NULL, NULL,
|
||||
N_("Clay"),
|
||||
&EEVEE_engine_init,
|
||||
&EEVEE_engine_free,
|
||||
&EEVEE_cache_init,
|
||||
&EEVEE_cache_populate,
|
||||
&EEVEE_cache_finish,
|
||||
&EEVEE_draw_scene,
|
||||
NULL//&EEVEE_draw_scene
|
||||
};
|
||||
|
||||
RenderEngineType viewport_eevee_type = {
|
||||
NULL, NULL,
|
||||
EEVEE_ENGINE, N_("Eevee"), RE_INTERNAL | RE_USE_OGL_PIPELINE,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, &EEVEE_collection_settings_create,
|
||||
&draw_engine_eevee_type,
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
#undef EEVEE_ENGINE
|
31
source/blender/draw/engines/eevee/eevee.h
Normal file
31
source/blender/draw/engines/eevee/eevee.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2016, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributor(s): Blender Institute
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file eevee.h
|
||||
* \ingroup DNA
|
||||
*/
|
||||
|
||||
#ifndef __EEVEE_H__
|
||||
#define __EEVEE_H__
|
||||
|
||||
extern RenderEngineType viewport_eevee_type;
|
||||
|
||||
#endif /* __EEVEE_H__ */
|
103
source/blender/draw/engines/eevee/eevee_lights.c
Normal file
103
source/blender/draw/engines/eevee/eevee_lights.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2016, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributor(s): Blender Institute
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file eevee_lights.c
|
||||
* \ingroup DNA
|
||||
*/
|
||||
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "eevee_private.h"
|
||||
|
||||
#define MAX_LIGHT 210 /* TODO : find size by dividing UBO max size by light data size */
|
||||
|
||||
typedef struct EEVEE_Light {
|
||||
float position[3], pad;
|
||||
float color[3], spec;
|
||||
float spot_size, spot_blend, area_x, area_y;
|
||||
} EEVEE_Light;
|
||||
|
||||
static struct {
|
||||
ListBase lamps; /* Lamps gathered during cache iteration */
|
||||
} g_data = {NULL}; /* Transient data */
|
||||
|
||||
void EEVEE_lights_init(EEVEE_StorageList *stl)
|
||||
{
|
||||
stl->lights_info = MEM_callocN(sizeof(EEVEE_LightsInfo), "EEVEE_LightsInfo");
|
||||
stl->lights_data = MEM_mallocN(sizeof(EEVEE_Light) * MAX_LIGHT, "EEVEE_LightsUboStorage");
|
||||
stl->lights_ref = MEM_mallocN(sizeof(Object *) * MAX_LIGHT, "EEVEE lights_ref");
|
||||
stl->lights_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_Light) * MAX_LIGHT, NULL);
|
||||
}
|
||||
|
||||
void EEVEE_lights_cache_init(EEVEE_StorageList *stl)
|
||||
{
|
||||
BLI_listbase_clear(&g_data.lamps);
|
||||
stl->lights_info->light_count = 0;
|
||||
}
|
||||
|
||||
void EEVEE_lights_cache_add(EEVEE_StorageList *stl, Object *ob)
|
||||
{
|
||||
BLI_addtail(&g_data.lamps, BLI_genericNodeN(ob));
|
||||
stl->lights_info->light_count += 1;
|
||||
}
|
||||
|
||||
void EEVEE_lights_cache_finish(EEVEE_StorageList *stl)
|
||||
{
|
||||
int light_ct = stl->lights_info->light_count;
|
||||
|
||||
if (light_ct > MAX_LIGHT) {
|
||||
printf("Too much lamps in the scene !!!\n");
|
||||
stl->lights_info->light_count = MAX_LIGHT;
|
||||
}
|
||||
|
||||
if (light_ct > 0) {
|
||||
int i = 0;
|
||||
for (LinkData *link = g_data.lamps.first; link && i < MAX_LIGHT; link = link->next, i++) {
|
||||
Object *ob = (Object *)link->data;
|
||||
stl->lights_ref[i] = ob;
|
||||
}
|
||||
}
|
||||
BLI_freelistN(&g_data.lamps);
|
||||
|
||||
/* We changed light data so we need to upload it */
|
||||
EEVEE_lights_update(stl);
|
||||
}
|
||||
|
||||
void EEVEE_lights_update(EEVEE_StorageList *stl)
|
||||
{
|
||||
int light_ct = stl->lights_info->light_count;
|
||||
|
||||
/* TODO only update if data changes */
|
||||
/* Update buffer with lamp data */
|
||||
for (int i = 0; i < light_ct; ++i) {
|
||||
EEVEE_Light *evli = stl->lights_data + i;
|
||||
Object *ob = stl->lights_ref[i];
|
||||
Lamp *la = (Lamp *)ob->data;
|
||||
|
||||
copy_v3_v3(evli->position, ob->obmat[3]);
|
||||
evli->color[0] = la->r * la->energy;
|
||||
evli->color[1] = la->g * la->energy;
|
||||
evli->color[2] = la->b * la->energy;
|
||||
}
|
||||
|
||||
/* Upload buffer to GPU */
|
||||
DRW_uniformbuffer_update(stl->lights_ubo, stl->lights_data);
|
||||
}
|
70
source/blender/draw/engines/eevee/eevee_private.h
Normal file
70
source/blender/draw/engines/eevee/eevee_private.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2016, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributor(s): Blender Institute
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file eevee_private.h
|
||||
* \ingroup DNA
|
||||
*/
|
||||
|
||||
struct Object;
|
||||
|
||||
/* keep it under MAX_PASSES */
|
||||
typedef struct EEVEE_PassList {
|
||||
struct DRWPass *pass;
|
||||
struct DRWPass *tonemap;
|
||||
} EEVEE_PassList;
|
||||
|
||||
/* keep it under MAX_BUFFERS */
|
||||
typedef struct EEVEE_FramebufferList {
|
||||
struct GPUFrameBuffer *main; /* HDR */
|
||||
} EEVEE_FramebufferList;
|
||||
|
||||
/* keep it under MAX_TEXTURES */
|
||||
typedef struct EEVEE_TextureList {
|
||||
struct GPUTexture *color; /* R11_G11_B10 */
|
||||
} EEVEE_TextureList;
|
||||
|
||||
/* keep it under MAX_STORAGE */
|
||||
typedef struct EEVEE_StorageList {
|
||||
/* Lights */
|
||||
struct EEVEE_LightsInfo *lights_info; /* Number of lights, ... */
|
||||
struct EEVEE_Light *lights_data; /* Array, Packed lights data info, duplication of what is in the Uniform Buffer in Vram */
|
||||
struct Object **lights_ref; /* List of all lights in the buffer. */
|
||||
struct GPUUniformBuffer *lights_ubo;
|
||||
} EEVEE_StorageList;
|
||||
|
||||
typedef struct EEVEE_LightsInfo {
|
||||
int light_count;
|
||||
} EEVEE_LightsInfo;
|
||||
|
||||
typedef struct EEVEE_Data {
|
||||
char engine_name[32];
|
||||
EEVEE_FramebufferList *fbl;
|
||||
EEVEE_TextureList *txl;
|
||||
EEVEE_PassList *psl;
|
||||
EEVEE_StorageList *stl;
|
||||
} EEVEE_Data;
|
||||
|
||||
/* eevee_lights.c */
|
||||
void EEVEE_lights_init(EEVEE_StorageList *stl);
|
||||
void EEVEE_lights_cache_init(EEVEE_StorageList *stl);
|
||||
void EEVEE_lights_cache_add(EEVEE_StorageList *stl, struct Object *ob);
|
||||
void EEVEE_lights_cache_finish(EEVEE_StorageList *stl);
|
||||
void EEVEE_lights_update(EEVEE_StorageList *stl);
|
@@ -0,0 +1,30 @@
|
||||
|
||||
uniform int light_count;
|
||||
|
||||
struct LightData {
|
||||
vec4 position;
|
||||
vec4 colorAndSpec; /* w : Spec Intensity */
|
||||
vec4 spotAndAreaData;
|
||||
};
|
||||
|
||||
layout(std140) uniform light_block {
|
||||
LightData lights_data[MAX_LIGHT];
|
||||
};
|
||||
|
||||
in vec3 worldPosition;
|
||||
in vec3 worldNormal;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec3 n = normalize(worldNormal);
|
||||
vec3 diffuse = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < MAX_LIGHT && i < light_count; ++i) {
|
||||
LightData ld = lights_data[i];
|
||||
vec3 l = normalize(ld.position.xyz - worldPosition);
|
||||
diffuse += max(0.0, dot(l, n)) * ld.colorAndSpec.rgb / 3.14159;
|
||||
}
|
||||
|
||||
fragColor = vec4(diffuse,1.0);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat3 WorldNormalMatrix;
|
||||
|
||||
in vec3 pos;
|
||||
in vec3 nor;
|
||||
|
||||
out vec3 worldPosition;
|
||||
out vec3 worldNormal;
|
||||
|
||||
void main() {
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
|
||||
worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
|
||||
worldNormal = WorldNormalMatrix * nor;
|
||||
}
|
10
source/blender/draw/engines/eevee/shaders/tonemap_frag.glsl
Normal file
10
source/blender/draw/engines/eevee/shaders/tonemap_frag.glsl
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
uniform sampler2D hdrColorBuf;
|
||||
|
||||
in vec4 uvcoordsvar;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(hdrColorBuf, uvcoordsvar.st);
|
||||
}
|
@@ -58,6 +58,7 @@
|
||||
|
||||
#include "draw_mode_engines.h"
|
||||
#include "clay.h"
|
||||
#include "eevee.h"
|
||||
|
||||
#define MAX_ATTRIB_NAME 32
|
||||
|
||||
@@ -109,12 +110,14 @@ struct DRWInterface {
|
||||
int attribs_size[16];
|
||||
int attribs_loc[16];
|
||||
/* matrices locations */
|
||||
int model;
|
||||
int modelview;
|
||||
int projection;
|
||||
int view;
|
||||
int modelviewprojection;
|
||||
int viewprojection;
|
||||
int normal;
|
||||
int worldnormal;
|
||||
int eye;
|
||||
/* Dynamic batch */
|
||||
GLuint instance_vbo;
|
||||
@@ -337,12 +340,14 @@ static DRWInterface *DRW_interface_create(GPUShader *shader)
|
||||
{
|
||||
DRWInterface *interface = MEM_mallocN(sizeof(DRWInterface), "DRWInterface");
|
||||
|
||||
interface->model = GPU_shader_get_uniform(shader, "ModelMatrix");
|
||||
interface->modelview = GPU_shader_get_uniform(shader, "ModelViewMatrix");
|
||||
interface->projection = GPU_shader_get_uniform(shader, "ProjectionMatrix");
|
||||
interface->view = GPU_shader_get_uniform(shader, "ViewMatrix");
|
||||
interface->viewprojection = GPU_shader_get_uniform(shader, "ViewProjectionMatrix");
|
||||
interface->modelviewprojection = GPU_shader_get_uniform(shader, "ModelViewProjectionMatrix");
|
||||
interface->normal = GPU_shader_get_uniform(shader, "NormalMatrix");
|
||||
interface->worldnormal = GPU_shader_get_uniform(shader, "WorldNormalMatrix");
|
||||
interface->eye = GPU_shader_get_uniform(shader, "eye");
|
||||
interface->instance_count = 0;
|
||||
interface->attribs_count = 0;
|
||||
@@ -770,12 +775,13 @@ static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*o
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(DST.context);
|
||||
DRWInterface *interface = shgroup->interface;
|
||||
|
||||
float mvp[4][4], mv[4][4], n[3][3];
|
||||
float mvp[4][4], mv[4][4], n[3][3], wn[3][3];
|
||||
float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */
|
||||
|
||||
bool do_mvp = (interface->modelviewprojection != -1);
|
||||
bool do_mv = (interface->modelview != -1);
|
||||
bool do_n = (interface->normal != -1);
|
||||
bool do_wn = (interface->worldnormal != -1);
|
||||
bool do_eye = (interface->eye != -1);
|
||||
|
||||
if (do_mvp) {
|
||||
@@ -789,6 +795,11 @@ static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*o
|
||||
invert_m3(n);
|
||||
transpose_m3(n);
|
||||
}
|
||||
if (do_wn) {
|
||||
copy_m3_m4(wn, obmat);
|
||||
invert_m3(wn);
|
||||
transpose_m3(wn);
|
||||
}
|
||||
if (do_eye) {
|
||||
/* Used by orthographic wires */
|
||||
float tmp[3][3];
|
||||
@@ -799,6 +810,9 @@ static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*o
|
||||
|
||||
/* Should be really simple */
|
||||
/* step 1 : bind object dependent matrices */
|
||||
if (interface->model != -1) {
|
||||
GPU_shader_uniform_vector(shgroup->shader, interface->model, 16, 1, (float *)obmat);
|
||||
}
|
||||
if (interface->modelviewprojection != -1) {
|
||||
GPU_shader_uniform_vector(shgroup->shader, interface->modelviewprojection, 16, 1, (float *)mvp);
|
||||
}
|
||||
@@ -817,6 +831,9 @@ static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*o
|
||||
if (interface->normal != -1) {
|
||||
GPU_shader_uniform_vector(shgroup->shader, interface->normal, 9, 1, (float *)n);
|
||||
}
|
||||
if (interface->worldnormal != -1) {
|
||||
GPU_shader_uniform_vector(shgroup->shader, interface->worldnormal, 9, 1, (float *)wn);
|
||||
}
|
||||
if (interface->eye != -1) {
|
||||
GPU_shader_uniform_vector(shgroup->shader, interface->eye, 3, 1, (float *)eye);
|
||||
}
|
||||
@@ -1548,6 +1565,7 @@ void DRW_engines_register(void)
|
||||
{
|
||||
#ifdef WITH_CLAY_ENGINE
|
||||
RE_engines_register(NULL, &viewport_clay_type);
|
||||
RE_engines_register(NULL, &viewport_eevee_type);
|
||||
|
||||
DRW_engine_register(&draw_engine_object_type);
|
||||
DRW_engine_register(&draw_engine_edit_armature_type);
|
||||
|
@@ -44,7 +44,7 @@ typedef struct GPUViewport GPUViewport;
|
||||
#define MAX_BUFFERS 8
|
||||
#define MAX_TEXTURES 16
|
||||
#define MAX_PASSES 16
|
||||
#define MAX_STORAGE 2 /* extend if needed */
|
||||
#define MAX_STORAGE 4 /* extend if needed */
|
||||
|
||||
/* All FramebufferLists are just the same pointers with different names */
|
||||
typedef struct FramebufferList {
|
||||
|
Reference in New Issue
Block a user