Browse Source

Fixed bump alpha issue.

Mark Sibly 9 years ago
parent
commit
a255fb8d1d

+ 1 - 1
modules/mojo/graphics/canvas.monkey2

@@ -1134,7 +1134,7 @@ Class Canvas
 		_device.Clear( Color.Black )
 			
 		_device.RenderTarget=_gbuffers[1]
-		_device.Clear( Color.Black )
+		_device.Clear( New Color( .5,.5,1 ) )
 		
 		_device.RenderTarget=_rtarget ? _rtarget.Texture Else Null
 	End

+ 5 - 4
modules/mojo/graphics/shaders/bump.glsl

@@ -22,7 +22,9 @@ void main(){
 
 	texCoord0=mx2_TexCoord0;
 
+#if MX2_RENDERPASS==2
 	tanMatrix=mat2( mx2_TexCoord1.x,mx2_TexCoord1.y,-mx2_TexCoord1.y,mx2_TexCoord1.x );
+#endif
 
 #if MX2_RENDERPASS==0
 	color=mx2_AmbientLight * mx2_ImageColor * mx2_Color;
@@ -55,10 +57,9 @@ void main(){
 
 	vec3 normal=texture2D( mx2_ImageTexture1,texCoord0 ).xyz;
 	
-	normal.xy=tanMatrix * (normal.xy * 2.0 - 1.0) * diffuse.a * 0.5 + 0.5;
-	normal.z*=diffuse.a;
-	
-	gl_FragColor=vec4( normal,diffuse.a );
+	normal.xy=tanMatrix * (normal.xy * 2.0 - 1.0) * 0.5 + 0.5;
+
+	gl_FragColor=vec4( normal*diffuse.a,diffuse.a );
 
 #endif
 

+ 2 - 2
modules/mojo/graphics/texture.monkey2

@@ -152,7 +152,7 @@ Class Texture Extends Resource
 		path=RealPath( path )
 		specular=specular ? RealPath( specular ) Else ""
 
-		Local pnorm:=Pixmap.Load( path,,True )
+		Local pnorm:=Pixmap.Load( path,,False )
 		If Not pnorm Return Null
 		
 		Local pspec:=Pixmap.Load( specular )
@@ -164,7 +164,7 @@ Class Texture Extends Resource
 				For Local x:=0 Until pnorm.Width
 					Local n:=pnorm.GetPixelARGB( x,y ) ~ yxor
 					Local s:=(pspec.GetPixelARGB( x,y ) Shr 16) & $ff
-					n=n & $ffffff00 | Clamp( Int( specularScale * s ),1,255 )
+					n=n & $ffffff00 | Clamp( Int( specularScale * s ),0,255 )
 					pnorm.SetPixelARGB( x,y,n )
 				Next
 			Next