Gorilla.Material.Default
Unit Gorilla.Material.Default.pasClasses
- TGorillaDefaultMaterial = class ( TCustomMaterial )
- TGorillaDefaultMaterialSource = class ( TMaterialSource )
Records
- record TGorillaShaderPassData
- record TGorillaShaderData
Enumerations
- enum TGorillaShadingModel = ( Lambert, Phong, BlinnPhong ) ;
Constants
Mics. types
- type PGorillaShaderData = pointer to TGorillaShaderData;
TGorillaShaderPassData
Fields
- public Geometry0ViewMatrix :
TMatrix3D
- public Geometry1ViewMatrix :
TMatrix3D
- public Geometry2ViewMatrix :
TMatrix3D
- public Geometry3ViewMatrix :
TMatrix3D
- public Geometry4ViewMatrix :
TMatrix3D
- public Geometry5ViewMatrix :
TMatrix3D
- public ShadowMapMatrix :
- public ReflectTextureMatrix :
TMatrix3D
- public RefractTextureMatrix :
TMatrix3D
- public ReflectionPower :
Single
- public RefractionPower :
Single
TGorillaShaderData
Fields
- public ModelMatrix :
TMatrix3D
- public ModelViewProjectionMatrix :
TMatrix3D
- public ModelNormalMatrix :
TMatrix3D
- public ViewMatrix :
TMatrix3D
- public ProjectionMatrix :
TMatrix3D
- public TimeInfo :
TVector3D
- public EyePos :
TVector3D
- public ViewDir :
TPoint3D
- public ShadingModel :
Integer
- public Material :
- public Lights :
- public LightsCount :
Integer
- public Options :
Integer
- public FogMode :
Integer
- public FogDensity :
Single
- public FogStart :
Single
- public FogEnd :
Single
- public Reserved0 :
- public FogColor :
TAlphaColorF
- public FrustumMin :
TVector3D
- public FrustumMax :
TVector3D
- public SceneMin :
TVector3D
- public SceneMax :
TVector3D
- public BoundaryMin :
TVector3D
- public BoundaryMax :
TVector3D
- public ViewSize :
TVector3D
- public ClippingPlane :
TVector3D
- public PassData :
Methods
TGorillaDefaultMaterial
Defining a default basic material sourcce allowing to with render lambert / phong / blinnphong shading on basis of a diffuse color texture.
Remarks
The default material renders up to 8 lights of point / directional / spot light type depending on platform and GLES version used.
On Windows platform + OpenGLES v3 (10.3+) the forward renderer can take up to 8 lights.
On Windows platform + OpenGLES v2 (10.1 - 10.2) the forward renderer can take up to 4 lights.
On Android platform + OpenGLES v2 | v3 the forward renderer can take up to 4 lights.
On iOS platform + OpenGLES v2 | v3 the forward renderer can take up to 4 lights.
On MacOS platform + OpenGLES v3 (10.3+) the forward renderer can take up to 8 lights.
On MacOS platform + OpenGLES v2 (10.1 - 10.2) the forward renderer can take up to 4 lights.
Ancestors
Members
Fields
- protected FUniforms :
TBufferObject
- protected FSource :
TGorillaDefaultMaterialSource
- protected FShaderData :
TGorillaShaderData
- protected FUseRefractionDepth :
Boolean
- protected FVSNode :
TGorillaGLSLVertexShader
- protected FVSShaderSource :
TContextShaderSource
- protected FVSVarIndex :
Integer
- protected FFSNode :
TGorillaGLSLFragmentShader
- protected FFSShaderSource :
TContextShaderSource
- protected FFSVarIndex :
Integer
- protected FUpdateShaderProgram :
Boolean
- protected FAllowTexture0 :
Boolean
- protected FAllowNormalMapTexture :
Boolean
- protected FAllowDisplacementMapTexture :
Boolean
- protected FAllowDepthTexture :
Boolean
- protected FAllowReflectionTexture :
Boolean
- protected FAllowRefractionTexture :
Boolean
- protected FAllowGeometryTexture :
Boolean
- protected FAllowShadowMapTexture :
Boolean
- protected FUniformsLinked :
Boolean
- protected FTimerService :
IFMXTimerService
- protected FMeasureTime :
Boolean
- protected FTextures :
TGorillaTexturePool
- protected FShadows :
Boolean
- protected FShadowMethod :
TGorillaShadowMethod
- protected FReflections :
Boolean
- protected FRefractions :
Boolean
- protected FDepthTexture :
TTexture
- protected FReflectionTexture :
TTexture
- protected FRefractionTexture :
TTexture
- protected FGeometryTexture :
:TGorillaDefaultMaterial.:1
Methods
- public constructor Create ( const ASource : TGorillaDefaultMaterialSource ) ;
- public destructor Destroy ( ) ;
- protected procedure InitializeUniformsBuffer
(
)
;
class;
We need to setup the global uniform buffer once.
- protected procedure FinalizeUniformsBuffer ( ) ; class;
- protected function GetShadingModel ( ) : TGorillaShadingModel ; virtual;
- protected procedure SetShadingModel ( const AValue : TGorillaShadingModel ) ; virtual;
- protected function GetStartTime ( ) : Double ; virtual;
- protected function GetRenderTime ( ) : Double ; virtual;
- protected function GetLastTime ( ) : Double ; virtual;
- protected function GetEmissive ( ) : TAlphaColorF ; virtual;
- protected procedure SetEmissive ( AValue : TAlphaColorF ) ; virtual;
- protected function GetDiffuse ( ) : TAlphaColorF ; virtual;
- protected procedure SetDiffuse ( AValue : TAlphaColorF ) ; virtual;
- protected function GetAmbient ( ) : TAlphaColorF ; virtual;
- protected procedure SetAmbient ( AValue : TAlphaColorF ) ; virtual;
- protected function GetSpecular ( ) : TAlphaColorF ; virtual;
- protected procedure SetSpecular ( AValue : TAlphaColorF ) ; virtual;
- protected function GetShininess ( ) : Single ; virtual;
- protected procedure SetShininess ( const AValue : Single ) ; virtual;
- protected function GetClippingColor ( ) : TAlphaColorF ; virtual;
- protected procedure SetClippingColor ( const AValue : TAlphaColorF ) ; virtual;
- protected function GetUseLighting ( ) : Boolean ; virtual;
- protected procedure SetUseLighting ( const AValue : Boolean ) ; virtual;
- protected function GetUseTexturing ( ) : Boolean ; virtual;
- protected procedure SetUseTexturing ( const AValue : Boolean ) ; virtual;
- protected function GetUseTexture0 ( ) : Boolean ; virtual;
- protected procedure SetUseTexture0 ( const AValue : Boolean ) ; virtual;
- protected function GetUseVertexColor ( ) : Boolean ; virtual;
- protected procedure SetUseVertexColor ( const AValue : Boolean ) ; virtual;
- protected function GetUseColorClipping ( ) : Boolean ; virtual;
- protected procedure SetUseColorClipping ( const AValue : Boolean ) ; virtual;
- protected function GetNearLimit ( ) : Single ; virtual;
- protected procedure SetNearLimit ( const AValue : Single ) ; virtual;
- protected function GetFarLimit ( ) : Single ; virtual;
- protected procedure SetFarLimit ( const AValue : Single ) ; virtual;
- protected procedure SetShadows ( const AValue : Boolean ) ; virtual;
- protected procedure SetShadowMethod ( const AValue : TGorillaShadowMethod ) ; virtual;
- protected procedure SetReflections ( const AValue : Boolean ) ; virtual;
- protected procedure SetRefractions ( const AValue : Boolean ) ; virtual;
- protected procedure SetDepthTexture ( const AValue : TTexture ) ; virtual;
- protected procedure SetReflectionTexture ( const AValue : TTexture ) ; virtual;
- protected procedure SetRefractionTexture ( const AValue : TTexture ) ; virtual;
- protected function GetGeometryTexture ( AIndex : TGorillaGeometryCubeSide ) : TTexture ; virtual;
- protected procedure SetGeometryTexture ( AIndex : TGorillaGeometryCubeSide; const AValue : TTexture ) ; virtual;
- protected function GetReflectionPower ( ) : Single ; virtual;
- protected procedure SetReflectionPower ( const AValue : Single ) ; virtual;
- protected function GetRefractionPower ( ) : Single ; virtual;
- protected procedure SetRefractionPower ( const AValue : Single ) ; virtual;
- protected procedure DoApplyMaterial ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyLights ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyShadow ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyReflection ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyRefraction ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyRaytracingShadow ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyMatrices ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyTime ( const Context : TContext3D ) ; virtual;
- protected procedure DoApplyFog ( const Context : TContext3D ) ; virtual;
- protected procedure DoApply ( const Context : TContext3D ) ; override;
- protected function DoGetTextureShaderVariables
(
const
AShaderKind :
TContextShaderKind; var
AVarIndex :
Integer
)
: TArray<FMX.Types3D.TContextShaderVariable>
;
virtual;
Returns an array of shader variables for all textures. The method will automatically handle separation of PoolTextures[]-Array and single textures.
- protected procedure RemoveShaderProgram ( ) ; virtual;
- protected procedure DoUpdateShaderProgram
(
)
;
virtual;
Calls RemoveShaderProgram() to destroy an already created shader. Afterwards it will setup again the vertex- and fragmentshader.
- protected procedure DoCreateVertexShader
(
)
;
virtual;
Creates the vertex shader node builder.
- protected procedure DoSetupVertexShader
(
)
;
virtual;
Builds the vertex shader source code.
- protected procedure DoUpdateVertexShader ( ) ; virtual;
- protected procedure DoCreateFragmentShader
(
)
;
virtual;
Creates the fragment shader node builder.
- protected procedure DoSetupFragmentShader
(
)
;
virtual;
Builds the fragment shader source code.
- protected procedure DoUpdateFragmentShader ( ) ; virtual;
- protected procedure DoCheckDefaultTextureFlags
(
)
;
virtual;
Checks shader source definitions and updates the allowed bitmap flags.
- protected procedure DoCreateTexturePool
(
)
;
virtual;
Creates the TGorillaTexturePool instance.
- protected procedure DoGetTexturesFromBitmapPool
(
const
APool :
TGorillaBitmapPool
)
;
virtual;
Reads all texture bitmaps from material source and fills the texture pool.
- protected procedure DoInitialize ( ) ; override;
- protected procedure DoChange ( ) ; override;
- public function FindTexturePoolEntryByName
(
const
AName :
string
)
: TGorillaTexturePoolEntry
;
virtual;
Returns a texture pool entry if it can be found by its name, otherwise the method returns nil.
- class private procedure Create@ ( ) ; class constructor noself;
- class private procedure Destroy@ ( ) ; class destructor noself;
Properties
- public VertexShaderNode : TGorillaGLSLVertexShader
- public FragmentShaderNode : TGorillaGLSLFragmentShader
- public MeasureTime : Boolean
Get or Activate/Deactivate time measurement. Some shaders may need time information between render cycles to render properly.
read FMeasureTime
write FMeasureTime - public StartTime : Double
- public RenderTime : Double
- public LastTime : Double
- public ShadingModel : TGorillaShadingModel
Get or set the used shading model. You can choose between Lambert, Phong or Blinnphong shading algorithm.
read GetShadingModel
write SetShadingModel - public Emissive : TAlphaColorF
- public Diffuse : TAlphaColorF
- public Ambient : TAlphaColorF
- public Specular : TAlphaColorF
- public Shininess : Single
- public ClippingColor : TAlphaColorF
Get or set clipping color. If UseColorClipping is enabled, RGB is used as color to be clipped and A is used as tolerance.
read GetClippingColor
write SetClippingColor - public UseLighting : Boolean
Enable or disable lighting shading model computation in shader.
read GetUseLighting
write SetUseLighting - public UseTexturing : Boolean
Enable or disable general texturing functionality. _Texture0 will not directly be used
read GetUseTexturing
write SetUseTexturing - public UseTexture0 : Boolean
Enable or disable general texturing functionality and _Texture0 variable.
read GetUseTexture0
write SetUseTexture0 - public UseVertexColor : Boolean
Enable or disable to use color rendering (on texture or not).
read GetUseVertexColor
write SetUseVertexColor - public UseColorClipping : Boolean
- public NearLimit : Single
- public FarLimit : Single
Defines the camera frustum far limit value. This value is used by raytracing shadow computation and can be changed to increase performance. The value should not be higher than 1000.0 otherwise raytracing performance will increase a lot.
read GetFarLimit
write SetFarLimit - public Shadows : Boolean
- public ShadowMethod : TGorillaShadowMethod
Get or set the used shadow method in shader. This property only has effect if "Shadows" is set to true.
read FShadowMethod
write SetShadowMethod - public DepthTexture : TTexture
A depth texture for shadow computation inside of default shader.
read FDepthTexture
write SetDepthTexture - public GeometryTexture[Index] : TTexture
A texture map of all visible vertex positions generated by a separated render pass.
read GetGeometryTexture
write SetGeometryTexture - public Reflections : Boolean
Activates / Deactivates the reflection computation of default shader.
read FReflections
write SetReflections - public ReflectionTexture : TTexture
A reflection texture computed by a render pass. The reflection render pass needs to be applied to the parent material source.
read FReflectionTexture
write SetReflectionTexture - public Refractions : Boolean
Activates / Deactivates the refraction computation of default shader.
read FRefractions
write SetRefractions - public RefractionTexture : TTexture
A refraction texture computed by a render pass. The refraction render pass needs to be applied to the parent material source.
read FRefractionTexture
write SetRefractionTexture - public ReflectionPower : Single
Defines the factor of mixing reflection with the basically computed color.
read GetReflectionPower
write SetReflectionPower - public RefractionPower : Single
Defines the factor of mixing refraction with the basically computed color.
read GetRefractionPower
write SetRefractionPower
TGorillaDefaultMaterialSource
Defining a default basic material sourcce allowing to with render lambert / phong / blinnphong shading on basis of a diffuse color texture.
Remarks
Use this material source as basis for further complex material renderer.The default material renders up to 8 lights of point / directional / spot light type depending on platform and GLES version used.
On Windows platform + OpenGLES v3 (10.3+) the forward renderer can take up to 8 lights.
On Windows platform + OpenGLES v2 (10.1 - 10.2) the forward renderer can take up to 4 lights.
On Android platform + OpenGLES v2 | v3 the forward renderer can take up to 4 lights.
On iOS platform + OpenGLES v2 | v3 the forward renderer can take up to 4 lights.
On MacOS platform + OpenGLES v3 (10.3+) the forward renderer can take up to 8 lights.
On MacOS platform + OpenGLES v2 (10.1 - 10.2) the forward renderer can take up to 4 lights.
Ancestors
Members
Fields
- protected FContextResetOvrId :
Integer
- protected FBitmaps :
TGorillaBitmapPool
- protected FTexture0 :
TGorillaBitmapPoolEntry
- protected FNormalMapTexture :
TGorillaBitmapPoolEntry
- protected FDisplacementMapTexture :
TGorillaBitmapPoolEntry
- protected FInputs :
TGorillaInputRenderPassMap
- protected FDepthTexture :
TGorillaBitmapPoolEntry
- protected FReflectionTexture :
TGorillaBitmapPoolEntry
- protected FRefractionTexture :
TGorillaBitmapPoolEntry
- protected FGeometryTexture :
:TGorillaDefaultMaterialSource.:1
- protected FShadowMapTexture :
:TGorillaDefaultMaterialSource.:2
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected function GetEmissive ( ) : TAlphaColorF ; virtual;
- protected procedure SetEmissive ( const AValue : TAlphaColorF ) ; virtual;
- protected function GetAmbient ( ) : TAlphaColorF ; virtual;
- protected procedure SetAmbient ( const AValue : TAlphaColorF ) ; virtual;
- protected function GetDiffuse ( ) : TAlphaColorF ; virtual;
- protected procedure SetDiffuse ( const AValue : TAlphaColorF ) ; virtual;
- protected function GetSpecular ( ) : TAlphaColorF ; virtual;
- protected procedure SetSpecular ( const AValue : TAlphaColorF ) ; virtual;
- protected function GetShininess ( ) : Single ; virtual;
- protected procedure SetShininess ( const AValue : Single ) ; virtual;
- protected function GetClippingColor ( ) : TAlphaColorF ; virtual;
- protected procedure SetClippingColor ( const AValue : TAlphaColorF ) ; virtual;
- protected function GetUseLighting ( ) : Boolean ; virtual;
- protected procedure SetUseLighting ( const AValue : Boolean ) ; virtual;
- protected function GetUseTexturing ( ) : Boolean ; virtual;
- protected procedure SetUseTexturing ( const AValue : Boolean ) ; virtual;
- protected function GetUseTexture0 ( ) : Boolean ; virtual;
- protected procedure SetUseTexture0 ( const AValue : Boolean ) ; virtual;
- protected function GetUseVertexColor ( ) : Boolean ; virtual;
- protected procedure SetUseVertexColor ( const AValue : Boolean ) ; virtual;
- protected function GetUseColorClipping ( ) : Boolean ; virtual;
- protected procedure SetUseColorClipping ( const AValue : Boolean ) ; virtual;
- protected function GetNearLimit ( ) : Single ; virtual;
- protected procedure SetNearLimit ( const AValue : Single ) ; virtual;
- protected function GetFarLimit ( ) : Single ; virtual;
- protected procedure SetFarLimit ( const AValue : Single ) ; virtual;
- protected function GetTextureTiling ( AIndex : Integer ) : TPointF ; virtual;
- protected procedure SetTextureTiling ( AIndex : Integer; const AValue : TPointF ) ; virtual;
- protected function GetTexture0 ( ) : TBitmap ; virtual;
- protected procedure SetTexture0 ( const AValue : TBitmap ) ; virtual;
- protected function GetNormalMap ( ) : TBitmap ; virtual;
- protected procedure SetNormalMap ( const AValue : TBitmap ) ; virtual;
- protected function GetDisplacementMap ( ) : TBitmap ; virtual;
- protected procedure SetDisplacementMap ( const AValue : TBitmap ) ; virtual;
- protected function GetDisplacement ( ) : TVector3D ; virtual;
- protected procedure SetDisplacement ( const AValue : TVector3D ) ; virtual;
- protected function GetShadingModel ( ) : TGorillaShadingModel ; virtual;
- protected procedure SetShadingModel ( const AValue : TGorillaShadingModel ) ; virtual;
- protected function GetDepthPass ( ) : TGorillaRenderPassController ; virtual;
- protected procedure SetDepthPass ( const AValue : TGorillaRenderPassController ) ; virtual;
- protected function GetGeometryPass ( ) : TGorillaRenderPassController ; virtual;
- protected procedure SetGeometryPass ( const AValue : TGorillaRenderPassController ) ; virtual;
- protected function GetReflectionPower ( ) : Single ; virtual;
- protected procedure SetReflectionPower ( const AValue : Single ) ; virtual;
- protected function GetRefractionPower ( ) : Single ; virtual;
- protected procedure SetRefractionPower ( const AValue : Single ) ; virtual;
- protected function GetReflectionPass ( ) : TGorillaRenderPassController ; virtual;
- protected procedure SetReflectionPass ( const AValue : TGorillaRenderPassController ) ; virtual;
- protected function GetRefractionPass ( ) : TGorillaRenderPassController ; virtual;
- protected procedure SetRefractionPass ( const AValue : TGorillaRenderPassController ) ; virtual;
- protected function GetShadows ( ) : Boolean ; virtual;
- protected procedure SetShadows ( const AValue : Boolean ) ; virtual;
- protected function GetShadowMethod ( ) : TGorillaShadowMethod ;
- protected procedure SetShadowMethod ( const AValue : TGorillaShadowMethod ) ; virtual;
- protected function GetReflections ( ) : Boolean ; virtual;
- protected procedure SetReflections ( const AValue : Boolean ) ; virtual;
- protected function GetRefractions ( ) : Boolean ; virtual;
- protected procedure SetRefractions ( const AValue : Boolean ) ; virtual;
- protected function GetShadowMapPass ( AIndex : Byte ) : TGorillaRenderPassController ; virtual;
- protected procedure SetShadowMapPass ( AIndex : Byte; AValue : TGorillaRenderPassController ) ; virtual;
- protected procedure Loaded
(
)
;
override;
Setup some basic settings after the material source was loaded from fmx-file.
- protected function CreateMaterial
(
)
: TMaterial
;
override;
Create the default material instance and apply material source settings.
- protected procedure ContextResetHandlerOverride
(
const
Sender :
TObject; const
Msg :
TMessageBase
)
;
virtual;
Callback method when the context handle was resetted.
- protected procedure DoCreateBitmapPool ( ) ; virtual;
- protected procedure DoCreateDefaultBitmaps
(
)
;
virtual;
Creates all default texture bitmaps depending on the specific flags, f.e. FAllowTexture0, FAllowNormalMapTexture, ...
- protected procedure DoUpdateDefaultBitmaps ( ) ; virtual;
- protected function DoAddBitmapToPool
(
const
AName :
string; const
AIsDynamic :
Boolean
=
False
; const
AIgnoreInArray :
Boolean
=
False
; const
AShaderKind :
TContextShaderKind
=
PixelShader
)
: TGorillaBitmapPoolEntry
;
virtual;
Adds a new bitmap to the texture bitmap pool.
- protected procedure DoOnBitmapPoolChanged ( ASender : TObject ) ; virtual;
- public function FindBitmapByName
(
const
AName :
string
)
: TBitmap
;
Tries to find a pool bitmap by a supplied name. If no entry could be found, the method returns nil.
- public function FindBitmapEntryByName
(
const
AName :
string
)
: TGorillaBitmapPoolEntry
;
Tries to find a pool bitmap entry by a supplied name. If no entry could be found, the method returns nil.
- public procedure UpdateDefaultBitmaps
(
)
;
Updates the internal default texture bitmaps like Texture0, NormalMapTexture, ... Call this method, if you change the defines for internal textures to create/destroy a texture bitmap.
Properties
- public TextureTiling[Index] : TPointF
- public UseLighting : Boolean
Enable or disable lighting shading model computation in shader.
read GetUseLighting
write SetUseLighting - public UseTexturing : Boolean
Enable or disable general texturing functionality. Texture0 not necessary!
read GetUseTexturing
write SetUseTexturing - public UseTexture0 : Boolean
Enable or disable base color texturing or use color rendering.
read GetUseTexture0
write SetUseTexture0 - public UseVertexColor : Boolean
- public UseColorClipping : Boolean
- public Texture : TBitmap
Get or set the diffuse color texture. This is only a weak reference to the first entry in the texture pool (Bitmaps).
read GetTexture0
write SetTexture0 - public Inputs : TDictionary<System.string,Gorilla.Controller.TGorillaRenderPassController>
- public ShadowMapPass[Index] : TGorillaRenderPassController
- published ShadingModel : TGorillaShadingModel
Get or set the used shading model. You can choose between Lambert, Phong or Blinnphong shading algorithm.
read GetShadingModel
write SetShadingModel - published Diffuse : TAlphaColorF
- published Emissive : TAlphaColorF
- published Ambient : TAlphaColorF
- published Specular : TAlphaColorF
- published ClippingColor : TAlphaColorF
Set the clipping color value: R/G/B is the basis color, A is the tolerance.
read GetClippingColor
write SetClippingColor - published Shininess : Single
- published NearLimit : Single
- published FarLimit : Single
- published Bitmaps : TGorillaBitmapPool
- published Shadows : Boolean
- published ShadowMethod : TGorillaShadowMethod
Get or set the used shadow method in shader. This property only has effect if "Shadows" is set to true.
read GetShadowMethod
write SetShadowMethod - published DepthPass : TGorillaRenderPassController
- published GeometryPass : TGorillaRenderPassController
- published Reflections : Boolean
- published ReflectionPass : TGorillaRenderPassController
Get reflection render pass or set reflection render pass to apply a reflection texture to material.
read GetReflectionPass
write SetReflectionPass - published ReflectionPower : Single
Read or write reflection color mixing factor from / to material.
read GetReflectionPower
write SetReflectionPower - published Refractions : Boolean
- published RefractionPass : TGorillaRenderPassController
Get refraction render pass or set refraction render pass to apply a refraction texture to material.
read GetRefractionPass
write SetRefractionPass - published RefractionPower : Single
Read or write refraction color mixing factor from / to material.
read GetRefractionPower
write SetRefractionPower