Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
1.1.0:default-material [2023/08/01 12:07] – [Material Behaviours] admin | 1.1.0:default-material [2024/01/05 10:07] (current) – [TGorillaShaderLight] admin | ||
---|---|---|---|
Line 537: | Line 537: | ||
Having a closer look at the structure below, it's showing further sub structures for lights, material, textures and render pass data. | Having a closer look at the structure below, it's showing further sub structures for lights, material, textures and render pass data. | ||
Those sub structures are automatically submitted to shaders too. | Those sub structures are automatically submitted to shaders too. | ||
+ | |||
+ | //Notice: Modified since v1.1// | ||
<file pascal> | <file pascal> | ||
TGorillaShaderData = packed record | TGorillaShaderData = packed record | ||
- | /// < | ||
- | /// Defines the multiplied model and view matrix. | ||
- | /// </ | ||
- | ModelMatrix : TMatrix3D; | ||
/// < | /// < | ||
/// Defines the multiplied model, view and projection matrix. | /// Defines the multiplied model, view and projection matrix. | ||
/// </ | /// </ | ||
ModelViewProjectionMatrix : TMatrix3D; | ModelViewProjectionMatrix : TMatrix3D; | ||
- | /// < | ||
- | /// Defines the inverted and transposed multiplied model and view matrix. | ||
- | /// </ | ||
- | ModelNormalMatrix : TMatrix3D; | ||
/// < | /// < | ||
/// Defines the view / camera matrix. | /// Defines the view / camera matrix. | ||
Line 728: | Line 722: | ||
/// </ | /// </ | ||
Clipping : TAlphaColorF; | Clipping : TAlphaColorF; | ||
+ | | ||
+ | /// < | ||
+ | /// Alpha cutoff value: (X > 0.01) == enabled, (Y == tolerated value) | ||
+ | /// </ | ||
+ | AlphaCutoff : TPointF; | ||
+ | /// < | ||
+ | /// Tonemapping exposure value | ||
+ | /// </ | ||
+ | ToneMapExp | ||
+ | Reserve | ||
/// < | /// < | ||
Line 846: | Line 850: | ||
{$ENDIF} | {$ENDIF} | ||
Position | Position | ||
- | /// < | ||
- | /// A " | ||
- | /// vector at the half angle between two other vectors. Normally the | ||
- | /// halfway vector [...] is computed between the vector to the viewer v | ||
- | /// and the light source. | ||
- | /// </ | ||
- | /// < | ||
- | /// H(a,b) = normalize(normalize(a) + normalize(b)) | ||
- | /// </ | ||
- | // HalfVector | ||
Direction | Direction | ||
Ambient | Ambient | ||
Diffuse | Diffuse | ||
Specular | Specular | ||
+ | | ||
+ | /// < | ||
+ | /// Light-Scattering settings are compressed into a single vec4 value, with | ||
+ | /// the following structure: | ||
+ | /// x=intensity, | ||
+ | /// </ | ||
+ | Scattering : TVector3D; | ||
SpotCutoff | SpotCutoff | ||
Line 868: | Line 869: | ||
LinearAttenuation | LinearAttenuation | ||
QuadraticAttenuation : Single; | QuadraticAttenuation : Single; | ||
- | {$IFDEF GL_ES_VERSION_3_0} | + | |
- | | + | |
- | | + | |
- | {$ENDIF} | + | |
constructor Create(ALight : TLightDescription); | constructor Create(ALight : TLightDescription); | ||
Line 1033: | Line 1033: | ||
Apply a single material behaviour to multiple material sources, but the place to edit parameters of your behaviour stay centralized. This makes it very easy to manage complex shading behaviour. | Apply a single material behaviour to multiple material sources, but the place to edit parameters of your behaviour stay centralized. This makes it very easy to manage complex shading behaviour. | ||
- | Read more [[material-behaviour|Material Behaviour]] | + | Read more about [[material-behaviour|Material Behaviour]] |
===== Extending the default material ===== | ===== Extending the default material ===== | ||
Line 1446: | Line 1446: | ||
DATA.Position.xyz = DELPHI_WOBBLE(DATA.Position.xyz, | DATA.Position.xyz = DELPHI_WOBBLE(DATA.Position.xyz, | ||
- | DATA.TransfVertexPos = _ModelMatrix | + | DATA.TransfVertexPos = a_ModelMatrix |
DATA.WorldViewProjVertPos = _ModelViewProjectionMatrix * DATA.Position; | DATA.WorldViewProjVertPos = _ModelViewProjectionMatrix * DATA.Position; | ||
} | } | ||
Line 1480: | Line 1480: | ||
Read more about TLocals structure in VertexShader/ | Read more about TLocals structure in VertexShader/ | ||
at // | at // | ||
+ | |||
+ | To modify the " | ||
+ | Otherwise the shader code is not getting updated after modifying the user-code: | ||
+ | |||
+ | <file Pascal> | ||
+ | procedure TForm1.SetMyShaderCode(); | ||
+ | var LStr : TStringList; | ||
+ | begin | ||
+ | /// Create a temporary stringlist component for our source code | ||
+ | LStr := TStringList.Create(); | ||
+ | try | ||
+ | LStr.Text := | ||
+ | 'void SurfaceShader(inout TLocals DATA){'# | ||
+ | /// make everything green | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | // Apply the temporary stringlist to the material | ||
+ | // This will assign it to the internal stringlist and update the shader code | ||
+ | // automatically. | ||
+ | GorillaLambertMaterialSource1.SurfaceShader := LStr; | ||
+ | finally | ||
+ | FreeAndNil(LStr); | ||
+ | end; | ||
+ | end; | ||
+ | </ | ||
==== Adding new Textures at DesignTime ==== | ==== Adding new Textures at DesignTime ==== |