[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15244] branches/apricot/source: Apricot Branch

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jun 16 18:58:14 CEST 2008


Revision: 15244
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15244
Author:   blendix
Date:     2008-06-16 18:58:12 +0200 (Mon, 16 Jun 2008)

Log Message:
-----------
Apricot Branch
==============

Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.

The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.

For uses: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.

* The game engine now also uses GLEW for extensions, replacing the
  custom opengl extensions code that was there. This means also that
  all extensions will now always be compiled in, regardless of the
  glext.h on the platform where compilation happens. Removes a lot
  of #ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
  work around a specific bug and only disabled multitexturing anyway.
  It might also have caused a slowdown since it was retrieving the
  environment variable for every vertex in immediate mode (bug #13680).

* Refactored the code to allow drawing skinned meshes with vertex
  arrays too, removing some specific immediate mode drawing functions
  for this that only did extra normal calculation. Now it always splits
  vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
  required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
  attributes for vertex arrays. These were not being enabled/disabled
  correct according to the opengl spec, leading to crashes. Also tangent
  attributes used an immediate mode call for vertex arrays, which can't
  work.
* Fixed use of uninitialized variable in RAS_TexVert.

* Also in the GLSL shaders, removed conditional returns since some
  graphics cards don't support this. And fix a bug with orco's not
  being created in textured mode.

Modified Paths:
--------------
    branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c
    branches/apricot/source/blender/gpu/intern/gpu_material.c
    branches/apricot/source/blender/gpu/intern/material_shaders.glsl
    branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c
    branches/apricot/source/blender/include/BIF_gl.h
    branches/apricot/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
    branches/apricot/source/gameengine/BlenderRoutines/CMakeLists.txt
    branches/apricot/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
    branches/apricot/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
    branches/apricot/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
    branches/apricot/source/gameengine/BlenderRoutines/Makefile
    branches/apricot/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    branches/apricot/source/gameengine/Converter/BL_MeshDeformer.cpp
    branches/apricot/source/gameengine/Converter/BL_MeshDeformer.h
    branches/apricot/source/gameengine/Converter/BL_SkinDeformer.cpp
    branches/apricot/source/gameengine/Converter/BL_SkinMeshObject.cpp
    branches/apricot/source/gameengine/Converter/CMakeLists.txt
    branches/apricot/source/gameengine/Converter/Makefile
    branches/apricot/source/gameengine/GamePlayer/common/CMakeLists.txt
    branches/apricot/source/gameengine/GamePlayer/common/GPC_Canvas.h
    branches/apricot/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
    branches/apricot/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
    branches/apricot/source/gameengine/GamePlayer/common/GPC_RenderTools.h
    branches/apricot/source/gameengine/GamePlayer/common/Makefile
    branches/apricot/source/gameengine/GamePlayer/common/SConscript
    branches/apricot/source/gameengine/GamePlayer/ghost/CMakeLists.txt
    branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
    branches/apricot/source/gameengine/GamePlayer/ghost/Makefile
    branches/apricot/source/gameengine/GamePlayer/ghost/SConscript
    branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.cpp
    branches/apricot/source/gameengine/Ketsji/BL_BlenderShader.h
    branches/apricot/source/gameengine/Ketsji/BL_Shader.cpp
    branches/apricot/source/gameengine/Ketsji/BL_Texture.cpp
    branches/apricot/source/gameengine/Ketsji/CMakeLists.txt
    branches/apricot/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
    branches/apricot/source/gameengine/Ketsji/KX_PythonInit.cpp
    branches/apricot/source/gameengine/Ketsji/Makefile
    branches/apricot/source/gameengine/Ketsji/SConscript
    branches/apricot/source/gameengine/Rasterizer/CMakeLists.txt
    branches/apricot/source/gameengine/Rasterizer/Makefile
    branches/apricot/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
    branches/apricot/source/gameengine/Rasterizer/RAS_IRasterizer.h
    branches/apricot/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_MeshObject.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript

Removed Paths:
-------------
    branches/apricot/source/gameengine/BlenderRoutines/mac_compat_glext.h
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h
    branches/apricot/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py

Modified: branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c	2008-06-16 16:48:09 UTC (rev 15243)
+++ branches/apricot/source/blender/blenkernel/intern/DerivedMesh.c	2008-06-16 16:58:12 UTC (rev 15244)
@@ -1990,6 +1990,11 @@
 			}
 			if((view->drawtype == OB_TEXTURE) || ((view->drawtype == OB_SOLID) && (view->flag2 & V3D_SOLID_TEX))) {
 				mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
+
+				if((G.fileflags & G_FILE_GAME_MAT) &&
+				   (G.fileflags & G_FILE_GAME_MAT_GLSL)) {
+					mask |= CD_MASK_ORCO;
+				}
 			}
 		}
 	}

Modified: branches/apricot/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/gpu_material.c	2008-06-16 16:48:09 UTC (rev 15243)
+++ branches/apricot/source/blender/gpu/intern/gpu_material.c	2008-06-16 16:58:12 UTC (rev 15244)
@@ -116,7 +116,7 @@
 	for(a=0, b=0; a<attribs->totlayer; a++) {
 		sprintf(name, "att%d", attribs->layer[a].glindex);
 		attribs->layer[a].glindex = GPU_shader_get_attribute(shader, name);
-		
+
 		if(attribs->layer[a].glindex >= 0) {
 			attribs->layer[b] = attribs->layer[a];
 			b++;

Modified: branches/apricot/source/blender/gpu/intern/material_shaders.glsl
===================================================================
--- branches/apricot/source/blender/gpu/intern/material_shaders.glsl	2008-06-16 16:48:09 UTC (rev 15243)
+++ branches/apricot/source/blender/gpu/intern/material_shaders.glsl	2008-06-16 16:58:12 UTC (rev 15244)
@@ -699,12 +699,12 @@
 
 	if(dot(vec, lampvec) < 0.0) {
 		inp = 0.0;
-		return;
 	}
+	else {
+		float intens = area_lamp_energy(area, co, vn);
 
-	float intens = area_lamp_energy(area, co, vn);
-
-	inp = pow(intens*areasize, k);
+		inp = pow(intens*areasize, k);
+	}
 }
 
 void shade_diffuse_oren_nayer(float nl, vec3 n, vec3 l, vec3 v, float rough, out float is)
@@ -714,34 +714,39 @@
 	float nv = max(dot(n, v), 0.0);
 	float realnl = dot(n, l);
 
-	if(realnl < 0.0) { is = 0.0; return; }
-	if(nl < 0.0) { is = 0.0; return; }
+	if(realnl < 0.0) {
+		is = 0.0;
+	}
+	else if(nl < 0.0) {
+		is = 0.0;
+	}
+	else {
+		float vh = max(dot(v, h), 0.0);
+		float Lit_A = acos(realnl);
+		float View_A = acos(nv);
 
-	float vh = max(dot(v, h), 0.0);
-	float Lit_A = acos(realnl);
-	float View_A = acos(nv);
+		vec3 Lit_B = normalize(l - realnl*n);
+		vec3 View_B = normalize(v - nv*n);
 
-	vec3 Lit_B = normalize(l - realnl*n);
-	vec3 View_B = normalize(v - nv*n);
+		float t = max(dot(Lit_B, View_B), 0.0);
 
-	float t = max(dot(Lit_B, View_B), 0.0);
+		float a, b;
 
-	float a, b;
+		if(Lit_A > View_A) {
+			a = Lit_A;
+			b = View_A;
+		}
+		else {
+			a = View_A;
+			b = Lit_A;
+		}
 
-	if(Lit_A > View_A) {
-		a = Lit_A;
-		b = View_A;
+		float A = 1.0 - (0.5*((rough*rough)/((rough*rough) + 0.33)));
+		float B = 0.45*((rough*rough)/((rough*rough) + 0.09));
+
+		b *= 0.95;
+		is = nl*(A + (B * t * sin(a) * tan(b)));
 	}
-	else {
-		a = View_A;
-		b = Lit_A;
-	}
-
-	float A = 1.0 - (0.5*((rough*rough)/((rough*rough) + 0.33)));
-	float B = 0.45*((rough*rough)/((rough*rough) + 0.09));
-
-	b *= 0.95;
-	is = nl*(A + (B * t * sin(a) * tan(b)));
 }
 
 void shade_diffuse_toon(vec3 n, vec3 l, vec3 v, float size, float tsmooth, out float is)
@@ -758,32 +763,38 @@
 {
 	if(nl <= 0.0) {
 		is = 0.0;
-		return;
 	}
+	else {
+		float nv = max(dot(n, v), 0.0);
 
-	float nv = max(dot(n, v), 0.0);
-
-	if(darkness <= 1.0)
-		is = nl*pow(max(nv*nl, 0.1), darkness - 1.0);
-	else
-		is = nl*pow(1.0001 - nv, darkness - 1.0);
+		if(darkness <= 1.0)
+			is = nl*pow(max(nv*nl, 0.1), darkness - 1.0);
+		else
+			is = nl*pow(1.0001 - nv, darkness - 1.0);
+	}
 }
 
 float fresnel_fac(vec3 view, vec3 vn, float grad, float fac)
 {
 	float t1, t2;
+	float ffac;
 
-	if(fac==0.0) return 1.0;
+	if(fac==0.0) {
+		ffac = 1.0;
+	}
+	else {
+		t1= dot(view, vn);
+		if(t1>0.0)  t2= 1.0+t1;
+		else t2= 1.0-t1;
 
-	t1= dot(view, vn);
-	if(t1>0.0)  t2= 1.0+t1;
-	else t2= 1.0-t1;
+		t2= grad + (1.0-grad)*pow(t2, fac);
 
-	t2= grad + (1.0-grad)*pow(t2, fac);
+		if(t2<0.0) ffac = 0.0;
+		else if(t2>1.0) ffac = 1.0;
+		else ffac = t2;
+	}
 
-	if(t2<0.0) return 0.0;
-	else if(t2>1.0) return 1.0;
-	return t2;
+	return ffac;
 }
 
 void shade_diffuse_fresnel(vec3 vn, vec3 lv, vec3 view, float fac_i, float fac, out float is)
@@ -849,51 +860,62 @@
 
 	if(nh < 0.0) {
 		specfac = 0.0;
-		return;
 	}
+	else {
+		float nv = max(dot(n, v), 0.0);
+		float i = pow(nh, hard);
 
-	float nv = max(dot(n, v), 0.0);
-	float i = pow(nh, hard);
-
-	i = i/(0.1+nv);
-	specfac = i;
+		i = i/(0.1+nv);
+		specfac = i;
+	}
 }
 
 void shade_blinn_spec(vec3 n, vec3 l, vec3 v, float refrac, float spec_power, out float specfac)
 {
-	if(refrac < 1.0) { specfac = 0.0; return; }
-	if(spec_power == 0.0) { specfac = 0.0; return; }
+	if(refrac < 1.0) {
+		specfac = 0.0;
+	}
+	else if(spec_power == 0.0) {
+		specfac = 0.0;
+	}
+	else {
+		if(spec_power<100.0)
+			spec_power= sqrt(1.0/spec_power);
+		else
+			spec_power= 10.0/spec_power;
 
-	if(spec_power<100.0)
-		spec_power= sqrt(1.0/spec_power);
-	else
-		spec_power= 10.0/spec_power;
+		vec3 h = normalize(v + l);
+		float nh = dot(n, h);
+		if(nh < 0.0) {
+			specfac = 0.0;
+		}
+		else {
+			float nv = max(dot(n, v), 0.01);
+			float nl = dot(n, l);
+			if(nl <= 0.01) {
+				specfac = 0.0;
+			}
+			else {
+				float vh = max(dot(v, h), 0.01);
 
-	vec3 h = normalize(v + l);
-	float nh = dot(n, h);
-	if(nh < 0.0) { specfac = 0.0; return; }
+				float a = 1.0;
+				float b = (2.0*nh*nv)/vh;
+				float c = (2.0*nh*nl)/vh;
 
-	float nv = max(dot(n, v), 0.01);
-	float nl = dot(n, l);
-	if(nl <= 0.01) { specfac = 0.0; return; }
+				float g;
 
-	float vh = max(dot(v, h), 0.01);
+				if(a < b && a < c) g = a;
+				else if(b < a && b < c) g = b;
+				else if(c < a && c < b) g = c;
 
-	float a = 1.0;
-	float b = (2.0*nh*nv)/vh;
-	float c = (2.0*nh*nl)/vh;
+				float p = sqrt(((refrac * refrac)+(vh*vh)-1.0));
+				float f = (((p-vh)*(p-vh))/((p+vh)*(p+vh)))*(1.0+((((vh*(p+vh))-1.0)*((vh*(p+vh))-1.0))/(((vh*(p-vh))+1.0)*((vh*(p-vh))+1.0))));
+				float ang = acos(nh);
 
-	float g;
-
-	if(a < b && a < c) g = a;
-	else if(b < a && b < c) g = b;
-	else if(c < a && c < b) g = c;
-
-	float p = sqrt(((refrac * refrac)+(vh*vh)-1.0));
-	float f = (((p-vh)*(p-vh))/((p+vh)*(p+vh)))*(1.0+((((vh*(p+vh))-1.0)*((vh*(p+vh))-1.0))/(((vh*(p-vh))+1.0)*((vh*(p-vh))+1.0))));
-	float ang = acos(nh);
-
-	specfac = max(f*g*exp((-(ang*ang)/(2.0*spec_power*spec_power))), 0.0);
+				specfac = max(f*g*exp((-(ang*ang)/(2.0*spec_power*spec_power))), 0.0);
+			}
+		}
+	}
 }
 
 void shade_wardiso_spec(vec3 n, vec3 l, vec3 v, float rms, out float specfac)

Modified: branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c
===================================================================
--- branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c	2008-06-16 16:48:09 UTC (rev 15243)
+++ branches/apricot/source/blender/gpu/intern/material_shaders.glsl.c	2008-06-16 16:58:12 UTC (rev 15244)
@@ -1,592 +1,597 @@
 /* DataToC output of file <material_shaders_glsl> */
 
-int datatoc_material_shaders_glsl_size= 20694;
+int datatoc_material_shaders_glsl_size= 20862;
 char datatoc_material_shaders_glsl[]= {
- 10,118, 97,114,121,105,110,103, 32,118,101, 99, 51, 32,118, 97,114, 99,111, 59, 10,118,
- 97,114,121,105,110,103, 32,118,101, 99, 51, 32,118, 97,114, 99, 97,109, 99,111, 59, 10,118, 97,114,121,105,110,103, 32,118,101,
- 99, 51, 32,118, 97,114,110,111,114,109, 97,108, 59, 10,117,110,105,102,111,114,109, 32,109, 97,116, 52, 32,117,110,102,111, 98,
-109, 97,116, 59, 10,117,110,105,102,111,114,109, 32,109, 97,116, 52, 32,117,110,102,118,105,101,119,109, 97,116, 59, 10, 10, 47,
- 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 83, 72, 65, 68, 69, 82, 32, 78, 79, 68, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42,
- 42, 42, 42, 42, 42, 42, 42, 42, 47, 10, 10, 35,100,101,102,105,110,101, 32, 77, 95, 80, 73, 32, 51, 46, 49, 52, 49, 53, 57, 50,
- 54, 53, 51, 53, 56, 57, 55, 57, 51, 50, 51, 56, 52, 54, 10, 10,118,111,105,100, 32,103,101,111,109, 40,118,101, 99, 51, 32, 97,
-116,116,111,114, 99,111, 44, 32,118,101, 99, 50, 32, 97,116,116,117,118, 44, 32,118,101, 99, 52, 32, 97,116,116,118, 99,111,108,
- 44, 32,111,117,116, 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,108,111, 99, 97,
-108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 44,
- 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,
-117,116, 32,118,101, 99, 52, 32,118, 99,111,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102,114,111,110,116, 98, 97, 99,
-107, 41, 10,123, 10,  9,108,111, 99, 97,108, 32, 61, 32,118, 97,114, 99, 97,109, 99,111, 59, 10,  9,118,105,101,119, 32, 61, 32,
-110,111,114,109, 97,108,105,122,101, 40,108,111, 99, 97,108, 41, 59, 10,  9,111,114, 99,111, 32, 61, 32, 97,116,116,111,114, 99,
-111, 59, 10,  9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, 45, 32,118,101, 99, 50, 40, 49,
- 46, 48, 44, 32, 49, 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 10,  9,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,
-108,105,122,101, 40,118, 97,114,110,111,114,109, 97,108, 41, 59,  9, 47, 42, 32, 98,108,101,110,100,101,114, 32,114,101,110,100,
-101,114, 32,110,111,114,109, 97,108, 32,105,115, 32,110,101,103, 97,116,101,100, 32, 42, 47, 10,  9,118, 99,111,108, 32, 61, 32,
-118,101, 99, 52, 40, 97,116,116,118, 99,111,108, 46,119, 47, 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,122, 47,
- 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,121, 47, 50, 53, 53, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10,  9,102,
-114,111,110,116, 98, 97, 99,107, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,112,112,105,110,103, 40,
-118,101, 99, 51, 32,118,101, 99, 44, 32,109, 97,116, 52, 32,109, 97,116, 44, 32,118,101, 99, 51, 32,109,105,110,118,101, 99, 44,
- 32,118,101, 99, 51, 32,109, 97,120,118,101, 99, 44, 32,102,108,111, 97,116, 32,100,111,109,105,110, 44, 32,102,108,111, 97,116,
- 32,100,111,109, 97,120, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, 10,  9,111,117,116,118,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list