[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15690] branches/apricot/source: Apricot Branch: GLSL
Brecht Van Lommel
brechtvanlommel at pandora.be
Tue Jul 22 16:33:10 CEST 2008
Revision: 15690
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15690
Author: blendix
Date: 2008-07-22 16:33:10 +0200 (Tue, 22 Jul 2008)
Log Message:
-----------
Apricot Branch: GLSL
====================
Added support for some world settings, updated docs.
* Ambient color
* Exposure/Range
* Mist (implementation should be optimized)
http://www.blender.org/development/current-projects/changes-since-246/realtime-glsl-materials/
Modified Paths:
--------------
branches/apricot/source/blender/gpu/GPU_draw.h
branches/apricot/source/blender/gpu/intern/gpu_material.c
branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl
branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl.c
branches/apricot/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
Modified: branches/apricot/source/blender/gpu/GPU_draw.h
===================================================================
--- branches/apricot/source/blender/gpu/GPU_draw.h 2008-07-22 12:02:57 UTC (rev 15689)
+++ branches/apricot/source/blender/gpu/GPU_draw.h 2008-07-22 14:33:10 UTC (rev 15690)
@@ -46,7 +46,11 @@
* shared with the game engine, where there were previously
* duplicates of some of these functions. */
-/* Initialize */
+/* Initialize
+ * - sets the default Blender opengl state, if in doubt, check
+ * the contents of this function
+ * - this is called when starting Blender, for opengl rendering,
+ * and for switching back from the game engine for example. */
void GPU_state_init(void);
@@ -94,7 +98,8 @@
void GPU_set_linear_mipmap(int linear);
void GPU_paint_set_mipmap(int mipmap);
-/* Image opengl free and update */
+/* Image updates and free
+ * - these deal with images bound as opengl textures */
void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h);
void GPU_update_images_framechange(void);
Modified: branches/apricot/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_material.c 2008-07-22 12:02:57 UTC (rev 15689)
+++ branches/apricot/source/blender/gpu/intern/gpu_material.c 2008-07-22 14:33:10 UTC (rev 15690)
@@ -42,6 +42,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "DNA_view3d_types.h"
+#include "DNA_world_types.h"
#include "BKE_colortools.h"
#include "BKE_DerivedMesh.h"
@@ -1000,9 +1001,11 @@
void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
{
+ GPUMaterial *mat= shi->gpumat;
+ GPUNodeLink *emit, *ulinfac, *ulogfac, *mistfac;
Material *ma= shi->mat;
- GPUMaterial *mat= shi->gpumat;
- GPUNodeLink *emit;
+ World *world= mat->scene->world;
+ float linfac, logfac, misttype;
memset(shr, 0, sizeof(*shr));
@@ -1037,6 +1040,29 @@
shr->combined = shr->diff;
shr->alpha = shi->alpha;
+ if(world) {
+ /* exposure correction */
+ if(world->exp!=0.0f || world->range!=1.0f) {
+ linfac= 1.0 + pow((2.0*world->exp + 0.5), -10);
+ logfac= log((linfac-1.0)/linfac)/world->range;
+
+ GPU_link(mat, "set_value", GPU_uniform(&linfac), &ulinfac);
+ GPU_link(mat, "set_value", GPU_uniform(&logfac), &ulogfac);
+
+ GPU_link(mat, "shade_exposure_correct", shr->combined,
+ ulinfac, ulogfac, &shr->combined);
+ GPU_link(mat, "shade_exposure_correct", shr->spec,
+ ulinfac, ulogfac, &shr->spec);
+ }
+
+ /* ambient color */
+ if(world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) {
+ if(GPU_link_changed(shi->amb) || ma->amb != 0.0f)
+ GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb),
+ GPU_uniform(&world->ambr), &shr->combined);
+ }
+ }
+
if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec);
@@ -1044,6 +1070,17 @@
GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined);
}
+ if(world && (world->mode & WO_MIST) && !(ma->mode & MA_NOMIST)) {
+ misttype = world->mistype;
+
+ GPU_link(mat, "shade_mist_factor", GPU_builtin(GPU_VIEW_POSITION),
+ GPU_uniform(&world->miststa), GPU_uniform(&world->mistdist),
+ GPU_uniform(&misttype), GPU_uniform(&world->misi), &mistfac);
+
+ GPU_link(mat, "mix_blend", mistfac, GPU_uniform(&world->horr),
+ shr->combined, &shr->combined);
+ }
+
GPU_link(mat, "mtex_alpha_to_col", shr->combined, shr->alpha, &shr->combined);
}
Modified: branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl 2008-07-22 12:02:57 UTC (rev 15689)
+++ branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl 2008-07-22 14:33:10 UTC (rev 15690)
@@ -1458,6 +1458,11 @@
outcol = col + col1*col2;
}
+void shade_maddf(vec4 col, float f, vec4 col1, out vec4 outcol)
+{
+ outcol = col + f*col1;
+}
+
void shade_mul(vec4 col1, vec4 col2, out vec4 outcol)
{
outcol = col1*col2;
@@ -1496,3 +1501,22 @@
}
}
+void shade_exposure_correct(vec3 col, float linfac, float logfac, out vec3 outcol)
+{
+ outcol = linfac*(1.0 - exp(col*logfac));
+}
+
+void shade_mist_factor(vec3 co, float miststa, float mistdist, float misttype, float misi, out float outfac)
+{
+ float fac, zcor;
+
+ zcor = (gl_ProjectionMatrix[3][3] == 0.0)? length(co): -co[2];
+
+ fac = clamp((zcor-miststa)/mistdist, 0.0, 1.0);
+ if(misttype == 0.0) fac *= fac;
+ else if(misttype == 1.0);
+ else fac = sqrt(fac);
+
+ outfac = (1.0-fac)*(1.0-misi);
+}
+
Modified: branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl.c 2008-07-22 12:02:57 UTC (rev 15689)
+++ branches/apricot/source/blender/gpu/intern/gpu_shader_material.glsl.c 2008-07-22 14:33:10 UTC (rev 15690)
@@ -1,993 +1,1012 @@
/* DataToC output of file <gpu_shader_material_glsl> */
-int datatoc_gpu_shader_material_glsl_size= 31581;
+int datatoc_gpu_shader_material_glsl_size= 32168;
char datatoc_gpu_shader_material_glsl[]= {
- 10,102,108,111, 97,116, 32,101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,102, 41, 10,123,
- 10, 9,114,101,116,117,114,110, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50, 56, 52, 54, 44, 32,102, 41, 59, 10,
-125, 10, 10,118,111,105,100, 32,114,103, 98, 95,116,111, 95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116,
- 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32, 99,109, 97,120, 44, 32, 99,109,105,
-110, 44, 32,104, 44, 32,115, 44, 32,118, 44, 32, 99,100,101,108,116, 97, 59, 10, 9,118,101, 99, 51, 32, 99, 59, 10, 10, 9, 99,
-109, 97,120, 32, 61, 32,109, 97,120, 40,114,103, 98, 91, 48, 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93, 44, 32,114,103,
- 98, 91, 50, 93, 41, 41, 59, 10, 9, 99,109,105,110, 32, 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, 32,109,105,110, 40,
-114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 10, 9, 99,100,101,108,116, 97, 32, 61, 32, 99,109, 97,120,
- 45, 99,109,105,110, 59, 10, 10, 9,118, 32, 61, 32, 99,109, 97,120, 59, 10, 9,105,102, 32, 40, 99,109, 97,120, 33, 61, 48, 46,
- 48, 41, 10, 9, 9,115, 32, 61, 32, 99,100,101,108,116, 97, 47, 99,109, 97,120, 59, 10, 9,101,108,115,101, 32,123, 10, 9, 9,
-115, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 10, 9,105,102, 32, 40,115, 32, 61,
- 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9,
- 9, 99, 32, 61, 32, 40,118,101, 99, 51, 40, 99,109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41, 32, 45, 32,114,
-103, 98, 46,120,121,122, 41, 47, 99,100,101,108,116, 97, 59, 10, 10, 9, 9,105,102, 32, 40,114,103, 98, 46,120, 61, 61, 99,109,
- 97,120, 41, 32,104, 32, 61, 32, 99, 91, 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,
-114,103, 98, 46,121, 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32, 45, 32, 32, 99,
- 91, 50, 93, 59, 10, 9, 9,101,108,115,101, 32,104, 32, 61, 32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45, 32, 99, 91, 48,
- 93, 59, 10, 10, 9, 9,104, 32, 47, 61, 32, 54, 46, 48, 59, 10, 10, 9, 9,105,102, 32, 40,104, 60, 48, 46, 48, 41, 10, 9, 9,
- 9,104, 32, 43, 61, 32, 49, 46, 48, 59, 10, 9,125, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,104, 44,
- 32,115, 44, 32,118, 44, 32,114,103, 98, 46,119, 41, 59, 10,125, 10, 10,118,111,105,100, 32,104,115,118, 95,116,111, 95,114,103,
- 98, 40,118,101, 99, 52, 32,104,115,118, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,
-102,108,111, 97,116, 32,105, 44, 32,102, 44, 32,112, 44, 32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32,118, 59, 10, 9,118,
-101, 99, 51, 32,114,103, 98, 59, 10, 10, 9,104, 32, 61, 32,104,115,118, 91, 48, 93, 59, 10, 9,115, 32, 61, 32,104,115,118, 91,
- 49, 93, 59, 10, 9,118, 32, 61, 32,104,115,118, 91, 50, 93, 59, 10, 10, 9,105,102, 40,115, 61, 61, 48, 46, 48, 41, 32,123, 10,
- 9, 9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,118, 44, 32,118, 41, 59, 10, 9,125, 10, 9,101,108,115,101, 32,
-123, 10, 9, 9,105,102, 40,104, 61, 61, 49, 46, 48, 41, 10, 9, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9, 10, 9, 9,
-104, 32, 42, 61, 32, 54, 46, 48, 59, 10, 9, 9,105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 10, 9, 9,102, 32, 61, 32,
-104, 32, 45, 32,105, 59, 10, 9, 9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41, 59, 10, 9, 9,
-112, 32, 61, 32,118, 42, 40, 49, 46, 48, 45,115, 41, 59, 10, 9, 9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42,102,
- 41, 41, 59, 10, 9, 9,116, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42, 40, 49, 46, 48, 45,102, 41, 41, 41, 59, 10, 9,
- 9, 10, 9, 9,105,102, 32, 40,105, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,
-116, 44, 32,112, 41, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 49, 46, 48, 41, 32,114,103, 98, 32,
- 61, 32,118,101, 99, 51, 40,113, 44, 32,118, 44, 32,112, 41, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61,
- 32, 50, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,118, 44, 32,116, 41, 59, 10, 9, 9,101,108,115,
-101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 51, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,113, 44,
- 32,118, 41, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 52, 46, 48, 41, 32,114,103, 98, 32, 61, 32,
-118,101, 99, 51, 40,116, 44, 32,112, 44, 32,118, 41, 59, 10, 9, 9,101,108,115,101, 32,114,103, 98, 32, 61, 32,118,101, 99, 51,
- 40,118, 44, 32,112, 44, 32,113, 41, 59, 10, 9,125, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,114,103,
- 98, 44, 32,104,115,118, 46,119, 41, 59, 10,125, 10, 10, 35,100,101,102,105,110,101, 32, 77, 95, 80, 73, 32, 51, 46, 49, 52, 49,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list