Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/CMakeLists.txt6
-rw-r--r--source/blender/gpu/GPU_draw.h1
-rw-r--r--source/blender/gpu/GPU_immediate.h50
-rw-r--r--source/blender/gpu/GPU_shader.h5
-rw-r--r--source/blender/gpu/GPU_shader_interface.h1
-rw-r--r--source/blender/gpu/GPU_vertex_format.h3
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c12
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h2
-rw-r--r--source/blender/gpu/intern/gpu_draw.c297
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c128
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c30
-rw-r--r--source/blender/gpu/intern/gpu_material.c1
-rw-r--r--source/blender/gpu/intern/gpu_shader.c17
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.c1
-rw-r--r--source/blender/gpu/intern/gpu_texture.c5
-rw-r--r--source/blender/gpu/intern/gpu_vertex_format.c111
-rw-r--r--source/blender/gpu/shaders/gpu_shader_fire_frag.glsl15
-rw-r--r--source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl47
-rw-r--r--source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl15
19 files changed, 465 insertions, 282 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index e8c3a19b77e..85a3b604e33 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -88,9 +88,6 @@ set(SRC
intern/gpu_viewport.c
shaders/gpu_shader_material.glsl
- shaders/gpu_shader_fire_frag.glsl
- shaders/gpu_shader_smoke_frag.glsl
- shaders/gpu_shader_smoke_vert.glsl
GPU_attr_binding.h
GPU_batch.h
@@ -239,9 +236,6 @@ data_to_c_simple(shaders/gpu_shader_keyframe_diamond_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_keyframe_diamond_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_geometry.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_fire_frag.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_smoke_frag.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_smoke_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_material.glsl SRC)
data_to_c_simple(shaders/gpu_shader_gpencil_stroke_vert.glsl SRC)
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 028756bc739..008f4199b02 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -103,6 +103,7 @@ void GPU_free_images_old(struct Main *bmain);
void GPU_free_smoke(struct SmokeModifierData *smd);
void GPU_free_smoke_velocity(struct SmokeModifierData *smd);
void GPU_create_smoke(struct SmokeModifierData *smd, int highres);
+void GPU_create_smoke_coba_field(struct SmokeModifierData *smd);
void GPU_create_smoke_velocity(struct SmokeModifierData *smd);
/* Delayed free of OpenGL buffers by main thread */
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index c8a4ea6a837..846adc44cee 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -57,46 +57,46 @@ GPUBatch *immBeginBatchAtMost(GPUPrimType, uint vertex_len);
/* Provide attribute values that can change per vertex. */
/* First vertex after immBegin must have all its attributes specified. */
-/* Skipped attributes will continue using the previous value for that attrib_id. */
-void immAttrib1f(uint attrib_id, float x);
-void immAttrib2f(uint attrib_id, float x, float y);
-void immAttrib3f(uint attrib_id, float x, float y, float z);
-void immAttrib4f(uint attrib_id, float x, float y, float z, float w);
+/* Skipped attributes will continue using the previous value for that attr_id. */
+void immAttr1f(uint attr_id, float x);
+void immAttr2f(uint attr_id, float x, float y);
+void immAttr3f(uint attr_id, float x, float y, float z);
+void immAttr4f(uint attr_id, float x, float y, float z, float w);
-void immAttrib2i(uint attrib_id, int x, int y);
+void immAttr2i(uint attr_id, int x, int y);
-void immAttrib1u(uint attrib_id, uint x);
+void immAttr1u(uint attr_id, uint x);
-void immAttrib2s(uint attrib_id, short x, short y);
+void immAttr2s(uint attr_id, short x, short y);
-void immAttrib2fv(uint attrib_id, const float data[2]);
-void immAttrib3fv(uint attrib_id, const float data[3]);
-void immAttrib4fv(uint attrib_id, const float data[4]);
+void immAttr2fv(uint attr_id, const float data[2]);
+void immAttr3fv(uint attr_id, const float data[3]);
+void immAttr4fv(uint attr_id, const float data[4]);
-void immAttrib3ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b);
-void immAttrib4ub(uint attrib_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+void immAttr3ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b);
+void immAttr4ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
-void immAttrib3ubv(uint attrib_id, const unsigned char data[4]);
-void immAttrib4ubv(uint attrib_id, const unsigned char data[4]);
+void immAttr3ubv(uint attr_id, const unsigned char data[4]);
+void immAttr4ubv(uint attr_id, const unsigned char data[4]);
/* Explicitly skip an attribute. */
-/* This advanced option kills automatic value copying for this attrib_id. */
-void immSkipAttrib(uint attrib_id);
+/* This advanced option kills automatic value copying for this attr_id. */
+void immAttrSkip(uint attr_id);
/* Provide one last attribute value & end the current vertex. */
/* This is most often used for 2D or 3D position (similar to glVertex). */
-void immVertex2f(uint attrib_id, float x, float y);
-void immVertex3f(uint attrib_id, float x, float y, float z);
-void immVertex4f(uint attrib_id, float x, float y, float z, float w);
+void immVertex2f(uint attr_id, float x, float y);
+void immVertex3f(uint attr_id, float x, float y, float z);
+void immVertex4f(uint attr_id, float x, float y, float z, float w);
-void immVertex2i(uint attrib_id, int x, int y);
+void immVertex2i(uint attr_id, int x, int y);
-void immVertex2s(uint attrib_id, short x, short y);
+void immVertex2s(uint attr_id, short x, short y);
-void immVertex2fv(uint attrib_id, const float data[2]);
-void immVertex3fv(uint attrib_id, const float data[3]);
+void immVertex2fv(uint attr_id, const float data[2]);
+void immVertex3fv(uint attr_id, const float data[3]);
-void immVertex2iv(uint attrib_id, const int data[2]);
+void immVertex2iv(uint attr_id, const int data[2]);
/* Provide uniform values that don't change for the entire draw call. */
void immUniform1i(const char *name, int x);
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index b53e6f108e7..308205339db 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -101,11 +101,6 @@ int GPU_shader_get_attribute(GPUShader *shader, const char *name);
/* Builtin/Non-generated shaders */
typedef enum GPUBuiltinShader {
- /* UNUSED (TODO REMOVE) */
- GPU_SHADER_SMOKE,
- GPU_SHADER_SMOKE_FIRE,
- GPU_SHADER_SMOKE_COBA,
-
/* specialized drawing */
GPU_SHADER_TEXT,
GPU_SHADER_TEXT_SIMPLE,
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h
index 458a49a366b..af89e487cf8 100644
--- a/source/blender/gpu/GPU_shader_interface.h
+++ b/source/blender/gpu/GPU_shader_interface.h
@@ -58,6 +58,7 @@ typedef enum {
GPU_UNIFORM_COLOR, /* vec4 color */
GPU_UNIFORM_EYE, /* vec3 eye */
GPU_UNIFORM_CALLID, /* int callId */
+ GPU_UNIFORM_OBJECT_INFO, /* vec3 objectInfo */
GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */
diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h
index 5e7e036bf41..113a3e894d0 100644
--- a/source/blender/gpu/GPU_vertex_format.h
+++ b/source/blender/gpu/GPU_vertex_format.h
@@ -80,8 +80,11 @@ typedef struct GPUVertFormat {
GPUVertAttr attribs[GPU_VERT_ATTR_MAX_LEN]; /* TODO: variable-size attribs array */
} GPUVertFormat;
+struct GPUShaderInterface;
+
void GPU_vertformat_clear(GPUVertFormat *);
void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat *src);
+void GPU_vertformat_from_interface(GPUVertFormat *format, const struct GPUShaderInterface *shaderface);
uint GPU_vertformat_attr_add(
GPUVertFormat *, const char *name,
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index c1e6b9b53a0..808cb985bf5 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -759,7 +759,7 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
BLI_dynstr_append(ds, ";\n");
}
-static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUOutput *output)
+static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUOutput *output, int *rbuiltins)
{
DynStr *ds = BLI_dynstr_new();
char *code;
@@ -770,14 +770,13 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO
#endif
codegen_set_unique_ids(nodes);
- builtins = codegen_process_uniforms_functions(material, ds, nodes);
-
+ *rbuiltins = builtins = codegen_process_uniforms_functions(material, ds, nodes);
if (builtins & GPU_BARYCENTRIC_TEXCO)
- BLI_dynstr_append(ds, "\tin vec2 barycentricTexCo;\n");
+ BLI_dynstr_append(ds, "in vec2 barycentricTexCo;\n");
if (builtins & GPU_BARYCENTRIC_DIST)
- BLI_dynstr_append(ds, "\tflat in vec3 barycentricDist;\n");
+ BLI_dynstr_append(ds, "flat in vec3 barycentricDist;\n");
BLI_dynstr_append(ds, "Closure nodetree_exec(void)\n{\n");
@@ -1790,6 +1789,7 @@ GPUPass *GPU_generate_pass(
GPUNodeLink *frag_outlink,
struct GPUVertexAttribs *attribs,
ListBase *nodes,
+ int *builtins,
const char *vert_code,
const char *geom_code,
const char *frag_lib,
@@ -1804,7 +1804,7 @@ GPUPass *GPU_generate_pass(
GPU_nodes_get_vertex_attributes(nodes, attribs);
/* generate code */
- char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output);
+ char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output, builtins);
/* Cache lookup: Reuse shaders already compiled */
uint32_t hash = gpu_pass_hash(fragmentgen, defines, attribs);
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 39d946d89a0..96be3a1a422 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -179,7 +179,7 @@ typedef struct GPUPass GPUPass;
GPUPass *GPU_generate_pass(
GPUMaterial *material,
GPUNodeLink *frag_outlink, struct GPUVertexAttribs *attribs,
- ListBase *nodes,
+ ListBase *nodes, int *builtins,
const char *vert_code, const char *geom_code,
const char *frag_lib, const char *defines);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 7902c5296aa..685b929ac93 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -62,7 +62,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "BKE_bmfont.h"
+#include "BKE_colorband.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
@@ -883,6 +883,192 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
BKE_image_release_ibuf(ima, ibuf, NULL);
}
+/* *************************** Transfer functions *************************** */
+
+enum {
+ TFUNC_FLAME_SPECTRUM = 0,
+ TFUNC_COLOR_RAMP = 1,
+};
+
+#define TFUNC_WIDTH 256
+
+#ifdef WITH_SMOKE
+static void create_flame_spectrum_texture(float *data)
+{
+#define FIRE_THRESH 7
+#define MAX_FIRE_ALPHA 0.06f
+#define FULL_ON_FIRE 100
+
+ float *spec_pixels = MEM_mallocN(TFUNC_WIDTH * 4 * 16 * 16 * sizeof(float), "spec_pixels");
+
+ blackbody_temperature_to_rgb_table(data, TFUNC_WIDTH, 1500, 3000);
+
+ for (int i = 0; i < 16; i++) {
+ for (int j = 0; j < 16; j++) {
+ for (int k = 0; k < TFUNC_WIDTH; k++) {
+ int index = (j * TFUNC_WIDTH * 16 + i * TFUNC_WIDTH + k) * 4;
+ if (k >= FIRE_THRESH) {
+ spec_pixels[index] = (data[k * 4]);
+ spec_pixels[index + 1] = (data[k * 4 + 1]);
+ spec_pixels[index + 2] = (data[k * 4 + 2]);
+ spec_pixels[index + 3] = MAX_FIRE_ALPHA * (
+ (k > FULL_ON_FIRE) ? 1.0f : (k - FIRE_THRESH) / ((float)FULL_ON_FIRE - FIRE_THRESH));
+ }
+ else {
+ zero_v4(&spec_pixels[index]);
+ }
+ }
+ }
+ }
+
+ memcpy(data, spec_pixels, sizeof(float) * 4 * TFUNC_WIDTH);
+
+ MEM_freeN(spec_pixels);
+
+#undef FIRE_THRESH
+#undef MAX_FIRE_ALPHA
+#undef FULL_ON_FIRE
+}
+
+static void create_color_ramp(const ColorBand *coba, float *data)
+{
+ for (int i = 0; i < TFUNC_WIDTH; i++) {
+ BKE_colorband_evaluate(coba, (float)i / TFUNC_WIDTH, &data[i * 4]);
+ }
+}
+
+static GPUTexture *create_transfer_function(int type, const ColorBand *coba)
+{
+ float *data = MEM_mallocN(sizeof(float) * 4 * TFUNC_WIDTH, __func__);
+
+ switch (type) {
+ case TFUNC_FLAME_SPECTRUM:
+ create_flame_spectrum_texture(data);
+ break;
+ case TFUNC_COLOR_RAMP:
+ create_color_ramp(coba, data);
+ break;
+ }
+
+ GPUTexture *tex = GPU_texture_create_1D(TFUNC_WIDTH, GPU_RGBA8, data, NULL);
+
+ MEM_freeN(data);
+
+ return tex;
+}
+
+static void swizzle_texture_channel_rrrr(GPUTexture *tex)
+{
+ GPU_texture_bind(tex, 0);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_R, GL_RED);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_G, GL_RED);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED);
+ GPU_texture_unbind(tex);
+}
+
+static GPUTexture *create_field_texture(SmokeDomainSettings *sds)
+{
+ float *field = NULL;
+
+ switch (sds->coba_field) {
+ case FLUID_FIELD_DENSITY: field = smoke_get_density(sds->fluid); break;
+ case FLUID_FIELD_HEAT: field = smoke_get_heat(sds->fluid); break;
+ case FLUID_FIELD_FUEL: field = smoke_get_fuel(sds->fluid); break;
+ case FLUID_FIELD_REACT: field = smoke_get_react(sds->fluid); break;
+ case FLUID_FIELD_FLAME: field = smoke_get_flame(sds->fluid); break;
+ case FLUID_FIELD_VELOCITY_X: field = smoke_get_velocity_x(sds->fluid); break;
+ case FLUID_FIELD_VELOCITY_Y: field = smoke_get_velocity_y(sds->fluid); break;
+ case FLUID_FIELD_VELOCITY_Z: field = smoke_get_velocity_z(sds->fluid); break;
+ case FLUID_FIELD_COLOR_R: field = smoke_get_color_r(sds->fluid); break;
+ case FLUID_FIELD_COLOR_G: field = smoke_get_color_g(sds->fluid); break;
+ case FLUID_FIELD_COLOR_B: field = smoke_get_color_b(sds->fluid); break;
+ case FLUID_FIELD_FORCE_X: field = smoke_get_force_x(sds->fluid); break;
+ case FLUID_FIELD_FORCE_Y: field = smoke_get_force_y(sds->fluid); break;
+ case FLUID_FIELD_FORCE_Z: field = smoke_get_force_z(sds->fluid); break;
+ default: return NULL;
+ }
+
+ GPUTexture *tex = GPU_texture_create_nD(
+ sds->res[0], sds->res[1], sds->res[2], 3,
+ field, GPU_R8, GPU_DATA_FLOAT, 0, true, NULL);
+
+ swizzle_texture_channel_rrrr(tex);
+ return tex;
+}
+
+static GPUTexture *create_density_texture(SmokeDomainSettings *sds, int highres)
+{
+ float *data = NULL, *source;
+ int cell_count = (highres) ? smoke_turbulence_get_cells(sds->wt) : sds->total_cells;
+ const bool has_color = (highres) ? smoke_turbulence_has_colors(sds->wt) : smoke_has_colors(sds->fluid);
+ int *dim = (highres) ? sds->res_wt : sds->res;
+ GPUTextureFormat format = (has_color) ? GPU_RGBA8 : GPU_R8;
+
+ if (has_color) {
+ data = MEM_callocN(sizeof(float) * cell_count * 4, "smokeColorTexture");
+ }
+
+ if (highres) {
+ if (has_color) {
+ smoke_turbulence_get_rgba(sds->wt, data, 0);
+ }
+ else {
+ source = smoke_turbulence_get_density(sds->wt);
+ }
+ }
+ else {
+ if (has_color) {
+ smoke_get_rgba(sds->fluid, data, 0);
+ }
+ else {
+ source = smoke_get_density(sds->fluid);
+ }
+ }
+
+ GPUTexture *tex = GPU_texture_create_nD(
+ dim[0], dim[1], dim[2], 3,
+ (data) ? data : source,
+ format, GPU_DATA_FLOAT, 0, true, NULL);
+ if (data) {
+ MEM_freeN(data);
+ }
+
+ if (format == GPU_R8) {
+ /* Swizzle the RGBA components to read the Red channel so
+ * that the shader stay the same for colored and non color
+ * density textures. */
+ swizzle_texture_channel_rrrr(tex);
+ }
+ return tex;
+}
+
+static GPUTexture *create_flame_texture(SmokeDomainSettings *sds, int highres)
+{
+ float *source = NULL;
+ const bool has_fuel = (highres) ? smoke_turbulence_has_fuel(sds->wt) : smoke_has_fuel(sds->fluid);
+ int *dim = (highres) ? sds->res_wt : sds->res;
+
+ if (!has_fuel)
+ return NULL;
+
+ if (highres) {
+ source = smoke_turbulence_get_flame(sds->wt);
+ }
+ else {
+ source = smoke_get_flame(sds->fluid);
+ }
+
+ GPUTexture *tex = GPU_texture_create_nD(
+ dim[0], dim[1], dim[2], 3,
+ source, GPU_R8, GPU_DATA_FLOAT, 0, true, NULL);
+
+ swizzle_texture_channel_rrrr(tex);
+
+ return tex;
+}
+#endif /* WITH_SMOKE */
+
void GPU_free_smoke(SmokeModifierData *smd)
{
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
@@ -897,85 +1083,66 @@ void GPU_free_smoke(SmokeModifierData *smd)
if (smd->domain->tex_flame)
GPU_texture_free(smd->domain->tex_flame);
smd->domain->tex_flame = NULL;
+
+ if (smd->domain->tex_flame_coba)
+ GPU_texture_free(smd->domain->tex_flame_coba);
+ smd->domain->tex_flame_coba = NULL;
+
+ if (smd->domain->tex_coba)
+ GPU_texture_free(smd->domain->tex_coba);
+ smd->domain->tex_coba = NULL;
+
+ if (smd->domain->tex_field)
+ GPU_texture_free(smd->domain->tex_field);
+ smd->domain->tex_field = NULL;
}
}
-void GPU_create_smoke(SmokeModifierData *smd, int highres)
+void GPU_create_smoke_coba_field(SmokeModifierData *smd)
{
#ifdef WITH_SMOKE
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
SmokeDomainSettings *sds = smd->domain;
- if (!sds->tex && !highres) {
- /* rgba texture for color + density */
- if (smoke_has_colors(sds->fluid)) {
- float *data = MEM_callocN(sizeof(float) * sds->total_cells * 4, "smokeColorTexture");
- smoke_get_rgba(sds->fluid, data, 0);
- sds->tex = GPU_texture_create_3D(sds->res[0], sds->res[1], sds->res[2], GPU_RGBA8, data, NULL);
- MEM_freeN(data);
- }
- /* density only */
- else {
- sds->tex = GPU_texture_create_3D(
- sds->res[0], sds->res[1], sds->res[2],
- GPU_R8, smoke_get_density(sds->fluid), NULL);
-
- /* Swizzle the RGBA components to read the Red channel so
- * that the shader stay the same for colored and non color
- * density textures. */
- GPU_texture_bind(sds->tex, 0);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_R, GL_RED);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_G, GL_RED);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_B, GL_RED);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED);
- GPU_texture_unbind(sds->tex);
- }
- sds->tex_flame = (
- smoke_has_fuel(sds->fluid) ?
- GPU_texture_create_3D(
- sds->res[0], sds->res[1], sds->res[2],
- GPU_R8, smoke_get_flame(sds->fluid), NULL) :
- NULL);
+
+ if (!sds->tex_field) {
+ sds->tex_field = create_field_texture(sds);
}
- else if (!sds->tex && highres) {
- /* rgba texture for color + density */
- if (smoke_turbulence_has_colors(sds->wt)) {
- float *data = MEM_callocN(sizeof(float) * smoke_turbulence_get_cells(sds->wt) * 4, "smokeColorTexture");
- smoke_turbulence_get_rgba(sds->wt, data, 0);
- sds->tex = GPU_texture_create_3D(sds->res_wt[0], sds->res_wt[1], sds->res_wt[2], GPU_RGBA8, data, NULL);
- MEM_freeN(data);
- }
- /* density only */
- else {
- sds->tex = GPU_texture_create_3D(
- sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
- GPU_R8, smoke_turbulence_get_density(sds->wt), NULL);
-
- /* Swizzle the RGBA components to read the Red channel so
- * that the shader stay the same for colored and non color
- * density textures. */
- GPU_texture_bind(sds->tex, 0);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_R, GL_RED);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_G, GL_RED);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_B, GL_RED);
- glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SWIZZLE_A, GL_RED);
- GPU_texture_unbind(sds->tex);
- }
- sds->tex_flame = (
- smoke_turbulence_has_fuel(sds->wt) ?
- GPU_texture_create_3D(
- sds->res_wt[0], sds->res_wt[1], sds->res_wt[2],
- GPU_R8, smoke_turbulence_get_flame(sds->wt), NULL) :
- NULL);
+ if (!sds->tex_coba) {
+ sds->tex_coba = create_transfer_function(TFUNC_COLOR_RAMP, sds->coba);
}
+ }
+#else // WITH_SMOKE
+ smd->domain->tex_field = NULL;
+#endif // WITH_SMOKE
+}
- sds->tex_shadow = GPU_texture_create_3D(
- sds->res[0], sds->res[1], sds->res[2],
- GPU_R8, sds->shadow, NULL);
+void GPU_create_smoke(SmokeModifierData *smd, int highres)
+{
+#ifdef WITH_SMOKE
+ if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
+ SmokeDomainSettings *sds = smd->domain;
+
+ if (!sds->tex) {
+ sds->tex = create_density_texture(sds, highres);
+ }
+ if (!sds->tex_flame) {
+ sds->tex_flame = create_flame_texture(sds, highres);
+ }
+ if (!sds->tex_flame_coba && sds->tex_flame) {
+ sds->tex_flame_coba = create_transfer_function(TFUNC_FLAME_SPECTRUM, NULL);
+ }
+ if (!sds->tex_shadow) {
+ sds->tex_shadow = GPU_texture_create_nD(
+ sds->res[0], sds->res[1], sds->res[2], 3,
+ sds->shadow,
+ GPU_R8, GPU_DATA_FLOAT, 0, true, NULL);
+ }
}
#else // WITH_SMOKE
(void)highres;
smd->domain->tex = NULL;
smd->domain->tex_flame = NULL;
+ smd->domain->tex_flame_coba = NULL;
smd->domain->tex_shadow = NULL;
#endif // WITH_SMOKE
}
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
index 6e3de51df6b..a71ba68821b 100644
--- a/source/blender/gpu/intern/gpu_immediate.c
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -412,56 +412,56 @@ static void setAttribValueBit(uint attrib_id)
/* --- generic attribute functions --- */
-void immAttrib1f(uint attrib_id, float x)
+void immAttr1f(uint attrib_id, float x)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_F32);
- assert(attrib->comp_len == 1);
+ assert(attr->comp_type == GPU_COMP_F32);
+ assert(attr->comp_len == 1);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- float *data = (float *)(imm.vertex_data + attrib->offset);
+ float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
data[0] = x;
}
-void immAttrib2f(uint attrib_id, float x, float y)
+void immAttr2f(uint attrib_id, float x, float y)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_F32);
- assert(attrib->comp_len == 2);
+ assert(attr->comp_type == GPU_COMP_F32);
+ assert(attr->comp_len == 2);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- float *data = (float *)(imm.vertex_data + attrib->offset);
+ float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
data[0] = x;
data[1] = y;
}
-void immAttrib3f(uint attrib_id, float x, float y, float z)
+void immAttr3f(uint attrib_id, float x, float y, float z)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_F32);
- assert(attrib->comp_len == 3);
+ assert(attr->comp_type == GPU_COMP_F32);
+ assert(attr->comp_len == 3);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- float *data = (float *)(imm.vertex_data + attrib->offset);
+ float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
data[0] = x;
@@ -469,19 +469,19 @@ void immAttrib3f(uint attrib_id, float x, float y, float z)
data[2] = z;
}
-void immAttrib4f(uint attrib_id, float x, float y, float z, float w)
+void immAttr4f(uint attrib_id, float x, float y, float z, float w)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_F32);
- assert(attrib->comp_len == 4);
+ assert(attr->comp_type == GPU_COMP_F32);
+ assert(attr->comp_len == 4);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- float *data = (float *)(imm.vertex_data + attrib->offset);
+ float *data = (float *)(imm.vertex_data + attr->offset);
/* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm.buffer_data, data); */
data[0] = x;
@@ -490,87 +490,87 @@ void immAttrib4f(uint attrib_id, float x, float y, float z, float w)
data[3] = w;
}
-void immAttrib1u(uint attrib_id, uint x)
+void immAttr1u(uint attrib_id, uint x)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_U32);
- assert(attrib->comp_len == 1);
+ assert(attr->comp_type == GPU_COMP_U32);
+ assert(attr->comp_len == 1);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- uint *data = (uint *)(imm.vertex_data + attrib->offset);
+ uint *data = (uint *)(imm.vertex_data + attr->offset);
data[0] = x;
}
-void immAttrib2i(uint attrib_id, int x, int y)
+void immAttr2i(uint attrib_id, int x, int y)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_I32);
- assert(attrib->comp_len == 2);
+ assert(attr->comp_type == GPU_COMP_I32);
+ assert(attr->comp_len == 2);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- int *data = (int *)(imm.vertex_data + attrib->offset);
+ int *data = (int *)(imm.vertex_data + attr->offset);
data[0] = x;
data[1] = y;
}
-void immAttrib2s(uint attrib_id, short x, short y)
+void immAttr2s(uint attrib_id, short x, short y)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_I16);
- assert(attrib->comp_len == 2);
+ assert(attr->comp_type == GPU_COMP_I16);
+ assert(attr->comp_len == 2);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- short *data = (short *)(imm.vertex_data + attrib->offset);
+ short *data = (short *)(imm.vertex_data + attr->offset);
data[0] = x;
data[1] = y;
}
-void immAttrib2fv(uint attrib_id, const float data[2])
+void immAttr2fv(uint attrib_id, const float data[2])
{
- immAttrib2f(attrib_id, data[0], data[1]);
+ immAttr2f(attrib_id, data[0], data[1]);
}
-void immAttrib3fv(uint attrib_id, const float data[3])
+void immAttr3fv(uint attrib_id, const float data[3])
{
- immAttrib3f(attrib_id, data[0], data[1], data[2]);
+ immAttr3f(attrib_id, data[0], data[1], data[2]);
}
-void immAttrib4fv(uint attrib_id, const float data[4])
+void immAttr4fv(uint attrib_id, const float data[4])
{
- immAttrib4f(attrib_id, data[0], data[1], data[2], data[3]);
+ immAttr4f(attrib_id, data[0], data[1], data[2], data[3]);
}
-void immAttrib3ub(uint attrib_id, uchar r, uchar g, uchar b)
+void immAttr3ub(uint attrib_id, uchar r, uchar g, uchar b)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_U8);
- assert(attrib->comp_len == 3);
+ assert(attr->comp_type == GPU_COMP_U8);
+ assert(attr->comp_len == 3);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- GLubyte *data = imm.vertex_data + attrib->offset;
+ GLubyte *data = imm.vertex_data + attr->offset;
/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */
data[0] = r;
@@ -578,19 +578,19 @@ void immAttrib3ub(uint attrib_id, uchar r, uchar g, uchar b)
data[2] = b;
}
-void immAttrib4ub(uint attrib_id, uchar r, uchar g, uchar b, uchar a)
+void immAttr4ub(uint attrib_id, uchar r, uchar g, uchar b, uchar a)
{
- GPUVertAttr *attrib = imm.vertex_format.attribs + attrib_id;
+ GPUVertAttr *attr = imm.vertex_format.attribs + attrib_id;
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
- assert(attrib->comp_type == GPU_COMP_U8);
- assert(attrib->comp_len == 4);
+ assert(attr->comp_type == GPU_COMP_U8);
+ assert(attr->comp_len == 4);
assert(imm.vertex_idx < imm.vertex_len);
assert(imm.prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
#endif
setAttribValueBit(attrib_id);
- GLubyte *data = imm.vertex_data + attrib->offset;
+ GLubyte *data = imm.vertex_data + attr->offset;
/* printf("%s %td %p\n", __FUNCTION__, data - imm.buffer_data, data); */
data[0] = r;
@@ -599,17 +599,17 @@ void immAttrib4ub(uint attrib_id, uchar r, uchar g, uchar b, uchar a)
data[3] = a;
}
-void immAttrib3ubv(uint attrib_id, const uchar data[3])
+void immAttr3ubv(uint attrib_id, const uchar data[3])
{
- immAttrib3ub(attrib_id, data[0], data[1], data[2]);
+ immAttr3ub(attrib_id, data[0], data[1], data[2]);
}
-void immAttrib4ubv(uint attrib_id, const uchar data[4])
+void immAttr4ubv(uint attrib_id, const uchar data[4])
{
- immAttrib4ub(attrib_id, data[0], data[1], data[2], data[3]);
+ immAttr4ub(attrib_id, data[0], data[1], data[2], data[3]);
}
-void immSkipAttrib(uint attrib_id)
+void immAttrSkip(uint attrib_id)
{
#if TRUST_NO_ONE
assert(attrib_id < imm.vertex_format.attr_len);
@@ -652,49 +652,49 @@ static void immEndVertex(void) /* and move on to the next vertex */
void immVertex2f(uint attrib_id, float x, float y)
{
- immAttrib2f(attrib_id, x, y);
+ immAttr2f(attrib_id, x, y);
immEndVertex();
}
void immVertex3f(uint attrib_id, float x, float y, float z)
{
- immAttrib3f(attrib_id, x, y, z);
+ immAttr3f(attrib_id, x, y, z);
immEndVertex();
}
void immVertex4f(uint attrib_id, float x, float y, float z, float w)
{
- immAttrib4f(attrib_id, x, y, z, w);
+ immAttr4f(attrib_id, x, y, z, w);
immEndVertex();
}
void immVertex2i(uint attrib_id, int x, int y)
{
- immAttrib2i(attrib_id, x, y);
+ immAttr2i(attrib_id, x, y);
immEndVertex();
}
void immVertex2s(uint attrib_id, short x, short y)
{
- immAttrib2s(attrib_id, x, y);
+ immAttr2s(attrib_id, x, y);
immEndVertex();
}
void immVertex2fv(uint attrib_id, const float data[2])
{
- immAttrib2f(attrib_id, data[0], data[1]);
+ immAttr2f(attrib_id, data[0], data[1]);
immEndVertex();
}
void immVertex3fv(uint attrib_id, const float data[3])
{
- immAttrib3f(attrib_id, data[0], data[1], data[2]);
+ immAttr3f(attrib_id, data[0], data[1], data[2]);
immEndVertex();
}
void immVertex2iv(uint attrib_id, const int data[2])
{
- immAttrib2i(attrib_id, data[0], data[1]);
+ immAttr2i(attrib_id, data[0], data[1]);
immEndVertex();
}
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index d0f0c3aacce..983c70281a2 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -89,35 +89,35 @@ void immRecti(uint pos, int x1, int y1, int x2, int y2)
void immRectf_fast_with_color(uint pos, uint col, float x1, float y1, float x2, float y2, const float color[4])
{
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2f(pos, x1, y1);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2f(pos, x2, y1);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2f(pos, x2, y2);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2f(pos, x1, y1);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2f(pos, x2, y2);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2f(pos, x1, y2);
}
void immRecti_fast_with_color(uint pos, uint col, int x1, int y1, int x2, int y2, const float color[4])
{
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2i(pos, x1, y1);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2i(pos, x2, y1);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2i(pos, x2, y2);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2i(pos, x1, y1);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2i(pos, x2, y2);
- immAttrib4fv(col, color);
+ immAttr4fv(col, color);
immVertex2i(pos, x1, y2);
}
@@ -425,16 +425,16 @@ void imm_draw_cylinder_fill_normal_3d(
n2[0] = cos2; n2[1] = sin2; n2[2] = 1 - n2[2];
/* first tri */
- immAttrib3fv(nor, n2);
+ immAttr3fv(nor, n2);
immVertex3fv(pos, v1);
immVertex3fv(pos, v2);
- immAttrib3fv(nor, n1);
+ immAttr3fv(nor, n1);
immVertex3fv(pos, v3);
/* second tri */
immVertex3fv(pos, v3);
immVertex3fv(pos, v4);
- immAttrib3fv(nor, n2);
+ immAttr3fv(nor, n2);
immVertex3fv(pos, v1);
}
}
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index ac97867f40f..986003c99e6 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -688,6 +688,7 @@ GPUMaterial *GPU_material_from_nodetree(
mat->outlink,
&mat->attribs,
&mat->nodes,
+ &mat->builtins,
vert_code,
geom_code,
frag_lib,
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 274ad1c8c0c..d428e2f9bd9 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -167,10 +167,6 @@ extern char datatoc_gpu_shader_text_simple_geom_glsl[];
extern char datatoc_gpu_shader_keyframe_diamond_vert_glsl[];
extern char datatoc_gpu_shader_keyframe_diamond_frag_glsl[];
-extern char datatoc_gpu_shader_fire_frag_glsl[];
-extern char datatoc_gpu_shader_smoke_vert_glsl[];
-extern char datatoc_gpu_shader_smoke_frag_glsl[];
-
extern char datatoc_gpu_shader_gpencil_stroke_vert_glsl[];
extern char datatoc_gpu_shader_gpencil_stroke_frag_glsl[];
extern char datatoc_gpu_shader_gpencil_stroke_geom_glsl[];
@@ -664,16 +660,6 @@ int GPU_shader_get_attribute(GPUShader *shader, const char *name)
}
static const GPUShaderStages builtin_shader_stages[GPU_NUM_BUILTIN_SHADERS] = {
- [GPU_SHADER_SMOKE] =
- { datatoc_gpu_shader_smoke_vert_glsl,
- datatoc_gpu_shader_smoke_frag_glsl },
- [GPU_SHADER_SMOKE_FIRE] =
- { datatoc_gpu_shader_smoke_vert_glsl,
- datatoc_gpu_shader_smoke_frag_glsl },
- [GPU_SHADER_SMOKE_COBA] =
- { datatoc_gpu_shader_smoke_vert_glsl,
- datatoc_gpu_shader_smoke_frag_glsl },
-
[GPU_SHADER_TEXT] =
{ datatoc_gpu_shader_text_vert_glsl,
datatoc_gpu_shader_text_frag_glsl,
@@ -997,9 +983,6 @@ static const char *gpu_shader_get_builtin_shader_defines(
case GPU_SHADER_2D_NODELINK_INST:
return "#define USE_INSTANCE\n";
- case GPU_SHADER_SMOKE_COBA:
- return "#define USE_COBA\n";
-
case GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE:
case GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE:
return "#define UNIFORM_SCALE\n";
diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c
index f6bbc228ae9..d46fc979363 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.c
+++ b/source/blender/gpu/intern/gpu_shader_interface.c
@@ -72,6 +72,7 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u)
[GPU_UNIFORM_COLOR] = "color",
[GPU_UNIFORM_EYE] = "eye",
[GPU_UNIFORM_CALLID] = "callId",
+ [GPU_UNIFORM_OBJECT_INFO] = "unfobjectinfo",
[GPU_UNIFORM_CUSTOM] = NULL,
[GPU_NUM_UNIFORMS] = NULL,
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index abb632ce718..6a8e686afb3 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -138,6 +138,7 @@ static int gpu_get_component_count(GPUTextureFormat format)
{
switch (format) {
case GPU_RGBA8:
+ case GPU_RGBA8UI:
case GPU_RGBA16F:
case GPU_RGBA16:
case GPU_RGBA32F:
@@ -183,7 +184,7 @@ static void gpu_validate_data_format(GPUTextureFormat tex_format, GPUDataFormat
}
}
/* Byte formats */
- else if (ELEM(tex_format, GPU_R8, GPU_RG8, GPU_RGBA8)) {
+ else if (ELEM(tex_format, GPU_R8, GPU_RG8, GPU_RGBA8, GPU_RGBA8UI)) {
BLI_assert(ELEM(data_format, GPU_DATA_UNSIGNED_BYTE, GPU_DATA_FLOAT));
}
/* Special case */
@@ -298,6 +299,7 @@ static uint gpu_get_bytesize(GPUTextureFormat data_type)
case GPU_RG16:
case GPU_DEPTH24_STENCIL8:
case GPU_DEPTH_COMPONENT32F:
+ case GPU_RGBA8UI:
case GPU_RGBA8:
case GPU_R11F_G11F_B10F:
case GPU_R32F:
@@ -335,6 +337,7 @@ static GLenum gpu_get_gl_internalformat(GPUTextureFormat format)
case GPU_RG16I: return GL_RG16I;
case GPU_RG16: return GL_RG16;
case GPU_RGBA8: return GL_RGBA8;
+ case GPU_RGBA8UI: return GL_RGBA8UI;
case GPU_R32F: return GL_R32F;
case GPU_R32UI: return GL_R32UI;
case GPU_R32I: return GL_R32I;
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c
index f1aaa99fbc6..c3de3d52b47 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.c
+++ b/source/blender/gpu/intern/gpu_vertex_format.c
@@ -29,6 +29,8 @@
* GPU vertex format
*/
+#include "GPU_shader_interface.h"
+
#include "GPU_vertex_format.h"
#include "gpu_vertex_format_private.h"
#include <stddef.h>
@@ -278,6 +280,115 @@ void VertexFormat_pack(GPUVertFormat *format)
format->packed = true;
}
+static uint calc_input_component_size(const GPUShaderInput *input)
+{
+ int size = input->size;
+ switch (input->gl_type) {
+ case GL_FLOAT_VEC2:
+ case GL_INT_VEC2:
+ case GL_UNSIGNED_INT_VEC2:
+ return size * 2;
+ case GL_FLOAT_VEC3:
+ case GL_INT_VEC3:
+ case GL_UNSIGNED_INT_VEC3:
+ return size * 3;
+ case GL_FLOAT_VEC4:
+ case GL_FLOAT_MAT2:
+ case GL_INT_VEC4:
+ case GL_UNSIGNED_INT_VEC4:
+ return size * 4;
+ case GL_FLOAT_MAT3:
+ return size * 9;
+ case GL_FLOAT_MAT4:
+ return size * 16;
+ case GL_FLOAT_MAT2x3:
+ case GL_FLOAT_MAT3x2:
+ return size * 6;
+ case GL_FLOAT_MAT2x4:
+ case GL_FLOAT_MAT4x2:
+ return size * 8;
+ case GL_FLOAT_MAT3x4:
+ case GL_FLOAT_MAT4x3:
+ return size * 12;
+ default:
+ return size;
+ }
+}
+
+static void get_fetch_mode_and_comp_type(
+ int gl_type,
+ GPUVertCompType *r_comp_type,
+ uint *r_gl_comp_type,
+ GPUVertFetchMode *r_fetch_mode)
+{
+ switch (gl_type) {
+ case GL_FLOAT:
+ case GL_FLOAT_VEC2:
+ case GL_FLOAT_VEC3:
+ case GL_FLOAT_VEC4:
+ case GL_FLOAT_MAT2:
+ case GL_FLOAT_MAT3:
+ case GL_FLOAT_MAT4:
+ case GL_FLOAT_MAT2x3:
+ case GL_FLOAT_MAT2x4:
+ case GL_FLOAT_MAT3x2:
+ case GL_FLOAT_MAT3x4:
+ case GL_FLOAT_MAT4x2:
+ case GL_FLOAT_MAT4x3:
+ *r_comp_type = GPU_COMP_F32;
+ *r_gl_comp_type = GL_FLOAT;
+ *r_fetch_mode = GPU_FETCH_FLOAT;
+ break;
+ case GL_INT:
+ case GL_INT_VEC2:
+ case GL_INT_VEC3:
+ case GL_INT_VEC4:
+ *r_comp_type = GPU_COMP_I32;
+ *r_gl_comp_type = GL_INT;
+ *r_fetch_mode = GPU_FETCH_INT;
+ break;
+ case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_INT_VEC2:
+ case GL_UNSIGNED_INT_VEC3:
+ case GL_UNSIGNED_INT_VEC4:
+ *r_comp_type = GPU_COMP_U32;
+ *r_gl_comp_type = GL_UNSIGNED_INT;
+ *r_fetch_mode = GPU_FETCH_INT;
+ break;
+ default:
+ BLI_assert(0);
+ }
+}
+
+void GPU_vertformat_from_interface(GPUVertFormat *format, const GPUShaderInterface *shaderface)
+{
+ const char *name_buffer = shaderface->name_buffer;
+
+ for (int i = 0; i < GPU_NUM_SHADERINTERFACE_BUCKETS; i++) {
+ const GPUShaderInput *input = shaderface->attrib_buckets[i];
+ if (input == NULL) {
+ continue;
+ }
+
+ const GPUShaderInput *next = input;
+ while (next != NULL) {
+ input = next;
+ next = input->next;
+
+ format->name_len++; /* multiname support */
+ format->attr_len++;
+
+ GPUVertAttr *attrib = format->attribs + input->location;
+
+ attrib->name[attrib->name_len++] = copy_attrib_name(format, name_buffer + input->name_offset);
+ attrib->offset = 0; /* offsets & stride are calculated later (during pack) */
+ attrib->comp_len = calc_input_component_size(input);
+ attrib->sz = attrib->comp_len * 4;
+ get_fetch_mode_and_comp_type(input->gl_type, &attrib->comp_type, &attrib->gl_comp_type, &attrib->fetch_mode);
+ }
+ }
+}
+
/* OpenGL ES packs in a different order as desktop GL but component conversion is the same.
* Of the code here, only struct GPUPackedNormal needs to change. */
diff --git a/source/blender/gpu/shaders/gpu_shader_fire_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fire_frag.glsl
deleted file mode 100644
index fc9cafb6b02..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_fire_frag.glsl
+++ /dev/null
@@ -1,15 +0,0 @@
-
-in vec3 coords;
-out vec4 fragColor;
-
-uniform sampler3D flame_texture;
-uniform sampler1D spectrum_texture;
-
-void main()
-{
- float flame = texture(flame_texture, coords).r;
- vec4 emission = texture(spectrum_texture, flame);
-
- fragColor.rgb = emission.a * emission.rgb;
- fragColor.a = emission.a;
-}
diff --git a/source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl b/source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl
deleted file mode 100644
index b57bd5b6a37..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_smoke_frag.glsl
+++ /dev/null
@@ -1,47 +0,0 @@
-
-in vec3 coords;
-out vec4 fragColor;
-
-uniform vec3 active_color;
-uniform float step_size;
-uniform float density_scale;
-
-uniform sampler3D soot_texture;
-uniform sampler3D shadow_texture;
-
-#ifdef USE_COBA
-uniform sampler1D transfer_texture;
-uniform sampler3D color_band_texture;
-#endif
-
-void main()
-{
- /* compute color and density from volume texture */
- vec4 soot = texture(soot_texture, coords);
-
-#ifndef USE_COBA
- vec3 soot_color;
- if (soot.a != 0) {
- soot_color = active_color * soot.rgb / soot.a;
- }
- else {
- soot_color = vec3(0);
- }
- float soot_density = density_scale * soot.a;
-
- /* compute transmittance and alpha */
- float soot_transmittance = pow(2.71828182846, -soot_density * step_size);
- float soot_alpha = 1.0 - soot_transmittance;
-
- /* shade */
- float shadow = texture(shadow_texture, coords).r;
- soot_color *= soot_transmittance * shadow;
-
- /* premultiply alpha */
- fragColor = vec4(soot_alpha * soot_color, soot_alpha);
-#else
- float color_band = texture(color_band_texture, coords).r;
- vec4 transfer_function = texture(transfer_texture, color_band);
- fragColor = transfer_function * density_scale;
-#endif
-}
diff --git a/source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl b/source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl
deleted file mode 100644
index 8c30e9baf9e..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_smoke_vert.glsl
+++ /dev/null
@@ -1,15 +0,0 @@
-
-uniform mat4 ModelViewProjectionMatrix;
-
-out vec3 coords;
-
-uniform vec3 min_location;
-uniform vec3 invsize;
-uniform vec3 ob_sizei;
-
-void main()
-{
- // TODO: swap gl_Vertex for vec3 pos, update smoke setup code
- gl_Position = ModelViewProjectionMatrix * vec4(gl_Vertex.xyz * ob_sizei, 1.0);
- coords = (gl_Vertex.xyz - min_location) * invsize;
-}