ソースを参照

Range of shininess fixed

glscene 1 ヶ月 前
コミット
d98e61e649

+ 36 - 71
Examples/Demos/glslshaders/DiffuseShader/fDiffuseShaderD.dfm

@@ -1,32 +1,23 @@
 object FormDiffuseShader: TFormDiffuseShader
   Left = 261
   Top = 176
-  Margins.Left = 5
-  Margins.Top = 5
-  Margins.Right = 5
-  Margins.Bottom = 5
   Caption = 'GLSL Diffuse Specular Shader'
-  ClientHeight = 922
-  ClientWidth = 1397
+  ClientHeight = 527
+  ClientWidth = 798
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
-  Font.Height = -19
+  Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   Position = poScreenCenter
   OnCreate = FormCreate
-  PixelsPerInch = 168
-  TextHeight = 24
+  TextHeight = 13
   object Viewer: TGLSceneViewer
     Left = 0
     Top = 0
-    Width = 1115
-    Height = 922
-    Margins.Left = 5
-    Margins.Top = 5
-    Margins.Right = 5
-    Margins.Bottom = 5
+    Width = 637
+    Height = 527
     Camera = Camera
     Buffer.FogEnvironment.FogColor.Color = {ACC8483E9A99193FCDCC4C3F9A99993E}
     Buffer.FogEnvironment.FogStart = 50.000000000000000000
@@ -37,31 +28,25 @@ object FormDiffuseShader: TFormDiffuseShader
     Buffer.AntiAliasing = aaNone
     Buffer.DepthPrecision = dp24bits
     Buffer.ColorDepth = cd24bits
-    FieldOfView = 163.948654174804700000
+    FieldOfView = 152.285934448242200000
     PenAsTouch = False
     Align = alClient
     TabOrder = 0
   end
   object Panel1: TPanel
-    Left = 1115
+    Left = 637
     Top = 0
-    Width = 282
-    Height = 922
-    Margins.Left = 5
-    Margins.Top = 5
-    Margins.Right = 5
-    Margins.Bottom = 5
+    Width = 161
+    Height = 527
     Align = alRight
     TabOrder = 1
+    ExplicitLeft = 629
+    ExplicitHeight = 502
     object LightMovingCheckBox: TCheckBox
-      Left = 14
-      Top = 14
-      Width = 170
-      Height = 30
-      Margins.Left = 5
-      Margins.Top = 5
-      Margins.Right = 5
-      Margins.Bottom = 5
+      Left = 8
+      Top = 8
+      Width = 97
+      Height = 17
       Caption = 'Light is Moving'
       Checked = True
       Color = clBtnFace
@@ -70,14 +55,10 @@ object FormDiffuseShader: TFormDiffuseShader
       TabOrder = 0
     end
     object ShaderEnabledCheckBox: TCheckBox
-      Left = 14
-      Top = 112
-      Width = 170
-      Height = 30
-      Margins.Left = 5
-      Margins.Top = 5
-      Margins.Right = 5
-      Margins.Bottom = 5
+      Left = 8
+      Top = 64
+      Width = 97
+      Height = 17
       Caption = 'Shader Enabled'
       Checked = True
       State = cbChecked
@@ -85,41 +66,29 @@ object FormDiffuseShader: TFormDiffuseShader
       OnClick = ShaderEnabledCheckBoxClick
     end
     object TurnPitchrollCheckBox: TCheckBox
-      Left = 14
-      Top = 42
-      Width = 240
-      Height = 30
-      Margins.Left = 5
-      Margins.Top = 5
-      Margins.Right = 5
-      Margins.Bottom = 5
+      Left = 8
+      Top = 24
+      Width = 137
+      Height = 17
       Caption = 'Turn-Pitch-Roll Enabled'
       Checked = True
       State = cbChecked
       TabOrder = 2
     end
     object RealisticSpecularCheckBox: TCheckBox
-      Left = 14
-      Top = 198
-      Width = 240
-      Height = 30
-      Margins.Left = 5
-      Margins.Top = 5
-      Margins.Right = 5
-      Margins.Bottom = 5
+      Left = 8
+      Top = 113
+      Width = 137
+      Height = 17
       Caption = 'Realistic Specular Mode'
       TabOrder = 3
       OnClick = RealisticSpecularCheckBoxClick
     end
     object MultiLightShaderCheckBox: TCheckBox
-      Left = 14
-      Top = 140
-      Width = 198
-      Height = 30
-      Margins.Left = 5
-      Margins.Top = 5
-      Margins.Right = 5
-      Margins.Bottom = 5
+      Left = 8
+      Top = 80
+      Width = 113
+      Height = 17
       Caption = 'MultiLight Shader'
       Checked = True
       State = cbChecked
@@ -127,14 +96,10 @@ object FormDiffuseShader: TFormDiffuseShader
       OnClick = MultiLightShaderCheckBoxClick
     end
     object EnableFogCheckBox: TCheckBox
-      Left = 14
-      Top = 238
-      Width = 240
-      Height = 30
-      Margins.Left = 5
-      Margins.Top = 5
-      Margins.Right = 5
-      Margins.Bottom = 5
+      Left = 8
+      Top = 136
+      Width = 137
+      Height = 17
       Caption = 'Enable fog'
       TabOrder = 5
       OnClick = EnableFogCheckBoxClick

+ 9 - 4
Source/GLS.File3DS.pas

@@ -13,7 +13,7 @@ uses
   System.Classes,
   System.SysUtils,
   System.Math,
-  
+
   Stage.Strings,
   Stage.OpenGLTokens,
   Stage.VectorTypes,
@@ -1491,7 +1491,7 @@ end;
 
 procedure TGL3DSVectorFile.LoadFromStream(aStream: TStream);
 type
-  TSmoothIndexEntry = array[0..31] of cardinal;
+  TSmoothIndexEntry = array[0..31] of Cardinal;
   PSmoothIndexArray = ^TSmoothIndexArray;
   TSmoothIndexArray = array[0..MaxInt shr 8] of TSmoothIndexEntry;
 var
@@ -1509,6 +1509,7 @@ var
     specColor: TGLVector;
     matLib: TGLMaterialLibrary;
     libMat, SecondMaterial: TGLLibMaterial;
+    TmpShininess: Integer;
   begin
     material := Materials.MaterialByName[Name];
     Assert(Assigned(material));
@@ -1532,7 +1533,11 @@ var
               1 - Abs(material.Transparency));
             specColor := VectorMake(material.Specular.R, material.Specular.G, material.Specular.B, 1);
             Specular.Color := VectorScale(specColor, material.ShinStrength);
-            Shininess := MaxInteger(0, Integer(round((material.Shininess) * 128)));
+            TmpShininess := MaxInteger(0, Integer(round((material.Shininess) * 128)));
+            if (TmpShininess >= 0) and (TmpShininess <= 128) then
+              Shininess := TmpShininess
+            else
+              Shininess := 0;
             if material.Transparency <> 0 then
               libMat.material.BlendingMode := bmTransparency;
           end;
@@ -2025,7 +2030,7 @@ begin
                           StoreSmoothIndex(CurrentVertexCount - 1, SmoothingGroup, CurrentVertexCount - 1, SmoothIndices);
                           // mark new vertex also as touched
                           MarkVertex(Marker, CurrentVertexCount - 1);
-                        end;  
+                        end;
                       end
                       else
                       begin