Eevee: World nodetree gpumaterial compatibility.
- Unify GPUMaterial creation (world/mesh). - Support for multiple shader variations (not used for now). - Convert GPUInputs to DRWUniforms to be used with the draw manager. - Nodetree Update is not supported. The only way to refresh the shaders is to change render engine. - Cleanup in GPUPass. - Add new temporary Node Compatibility type. Compatibility types should be removed in the future.
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
struct bContext;
|
||||
struct GPUFrameBuffer;
|
||||
struct GPUShader;
|
||||
struct GPUMaterial;
|
||||
struct GPUTexture;
|
||||
struct GPUUniformBuffer;
|
||||
struct Object;
|
||||
@@ -245,6 +246,8 @@ typedef enum {
|
||||
} DRWState;
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, struct Batch *geom);
|
||||
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, struct Batch *geom);
|
||||
DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass);
|
||||
DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass);
|
||||
|
||||
@@ -47,11 +47,13 @@
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "intern/gpu_codegen.h"
|
||||
#include "GPU_batch.h"
|
||||
#include "GPU_draw.h"
|
||||
#include "GPU_extensions.h"
|
||||
#include "GPU_framebuffer.h"
|
||||
#include "GPU_lamp.h"
|
||||
#include "GPU_material.h"
|
||||
#include "GPU_shader.h"
|
||||
#include "GPU_texture.h"
|
||||
#include "GPU_uniformbuffer.h"
|
||||
@@ -614,6 +616,80 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
|
||||
return shgroup;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass)
|
||||
{
|
||||
double time = 0.0; /* TODO make time variable */
|
||||
const int max_tex = GPU_max_textures() - 1;
|
||||
|
||||
/* TODO : Ideally we should not convert. But since the whole codegen
|
||||
* is relying on GPUPass we keep it as is for now. */
|
||||
|
||||
GPUPass *gpupass = GPU_material_get_pass(material);
|
||||
|
||||
if (!gpupass) {
|
||||
/* Shader compilation error */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct GPUShader *shader = GPU_pass_shader(gpupass);
|
||||
|
||||
DRWShadingGroup *grp = DRW_shgroup_create(shader, pass);
|
||||
|
||||
/* Converting dynamic GPUInput to DRWUniform */
|
||||
ListBase *inputs = &gpupass->inputs;
|
||||
|
||||
for (GPUInput *input = inputs->first; input; input = input->next) {
|
||||
/* Textures */
|
||||
if (input->ima) {
|
||||
GPUTexture *tex = GPU_texture_from_blender(input->ima, input->iuser, input->textarget, input->image_isdata, time, 1);
|
||||
|
||||
if (input->bindtex) {
|
||||
/* TODO maybe track texture slot usage to avoid clash with engine textures */
|
||||
DRW_shgroup_uniform_texture(grp, input->shadername, tex, max_tex - input->texid);
|
||||
}
|
||||
}
|
||||
/* Floats */
|
||||
else {
|
||||
switch (input->type) {
|
||||
case 1:
|
||||
DRW_shgroup_uniform_float(grp, input->shadername, (float *)input->dynamicvec, 1);
|
||||
break;
|
||||
case 2:
|
||||
DRW_shgroup_uniform_vec2(grp, input->shadername, (float *)input->dynamicvec, 1);
|
||||
break;
|
||||
case 3:
|
||||
DRW_shgroup_uniform_vec3(grp, input->shadername, (float *)input->dynamicvec, 1);
|
||||
break;
|
||||
case 4:
|
||||
DRW_shgroup_uniform_vec4(grp, input->shadername, (float *)input->dynamicvec, 1);
|
||||
break;
|
||||
case 9:
|
||||
DRW_shgroup_uniform_mat3(grp, input->shadername, (float *)input->dynamicvec);
|
||||
break;
|
||||
case 16:
|
||||
DRW_shgroup_uniform_mat4(grp, input->shadername, (float *)input->dynamicvec);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return grp;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, Batch *geom)
|
||||
{
|
||||
DRWShadingGroup *shgroup = DRW_shgroup_material_create(material, pass);
|
||||
|
||||
if (shgroup) {
|
||||
shgroup->type = DRW_SHG_INSTANCE;
|
||||
shgroup->instance_geom = geom;
|
||||
}
|
||||
|
||||
return shgroup;
|
||||
}
|
||||
|
||||
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, Batch *geom)
|
||||
{
|
||||
DRWShadingGroup *shgroup = DRW_shgroup_create(shader, pass);
|
||||
|
||||
Reference in New Issue
Block a user