Mark Sibly 8 роки тому
батько
коміт
eee16fddda

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

@@ -66,7 +66,12 @@ Public
 | TextureFlags	| Description
 |:--------------|:-----------
 | Dynamic		| Texture is frequently updated. This flag should be set if the texture contents are regularly updated and don't need to be preserved.
-
+| WrapS			| Wrap S texture coordinates
+| WrapT			| Wrap T texture coordinates
+| Filter		| Enable magnification filtering
+| Mipmap		| Enable minification mipmapping, and minification filtering if Filter enabled.
+| WrapST		| Enable WrapS and WrapT.
+| FilterMipmap	| Enable Filter and Mipmap.
 #end
 Enum TextureFlags
 	None=			$0000
@@ -82,6 +87,8 @@ Enum TextureFlags
 	FilterMipmap=	Filter|Mipmap
 End
 
+#rem monketdoc @hidden
+#end
 Enum CubeFace
 	PositiveX
 	NegativeX
@@ -91,6 +98,8 @@ Enum CubeFace
 	NegativeZ
 End
 
+#Rem monkeydoc The Texture class.
+#end
 Class Texture Extends Resource
 	
 	Private
@@ -428,7 +437,7 @@ Class Texture Extends Resource
 					glTexParameteri( _glTarget,GL_TEXTURE_MIN_FILTER,GL_NEAREST )
 				Endif
 				
-				If _flags & TextureFlags.FilterMipmap
+				If _flags & TextureFlags.Mipmap And Not (_flags & TextureFlags.Cubemap)
 					If glexts.GL_texture_filter_anisotropic
 						Local max:Int=0
 						glGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY,Varptr max )

+ 6 - 4
modules/mojo/graphics/uniformblock.monkey2

@@ -15,8 +15,9 @@ Class UniformBlock Extends Resource
 	Method New( uniforms:UniformBlock )
 	
 		_name=uniforms._name
-		
 		_linearColors=uniforms._linearColors
+		_defaultTexture=uniforms._defaultTexture
+		_ntextures=uniforms._ntextures
 		
 		For Local i:=0 Until _uniforms.Length
 			_uniforms[i]=uniforms._uniforms[i]
@@ -298,11 +299,12 @@ Class UniformBlock Extends Resource
 	End
 
 	Field _name:Int
-	Field _seq:Int
 	Field _linearColors:bool
-	Field _uniforms:=New Uniform[64]
-	Field _ntextures:Int
 	Field _defaultTexture:Texture
+	Field _ntextures:Int
+
+	Field _uniforms:=New Uniform[64]
+	Field _seq:Int
 	
 	Method SetData<T>( uniform:String,data:T,type:Type )
 		Local id:=GetUniformId( uniform )

+ 0 - 11
modules/mojo3d-physics/physics/native/objecthandle.h

@@ -1,11 +0,0 @@
-
-#ifndef BB_OBJECT_HANDLE_H
-#define BB_OBJECT_HANDLE_H
-
-#include <bbmonkey.h>
-
-inline void *bb_object_to_handle( bbObject *object ){ return object; }
-
-inline bbObject *bb_handle_to_object( void *handle ){ return static_cast<bbObject*>( handle ); }
-
-#endif

+ 3 - 13
modules/mojo3d-physics/physics/world.monkey2

@@ -1,16 +1,6 @@
 
 Namespace mojo3d.physics
 
-#Import "native/objecthandle.h"
-
-Extern
-
-Function object_to_handle:Void Ptr( obj:Object )="bb_object_to_handle"
-
-Function handle_to_object:Object( handle:Void Ptr )="bb_handle_to_object"
-
-Public
-
 Class Scene Extension
 
 	Property World:World()
@@ -37,7 +27,7 @@ Class RaycastResult
 	
 	Method New( btresult:btCollisionWorld.ClosestRayResultCallback Ptr )
 		time=btresult->m_closestHitFraction
-		body=Cast<RigidBody>( handle_to_object( btresult->m_collisionObject.getUserPointer() ) )
+		body=Cast<RigidBody>( btresult->m_collisionObject.getUserPointer() )
 		point=btresult->m_hitPointWorld
 		normal=btresult->m_hitNormalWorld
 	End
@@ -48,7 +38,7 @@ Class RaycastResult
 		Local castTo:=Cast<Vec3f>( btresult->m_convexToWorld )
 		
 		time=btresult->m_closestHitFraction
-		body=Cast<RigidBody>( handle_to_object( btresult->m_hitCollisionObject.getUserPointer() ) )
+		body=Cast<RigidBody>( btresult->m_hitCollisionObject.getUserPointer() )
 		point=(castTo-castFrom) * btresult->m_closestHitFraction + castFrom
 		normal=btresult->m_hitNormalWorld
 	End
@@ -140,7 +130,7 @@ Class World
 		
 		_btworld.addRigidBody( body.btBody,body.CollisionGroup,body.CollisionMask )
 		
-		body.btBody.setUserPointer( object_to_handle( body ) )
+		body.btBody.setUserPointer( Cast<Void Ptr>( body ) )
 	End
 	
 	Method Remove( body:RigidBody )

+ 2 - 1
modules/mojo3d-physics/tests/fpsthing.monkey2

@@ -148,7 +148,8 @@ Class MyWindow Extends Window
 		'
 		_light=New Light
 		_light.Rotate( 60,60,0 )	'aim directional light 'down' - Pi/2=90 degrees.
-		'_light.ShadowsEnabled=False
+		
+		_light.CastsShadow=True
 		
 		'Load castle
 		'

+ 1 - 1
modules/mojo3d/graphics/pbrmaterial.monkey2

@@ -227,7 +227,7 @@ Class PbrMaterial Extends Material
 	
 	Method OnValidateShader:Shader() Override
 		
-		_textured=False
+		_textured=True'False
 		_bumpmapped=False
 		
 		If Uniforms.NumTextures

+ 1 - 2
modules/mojo3d/graphics/renderer.monkey2

@@ -118,7 +118,6 @@ Class Renderer
 		_renderScene=scene
 
 		_runiforms.SetTexture( "SkyTexture",_renderScene.SkyTexture )
-		
 		_runiforms.SetColor( "ClearColor",_renderScene.ClearColor )
 		_runiforms.SetColor( "AmbientDiffuse",_renderScene.AmbientLight )
 	
@@ -133,7 +132,7 @@ Class Renderer
 		Endif
 		
 		_runiforms.SetTexture( "EnvTexture",env )
-		
+		_runiforms.SetFloat( "EnvTextureMaxLod",Log2( env.Size.x ) )
 		_runiforms.SetColor( "EnvColor",_renderScene.EnvColor )
 		
 		_renderQueue.Clear()

+ 2 - 0
modules/mojo3d/graphics/scene.monkey2

@@ -12,6 +12,8 @@ Class Scene Extends DynamicObject
 		_clearColor=Color.Sky
 
 		_ambientDiffuse=Color.DarkGrey
+		
+		_envColor=Color.White
 	End
 	
 	#rem monkeydoc The sky texture.

+ 3 - 2
modules/mojo3d/graphics/shaders/material-pbr-deferred.glsl

@@ -25,6 +25,7 @@ uniform mat3 i_ModelViewNormalMatrix;
 
 uniform vec4 r_AmbientDiffuse;
 uniform samplerCube r_EnvTexture;
+uniform float r_EnvTextureMaxLod;
 uniform vec4 r_EnvColor;
 uniform mat3 r_EnvMatrix;
 
@@ -192,11 +193,11 @@ void pbrWriteFragData( vec3 color,vec3 emissive,float metalness,float roughness,
 	
 	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
 	
-	float lod=textureCube( r_EnvTexture,rvec,10.0 ).a * 255.0 - 10.0;
+	float lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
 	
 	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
 	
-	vec3 env=pow( textureCube( r_EnvTexture,rvec,max( roughness*10.0-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
+	vec3 env=pow( textureCube( r_EnvTexture,rvec,max( roughness*r_EnvTextureMaxLod-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
 
 	vec3 vvec=normalize( -v_Position );
 	

+ 4 - 2
modules/mojo3d/graphics/shaders/material-pbr-forward.glsl

@@ -38,6 +38,7 @@ uniform mat3 m_TextureMatrix;
 //
 uniform vec4 r_AmbientDiffuse;
 uniform samplerCube r_EnvTexture;
+uniform float r_EnvTextureMaxLod;
 uniform vec4 r_EnvColor;
 uniform mat3 r_EnvMatrix;
 
@@ -280,10 +281,11 @@ vec3 fragColor( vec3 color,vec3 emissive,float metalness,float roughness,float o
 	
 	//ambient color
 	
+	
 	vec3 rvec=r_EnvMatrix * reflect( v_Position,normal );
-	float lod=textureCube( r_EnvTexture,rvec,10.0 ).a * 255.0 - 10.0;
+	float lod=textureCube( r_EnvTexture,rvec,r_EnvTextureMaxLod ).a * 255.0 - r_EnvTextureMaxLod;
 	if( lod>0.0 ) lod=textureCube( r_EnvTexture,rvec ).a * 255.0;
-	vec3 ambenv=pow( textureCube( r_EnvTexture,rvec,max( roughness*10.0-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
+	vec3 ambenv=pow( textureCube( r_EnvTexture,rvec,max( roughness*r_EnvTextureMaxLod-lod,0.0 ) ).rgb,vec3( 2.2 ) ) * r_EnvColor.rgb;
 	
 	float ndotv=max( dot( normal,vvec ),0.0 );
 

+ 3 - 2
modules/mojo3d/tests/anisotropic.monkey2

@@ -13,7 +13,7 @@ Using std..
 Using mojo..
 Using mojo3d..
 
-Const MaxAnisotropy:=0			'set to 0 to use use HW default (usually 16) 1 to for lowest.
+Const MaxAnisotropy:=0			'set to 0 to use use HW max (usually 16) 1 for min/off.
 
 Class MyWindow Extends Window
 	
@@ -34,6 +34,7 @@ Class MyWindow Extends Window
 		'create scene
 		'		
 		_scene=Scene.GetCurrent()
+		
 		_scene.EnvColor=Color.Black
 		_scene.ClearColor=Color.Black
 		_scene.AmbientLight=Color.Black
@@ -62,7 +63,7 @@ Class MyWindow Extends Window
 		
 		'create material
 		'
-		Local material:=New PbrMaterial( Color.Black,0,1 )
+		Local material:=New PbrMaterial( Color.Black )
 		material.EmissiveTexture=texture
 		material.EmissiveFactor=Color.Red
 

+ 2 - 4
modules/mojo3d/tests/ducks.monkey2

@@ -33,8 +33,6 @@ Class MyWindow Extends Window
 
 		Super.New( title,width,height,flags )
 		
-		SwapInterval=0
-		
 		Print gles20.glGetString( gles20.GL_EXTENSIONS ).Replace( " ","~n" )
 		
 		'create scene
@@ -120,7 +118,7 @@ Class MyWindow Extends Window
 
 		RequestRender()
 		
-		_ducks[0].RotateY( 1 )
+		'_ducks[0].RotateY( 1 )
 
 		util.Fly( _camera,Self )
 		
@@ -142,7 +140,7 @@ Function Main()
 '	config["mojo3d_renderer"]="forward-direct"	'default on mobile targets. depth buffer must be enabled too.
 '	config["GL_depth_buffer_enabled"]=1
 
-'	config["mojo3d_renderer"]="forward"
+	config["mojo3d_renderer"]="forward"
 		
 	New AppInstance( config )