- if not FormatIsUncompressed(InternalFormat) then
- raise EglBitmapUnsupportedInternalFormat.Create('TglBitmap2D.ToNormalMap - ' + UNSUPPORTED_INTERNAL_FORMAT);
-
- if Scale > 100 then
- Rec.Scale := 100
- else
- if Scale < -100 then
- Rec.Scale := -100
- else
- Rec.Scale := Scale;
-
- SetLength(Rec.Heights, Width * Height);
- try
- case Func of
- nm4Samples:
- begin
- SetLength(Rec.MatrixU, 2);
- SetEntry(Rec.MatrixU, 0, -1, 0, -0.5);
- SetEntry(Rec.MatrixU, 1, 1, 0, 0.5);
-
- SetLength(Rec.MatrixV, 2);
- SetEntry(Rec.MatrixV, 0, 0, 1, 0.5);
- SetEntry(Rec.MatrixV, 1, 0, -1, -0.5);
- end;
- nmSobel:
- begin
- SetLength(Rec.MatrixU, 6);
- SetEntry(Rec.MatrixU, 0, -1, 1, -1.0);
- SetEntry(Rec.MatrixU, 1, -1, 0, -2.0);
- SetEntry(Rec.MatrixU, 2, -1, -1, -1.0);
- SetEntry(Rec.MatrixU, 3, 1, 1, 1.0);
- SetEntry(Rec.MatrixU, 4, 1, 0, 2.0);
- SetEntry(Rec.MatrixU, 5, 1, -1, 1.0);
-
- SetLength(Rec.MatrixV, 6);
- SetEntry(Rec.MatrixV, 0, -1, 1, 1.0);
- SetEntry(Rec.MatrixV, 1, 0, 1, 2.0);
- SetEntry(Rec.MatrixV, 2, 1, 1, 1.0);
- SetEntry(Rec.MatrixV, 3, -1, -1, -1.0);
- SetEntry(Rec.MatrixV, 4, 0, -1, -2.0);
- SetEntry(Rec.MatrixV, 5, 1, -1, -1.0);
- end;
- nm3x3:
- begin
- SetLength(Rec.MatrixU, 6);
- SetEntry(Rec.MatrixU, 0, -1, 1, -1/6);
- SetEntry(Rec.MatrixU, 1, -1, 0, -1/6);
- SetEntry(Rec.MatrixU, 2, -1, -1, -1/6);
- SetEntry(Rec.MatrixU, 3, 1, 1, 1/6);
- SetEntry(Rec.MatrixU, 4, 1, 0, 1/6);
- SetEntry(Rec.MatrixU, 5, 1, -1, 1/6);
-
- SetLength(Rec.MatrixV, 6);
- SetEntry(Rec.MatrixV, 0, -1, 1, 1/6);
- SetEntry(Rec.MatrixV, 1, 0, 1, 1/6);
- SetEntry(Rec.MatrixV, 2, 1, 1, 1/6);
- SetEntry(Rec.MatrixV, 3, -1, -1, -1/6);
- SetEntry(Rec.MatrixV, 4, 0, -1, -1/6);
- SetEntry(Rec.MatrixV, 5, 1, -1, -1/6);
- end;
- nm5x5:
- begin
- SetLength(Rec.MatrixU, 20);
- SetEntry(Rec.MatrixU, 0, -2, 2, -1 / 16);
- SetEntry(Rec.MatrixU, 1, -1, 2, -1 / 10);
- SetEntry(Rec.MatrixU, 2, 1, 2, 1 / 10);
- SetEntry(Rec.MatrixU, 3, 2, 2, 1 / 16);
- SetEntry(Rec.MatrixU, 4, -2, 1, -1 / 10);
- SetEntry(Rec.MatrixU, 5, -1, 1, -1 / 8);
- SetEntry(Rec.MatrixU, 6, 1, 1, 1 / 8);
- SetEntry(Rec.MatrixU, 7, 2, 1, 1 / 10);
- SetEntry(Rec.MatrixU, 8, -2, 0, -1 / 2.8);
- SetEntry(Rec.MatrixU, 9, -1, 0, -0.5);
- SetEntry(Rec.MatrixU, 10, 1, 0, 0.5);
- SetEntry(Rec.MatrixU, 11, 2, 0, 1 / 2.8);
- SetEntry(Rec.MatrixU, 12, -2, -1, -1 / 10);
- SetEntry(Rec.MatrixU, 13, -1, -1, -1 / 8);
- SetEntry(Rec.MatrixU, 14, 1, -1, 1 / 8);
- SetEntry(Rec.MatrixU, 15, 2, -1, 1 / 10);
- SetEntry(Rec.MatrixU, 16, -2, -2, -1 / 16);
- SetEntry(Rec.MatrixU, 17, -1, -2, -1 / 10);
- SetEntry(Rec.MatrixU, 18, 1, -2, 1 / 10);
- SetEntry(Rec.MatrixU, 19, 2, -2, 1 / 16);
-
- SetLength(Rec.MatrixV, 20);
- SetEntry(Rec.MatrixV, 0, -2, 2, 1 / 16);
- SetEntry(Rec.MatrixV, 1, -1, 2, 1 / 10);
- SetEntry(Rec.MatrixV, 2, 0, 2, 0.25);
- SetEntry(Rec.MatrixV, 3, 1, 2, 1 / 10);
- SetEntry(Rec.MatrixV, 4, 2, 2, 1 / 16);
- SetEntry(Rec.MatrixV, 5, -2, 1, 1 / 10);
- SetEntry(Rec.MatrixV, 6, -1, 1, 1 / 8);
- SetEntry(Rec.MatrixV, 7, 0, 1, 0.5);
- SetEntry(Rec.MatrixV, 8, 1, 1, 1 / 8);
- SetEntry(Rec.MatrixV, 9, 2, 1, 1 / 16);
- SetEntry(Rec.MatrixV, 10, -2, -1, -1 / 16);
- SetEntry(Rec.MatrixV, 11, -1, -1, -1 / 8);
- SetEntry(Rec.MatrixV, 12, 0, -1, -0.5);
- SetEntry(Rec.MatrixV, 13, 1, -1, -1 / 8);
- SetEntry(Rec.MatrixV, 14, 2, -1, -1 / 10);
- SetEntry(Rec.MatrixV, 15, -2, -2, -1 / 16);
- SetEntry(Rec.MatrixV, 16, -1, -2, -1 / 10);
- SetEntry(Rec.MatrixV, 17, 0, -2, -0.25);
- SetEntry(Rec.MatrixV, 18, 1, -2, -1 / 10);
- SetEntry(Rec.MatrixV, 19, 2, -2, -1 / 16);
- end;
- end;
-
- // Daten Sammeln
- if UseAlpha and FormatHasAlpha(InternalFormat) then
- AddFunc(glBitmapToNormalMapPrepareAlphaFunc, False, @Rec)
- else
- AddFunc(glBitmapToNormalMapPrepareFunc, False, @Rec);