| 1 |
{%MainUnit castlerendererinternalshader.pas} |
| 2 |
{ |
| 3 |
Copyright 2010-2024 Michalis Kamburelis. |
| 4 |
|
| 5 |
This file is part of "Castle Game Engine". |
| 6 |
|
| 7 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 8 |
included in this distribution, for details about the copyright. |
| 9 |
|
| 10 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| 14 |
---------------------------------------------------------------------------- |
| 15 |
} |
| 16 |
|
| 17 |
{ Generating shader code for "plane mirror" feature, |
| 18 |
https://castle-engine.io/x3d_extensions_mirror_plane.php . } |
| 19 |
|
| 20 |
{$ifdef read_interface} |
| 21 |
|
| 22 |
//type |
| 23 |
{ Shader uniforms calculated by rendering using ViewpointMirror, |
| 24 |
used by GLSL code calculating texture coordinates in case of |
| 25 |
TextureCoordinateGenerator.mode = "MIRROR-PLANE". } |
| 26 |
TMirrorPlaneUniforms = class |
| 27 |
NormalizedPlane: TVector4; |
| 28 |
CameraPositionOnPlane, CameraSide, CameraUp: TVector3; |
| 29 |
FrustumDimensions: TFloatRectangle; |
| 30 |
procedure SetDynamicUniforms(const AProgram: TX3DShaderProgram); |
| 31 |
end; |
| 32 |
|
| 33 |
{$endif read_interface} |
| 34 |
|
| 35 |
{$ifdef read_implementation} |
| 36 |
|
| 37 |
procedure TMirrorPlaneUniforms.SetDynamicUniforms(const AProgram: TX3DShaderProgram); |
| 38 |
begin |
| 39 |
AProgram.SetUniform('castle_NormalizedPlane', NormalizedPlane); |
| 40 |
AProgram.SetUniform('castle_CameraPositionOnPlane', CameraPositionOnPlane); |
| 41 |
AProgram.SetUniform('castle_CameraSide', CameraSide); |
| 42 |
AProgram.SetUniform('castle_CameraUp', CameraUp); |
| 43 |
AProgram.SetUniform('castle_FrustumDimensions', |
| 44 |
Vector4( |
| 45 |
FrustumDimensions.Left, |
| 46 |
FrustumDimensions.Bottom, |
| 47 |
FrustumDimensions.Width, |
| 48 |
FrustumDimensions.Height)); |
| 49 |
end; |
| 50 |
|
| 51 |
{$endif read_implementation} |