[sldev-commits] r1067 - in branches/shadow-draft-2: doc indra/llrender indra/newview indra/newview/app_settings/shaders/class1/deferred

soft.linden at svn.secondlife.com soft.linden at svn.secondlife.com
Fri Aug 22 09:11:41 PDT 2008


Author: soft.linden
Date: 2008-08-22 11:11:40 -0500 (Fri, 22 Aug 2008)
New Revision: 1067

Modified:
   branches/shadow-draft-2/doc/asset_urls.txt
   branches/shadow-draft-2/indra/llrender/llimagegl.cpp
   branches/shadow-draft-2/indra/llrender/llimagegl.h
   branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
   branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
   branches/shadow-draft-2/indra/newview/lldrawpool.h
   branches/shadow-draft-2/indra/newview/lldrawpoolalpha.cpp
   branches/shadow-draft-2/indra/newview/lldrawpoolalpha.h
   branches/shadow-draft-2/indra/newview/lldrawpoolsimple.cpp
   branches/shadow-draft-2/indra/newview/llvovolume.cpp
Trac: http://svn.secondlife.com/trac/linden/changeset/1067
Log:
Snapshot of internal branch shadow-draft-2
Last Changed Rev: 94931
Last Changed Date: 2008-08-22 04:34:55 -0700 (Fri, 22 Aug 2008)

Supplementary files:
http://secondlife.com/developers/opensource/downloads/2008/08/md5sums-shadow-draft-2-r94931.txt
http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-artwork-shadow-draft-2-r94931.zip
http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-darwin-libs-shadow-draft-2-r94931.tar.gz
http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-win32-libs-shadow-draft-2-r94931.zip
http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-linux-libs-shadow-draft-2-r94931.tar.gz

Source tarballs - redundant to this svn:
http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-src-shadow-draft-2-r94931.tar.gz
http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-src-shadow-draft-2-r94931.zip


Modified: branches/shadow-draft-2/doc/asset_urls.txt
===================================================================
--- branches/shadow-draft-2/doc/asset_urls.txt	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/doc/asset_urls.txt	2008-08-22 16:11:40 UTC (rev 1067)
@@ -1,8 +1,8 @@
 # For building instructions:
 # https://wiki.secondlife.com/wiki/Get_source_and_compile
 
-SLASSET_MD5=http://secondlife.com/developers/opensource/downloads/2008/08/md5sums-shadow-draft-2-r94570.txt
-SLASSET_ART=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-artwork-shadow-draft-2-r94570.zip
-SLASSET_LIBS_DARWIN=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-darwin-libs-shadow-draft-2-r94570.tar.gz
-SLASSET_LIBS_WIN32=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-win32-libs-shadow-draft-2-r94570.zip
-SLASSET_LIBS_LINUXI386=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-linux-libs-shadow-draft-2-r94570.tar.gz
+SLASSET_MD5=http://secondlife.com/developers/opensource/downloads/2008/08/md5sums-shadow-draft-2-r94931.txt
+SLASSET_ART=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-artwork-shadow-draft-2-r94931.zip
+SLASSET_LIBS_DARWIN=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-darwin-libs-shadow-draft-2-r94931.tar.gz
+SLASSET_LIBS_WIN32=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-win32-libs-shadow-draft-2-r94931.zip
+SLASSET_LIBS_LINUXI386=http://secondlife.com/developers/opensource/downloads/2008/08/slviewer-linux-libs-shadow-draft-2-r94931.tar.gz

Modified: branches/shadow-draft-2/indra/llrender/llimagegl.cpp
===================================================================
--- branches/shadow-draft-2/indra/llrender/llimagegl.cpp	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/llrender/llimagegl.cpp	2008-08-22 16:11:40 UTC (rev 1067)
@@ -321,6 +321,7 @@
 	mFormatType = GL_UNSIGNED_BYTE;
 	mFormatSwapBytes = FALSE;
 	mHasExplicitFormat = FALSE;
+	mIsMask = FALSE;
 }
 
 void LLImageGL::cleanup()
@@ -569,7 +570,11 @@
 					}
 						
 					glTexImage2D(mTarget, gl_level, mFormatInternal, w, h, 0, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in);
-					
+					if (gl_level == 0)
+					{
+						analyzeAlpha(data_in, w, h);
+					}
+
 					if(mFormatSwapBytes)
 					{
 						glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
@@ -596,10 +601,13 @@
 						stop_glerror();
 					}
 
+					S32 w = getWidth(mCurrentDiscardLevel);
+					S32 h = getHeight(mCurrentDiscardLevel);
 					glTexImage2D(mTarget, 0, mFormatInternal,
-								 getWidth(mCurrentDiscardLevel), getHeight(mCurrentDiscardLevel), 0,
+								 w, h, 0,
 								 mFormatPrimary, mFormatType,
 								 data_in);
+					analyzeAlpha(data_in, w, h);
 					stop_glerror();
 
 					if(mFormatSwapBytes)
@@ -650,6 +658,10 @@
 						}
 
 						glTexImage2D(mTarget, m, mFormatInternal, w, h, 0, mFormatPrimary, mFormatType, cur_mip_data);
+						if (m == 0)
+						{
+							analyzeAlpha(data_in, w, h);
+						}
 						stop_glerror();
 
 						if(mFormatSwapBytes)
@@ -701,6 +713,8 @@
 
 			glTexImage2D(mTarget, 0, mFormatInternal, w, h, 0,
 						 mFormatPrimary, mFormatType, (GLvoid *)data_in);
+			analyzeAlpha(data_in, w, h);
+			
 			stop_glerror();
 
 			if(mFormatSwapBytes)
@@ -1343,6 +1357,63 @@
 	mBindTarget = bind_target;
 }
 
+void LLImageGL::analyzeAlpha(const void* data_in, S32 w, S32 h)
+{
+	if (mFormatType != GL_UNSIGNED_BYTE)
+	{
+		llwarns << "Cannot analye alpha for image with format type " << std::hex << mFormatType << llendl;
+	}
+
+	U32 stride = 0;
+	switch (mFormatPrimary)
+	{
+	case GL_LUMINANCE:
+	case GL_ALPHA:
+		stride = 1;
+		break;
+	case GL_LUMINANCE_ALPHA:
+		stride = 2;
+		break;
+	case GL_RGB:
+		//no alpha
+		mIsMask = FALSE;
+		return;
+	case GL_RGBA:
+		stride = 4;
+		break;
+	default:
+		llwarns << "Cannot analyze alpha of image with primary format " << std::hex << mFormatPrimary << llendl;
+		return;
+	}
+
+	U32 length = w * h;
+	const GLubyte* current = ((const GLubyte*) data_in)+stride-1;
+	
+	S32 sample[16];
+	memset(sample, 0, sizeof(S32)*16);
+
+	for (U32 i = 0; i < length; i++)
+	{
+		++sample[*current/16];
+		current += stride;
+	}
+
+	U32 total = 0;
+	for (U32 i = 4; i < 11; i++)
+	{
+		total += sample[i];
+	}
+
+	if (total > length/16)
+	{
+		mIsMask = FALSE;
+	}
+	else
+	{
+		mIsMask = TRUE;
+	}
+}
+
 //----------------------------------------------------------------------------
 
 // Manual Mip Generation

Modified: branches/shadow-draft-2/indra/llrender/llimagegl.h
===================================================================
--- branches/shadow-draft-2/indra/llrender/llimagegl.h	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/llrender/llimagegl.h	2008-08-22 16:11:40 UTC (rev 1067)
@@ -85,6 +85,8 @@
 	void glClamp (BOOL clamps, BOOL clampt);
 	void glClampCubemap (BOOL clamps, BOOL clampt, BOOL clampr = FALSE);
 
+	void analyzeAlpha(const void* data_in, S32 w, S32 h);
+
 public:
 	virtual void dump();	// debugging info to llinfos
 	virtual BOOL bind(const S32 stage = 0) const;
@@ -130,6 +132,8 @@
 	BOOL getHasGLTexture() const { return mTexName != 0; }
 	LLGLuint getTexName() const { return mTexName; }
 
+	BOOL getIsAlphaMask() const { return mIsMask; }
+
 	BOOL getIsResident(BOOL test_now = FALSE); // not const
 
 	void setTarget(const LLGLenum target, const LLGLenum bind_target);
@@ -156,6 +160,8 @@
 	S8 mHasMipMaps;
 	S8 mHasExplicitFormat; // If false (default), GL format is f(mComponents)
 	S8 mAutoGenMips;
+
+	BOOL mIsMask;
 	
 protected:
 	LLGLenum mTarget;		// Normally GL_TEXTURE2D, sometimes something else (ex. cube maps)

Modified: branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
===================================================================
--- branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl	2008-08-22 16:11:40 UTC (rev 1067)
@@ -69,13 +69,13 @@
 			sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
 			col += da*sa*light_col[i].rgb*spec.rgb;
 		}
-	
-		//attenuate point light contribution by SSAO component
-		col *= texture2DRect(lightMap, frag.xy).g;
 		
 		out_col += col;	
 	}
 	
+	//attenuate point light contribution by SSAO component
+	out_col *= texture2DRect(lightMap, frag.xy).g;
+	
 	gl_FragColor.rgb = out_col;
 	gl_FragColor.a = 0.0;
 }

Modified: branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
===================================================================
--- branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl	2008-08-22 16:11:40 UTC (rev 1067)
@@ -36,7 +36,6 @@
 	}
 	
 	vec3 norm = texture2DRect(normalMap, frag).xyz;
-	vec4 spec = texture2DRect(specularMap, frag);
 	float da = dot(norm, lv);
 	if (da < 0.0)
 	{
@@ -56,6 +55,7 @@
 	
 	col = gl_Color.rgb*lit*col;
 
+	vec4 spec = texture2DRect(specularMap, frag);
 	if (spec.a > 0.0)
 	{
 		vec3 ref = reflect(normalize(pos), norm);

Modified: branches/shadow-draft-2/indra/newview/lldrawpool.h
===================================================================
--- branches/shadow-draft-2/indra/newview/lldrawpool.h	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/newview/lldrawpool.h	2008-08-22 16:11:40 UTC (rev 1067)
@@ -52,10 +52,8 @@
 	{
 		// Correspond to LLPipeline render type
 		POOL_SIMPLE = 1,
-		POOL_FULLBRIGHT,
 		POOL_TERRAIN,	
 		POOL_BUMP,
-		POOL_GRASS,
 		POOL_TREE,
 		POOL_SKY,
 		POOL_WL_SKY,
@@ -63,6 +61,8 @@
 		POOL_INVISIBLE,
 		POOL_AVATAR,
 		POOL_WATER,
+		POOL_GRASS,
+		POOL_FULLBRIGHT,
 		POOL_GLOW,
 		POOL_ALPHA,
 		NUM_POOL_TYPES,
@@ -129,6 +129,8 @@
 		PASS_BUMP,
 		PASS_GLOW,
 		PASS_ALPHA,
+		PASS_ALPHA_MASK,
+		PASS_FULLBRIGHT_ALPHA_MASK,
 		PASS_ALPHA_SHADOW,
 		NUM_RENDER_TYPES,
 	};

Modified: branches/shadow-draft-2/indra/newview/lldrawpoolalpha.cpp
===================================================================
--- branches/shadow-draft-2/indra/newview/lldrawpoolalpha.cpp	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/newview/lldrawpoolalpha.cpp	2008-08-22 16:11:40 UTC (rev 1067)
@@ -75,6 +75,35 @@
 	mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
 }
 
+S32 LLDrawPoolAlpha::getNumDeferredPasses()
+{
+	return 1;
+}
+
+void LLDrawPoolAlpha::beginDeferredPass(S32 pass)
+{
+	
+}
+
+void LLDrawPoolAlpha::endDeferredPass(S32 pass)
+{
+	gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.4f);
+	{
+		LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS);
+		gDeferredTreeProgram.bind();
+		LLGLEnable test(GL_ALPHA_TEST);
+		//render alpha masked objects
+		LLRenderPass::renderTexture(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask());
+	}			
+	gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
+}
+
+void LLDrawPoolAlpha::renderDeferred(S32 pass)
+{
+	
+}
+
+
 S32 LLDrawPoolAlpha::getNumPostDeferredPasses() 
 { 
 	return 1; 
@@ -149,10 +178,34 @@
 {
 	LLFastTimer t(LLFastTimer::FTM_RENDER_ALPHA);
 
+	LLGLSPipelineAlpha gls_pipeline_alpha;
+
+	if (LLPipeline::sFastAlpha)
+	{
+		gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f);
+		if (mVertexShaderLevel > 0)
+		{
+			if (!LLPipeline::sRenderDeferred)
+			{
+				simple_shader->bind();
+				pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask());
+			}
+			fullbright_shader->bind();
+			pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask());
+			LLGLSLShader::bindNoShader();
+		}
+		else
+		{
+			gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
+			pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask());
+			gPipeline.enableLightsDynamic();
+			pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask());
+		}
+		gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
+
+	}
+
 	LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE);
-
-	LLGLSPipelineAlpha gls_pipeline_alpha;
-	
 	renderAlpha(getVertexDataMask());
 
 	if (sShowDebugAlpha)

Modified: branches/shadow-draft-2/indra/newview/lldrawpoolalpha.h
===================================================================
--- branches/shadow-draft-2/indra/newview/lldrawpoolalpha.h	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/newview/lldrawpoolalpha.h	2008-08-22 16:11:40 UTC (rev 1067)
@@ -54,6 +54,11 @@
 	LLDrawPoolAlpha(U32 type = LLDrawPool::POOL_ALPHA);
 	/*virtual*/ ~LLDrawPoolAlpha();
 
+	/*virtual*/ S32 getNumDeferredPasses();
+	/*virtual*/ void beginDeferredPass(S32 pass);
+	/*virtual*/ void endDeferredPass(S32 pass);
+	/*virtual*/ void renderDeferred(S32 pass);
+
 	/*virtual*/ S32 getNumPostDeferredPasses();
 	/*virtual*/ void beginPostDeferredPass(S32 pass);
 	/*virtual*/ void endPostDeferredPass(S32 pass);

Modified: branches/shadow-draft-2/indra/newview/lldrawpoolsimple.cpp
===================================================================
--- branches/shadow-draft-2/indra/newview/lldrawpoolsimple.cpp	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/newview/lldrawpoolsimple.cpp	2008-08-22 16:11:40 UTC (rev 1067)
@@ -238,7 +238,6 @@
 	{
 		LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS);
 		LLGLEnable test(GL_ALPHA_TEST);
-		LLGLEnable blend(GL_BLEND);
 		gGL.setSceneBlendType(LLRender::BT_ALPHA);
 		//render grass
 		LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask());
@@ -322,12 +321,15 @@
 		gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
 	}
 	
-	gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f);
+	//gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.25f);
 	
+	//LLGLEnable test(GL_ALPHA_TEST);
+	//LLGLEnable blend(GL_BLEND);
+	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 	U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_COLOR;
 	renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask);
 
-	gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
+	//gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
 }
 
 S32 LLDrawPoolFullbright::getNumPasses()

Modified: branches/shadow-draft-2/indra/newview/llvovolume.cpp
===================================================================
--- branches/shadow-draft-2/indra/newview/llvovolume.cpp	2008-08-22 15:53:10 UTC (rev 1066)
+++ branches/shadow-draft-2/indra/newview/llvovolume.cpp	2008-08-22 16:11:40 UTC (rev 1067)
@@ -466,7 +466,7 @@
 
 		F32 old_size = face->getVirtualSize();
 
-		if (face->getPoolType() == LLDrawPool::POOL_ALPHA)
+		/*if (face->getPoolType() == LLDrawPool::POOL_ALPHA)
 		{
 			
 			if (LLPipeline::sFastAlpha &&
@@ -475,7 +475,7 @@
 			{
 				gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_COLOR, FALSE);
 			}
-		}
+		}*/
 
 		if (face->mTextureMatrix != NULL)
 		{
@@ -2461,10 +2461,26 @@
 
 			BOOL is_alpha = facep->getPoolType() == LLDrawPool::POOL_ALPHA ? TRUE : FALSE;
 
+			
 		
 			if (is_alpha)
 			{
-				registerFace(group, facep, LLRenderPass::PASS_ALPHA);
+				if (LLPipeline::sFastAlpha && facep->getTexture()->getIsAlphaMask())
+				{
+					if (te->getFullbright())
+					{
+						registerFace(group, facep, LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK);
+					}
+					else
+					{
+						registerFace(group, facep, LLRenderPass::PASS_ALPHA_MASK);
+					}
+				}
+				else
+				{
+					registerFace(group, facep, LLRenderPass::PASS_ALPHA);
+				}
+
 				if (LLPipeline::sRenderDeferred)
 				{
 					registerFace(group, facep, LLRenderPass::PASS_ALPHA_SHADOW);



More information about the sldev-commits mailing list