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:
authorAntony Riakiotakis <kalast@gmail.com>2011-12-15 17:58:09 +0400
committerAntony Riakiotakis <kalast@gmail.com>2011-12-15 17:58:09 +0400
commit6ccc605660ea0b45b723016e82b3635f8d5cc707 (patch)
tree7def5ad95056f9c36a778d6de25565b420dfe048 /source/blender/gpu/intern/gpu_codegen.c
parent030694b26041d793ca53aa4282e3e4e2d98f559f (diff)
Bicubic bump map filtering.
This commit introduces bicubic bump map capabilities for the viewport for OpenGL 3.0+ capable GPUs. To use the functionality change the bump mapping method to "best quality" Previous "best quality" setting becomes "medium quality" now. For non OpenGL 3.0 GPUs this becomes the same as "medium quality" Also: * added tooltip descriptions to the bump method settings. * modified the shader to ommit extraneous matrix multiplications for matrices already provided by OpenGL. Bicubic shader by Morten Mikkelsen. Thanks a lot! Oh...and FIRST!
Diffstat (limited to 'source/blender/gpu/intern/gpu_codegen.c')
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 05c459b703d..cc4b092a071 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -59,6 +59,10 @@
extern char datatoc_gpu_shader_material_glsl[];
extern char datatoc_gpu_shader_vertex_glsl[];
+
+static char *glsl_material_library = NULL;
+
+
/* structs and defines */
static const char* GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4",
@@ -229,7 +233,7 @@ GPUFunction *GPU_lookup_function(const char *name)
{
if(!FUNCTION_HASH) {
FUNCTION_HASH = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "GPU_lookup_function gh");
- gpu_parse_functions_string(FUNCTION_HASH, datatoc_gpu_shader_material_glsl);
+ gpu_parse_functions_string(FUNCTION_HASH, glsl_material_library);
/*FUNCTION_PROTOTYPES = gpu_generate_function_prototyps(FUNCTION_HASH);
FUNCTION_LIB = GPU_shader_create_lib(datatoc_gpu_shader_material_glsl);*/
}
@@ -248,6 +252,9 @@ void GPU_extensions_exit(void)
BLI_ghash_free(FUNCTION_HASH, NULL, (GHashValFreeFP)MEM_freeN);
FUNCTION_HASH = NULL;
}
+
+ if(glsl_material_library)
+ MEM_freeN(glsl_material_library);
/*if(FUNCTION_PROTOTYPES) {
MEM_freeN(FUNCTION_PROTOTYPES);
FUNCTION_PROTOTYPES = NULL;
@@ -640,6 +647,35 @@ static char *code_generate_vertex(ListBase *nodes)
return code;
}
+int GPU_bicubic_bump_support(void){
+ return GLEW_ARB_texture_gather && GLEW_ARB_texture_query_lod && GLEW_VERSION_3_0;
+}
+
+void GPU_code_generate_glsl_lib(void){
+ DynStr *ds;
+
+ /* only initialize the library once */
+ if(glsl_material_library)
+ return;
+
+ ds = BLI_dynstr_new();
+
+ if(GPU_bicubic_bump_support()){
+ BLI_dynstr_append(ds, "/* These are needed for high quality bump mapping */\n"
+ "#version 130\n"
+ "#extension GL_ARB_texture_gather: enable\n"
+ "#extension GL_ARB_texture_query_lod: enable\n"
+ "#define BUMP_BICUBIC\n");
+ }
+ BLI_dynstr_append(ds, datatoc_gpu_shader_material_glsl);
+
+
+ glsl_material_library = BLI_dynstr_get_cstring(ds);
+
+ BLI_dynstr_free(ds);
+}
+
+
/* GPU pass binding/unbinding */
GPUShader *GPU_pass_shader(GPUPass *pass)
@@ -1318,7 +1354,7 @@ GPUPass *GPU_generate_pass(ListBase *nodes, GPUNodeLink *outlink, GPUVertexAttri
/* generate code and compile with opengl */
fragmentcode = code_generate_fragment(nodes, outlink->output, name);
vertexcode = code_generate_vertex(nodes);
- shader = GPU_shader_create(vertexcode, fragmentcode, datatoc_gpu_shader_material_glsl); /*FUNCTION_LIB);*/
+ shader = GPU_shader_create(vertexcode, fragmentcode, glsl_material_library); /*FUNCTION_LIB);*/
/* failed? */
if (!shader) {
@@ -1335,7 +1371,7 @@ GPUPass *GPU_generate_pass(ListBase *nodes, GPUNodeLink *outlink, GPUVertexAttri
pass->shader = shader;
pass->fragmentcode = fragmentcode;
pass->vertexcode = vertexcode;
- pass->libcode = datatoc_gpu_shader_material_glsl;
+ pass->libcode = glsl_material_library;
/* extract dynamic inputs and throw away nodes */
GPU_nodes_extract_dynamic_inputs(pass, nodes);