Debian Codegraph @

src/scene/glsl/generated-pascal/common.vs.inc

raw
1 { -*- buffer-read-only: t -*- }
2 { DON'T EDIT -- this file was automatically generated from "source/common.vs" }
3 '/* Vertex shader utilities used by both Gouraud and Phong shading.' + LineEnding +
4 '' + LineEnding +
5 ' Used by ../castlerendererinternalshader.pas to construct the final shader.' + LineEnding +
6 ' When you change this file, rerun `make'' and then recompile Pascal sources.' + LineEnding +
7 '*/' + LineEnding +
8 '' + LineEnding +
9 '#ifdef CASTLE_NEEDS_MIRROR_PLANE_TEX_COORDS' + LineEnding +
10 'uniform vec4 castle_NormalizedPlane;' + LineEnding +
11 'uniform vec3 castle_CameraPositionOnPlane;' + LineEnding +
12 'uniform vec3 castle_CameraSide;' + LineEnding +
13 'uniform vec3 castle_CameraUp;' + LineEnding +
14 'uniform vec4 castle_FrustumDimensions;' + LineEnding +
15 '' + LineEnding +
16 '/* Calculate texture coordinates matching ViewpointMirror texture projection. */' + LineEnding +
17 'vec3 castle_generate_tex_coords_mirror_plane(const in vec4 vertex_world)' + LineEnding +
18 '{' + LineEnding +
19 ' /* The same implemented on CPU in Pascal (with Coord = vertex_world):' + LineEnding +
20 '' + LineEnding +
21 ' PlaneCoord := PointOnPlaneClosestToPoint(Plane, Coord) - CameraPositionOnPlane;' + LineEnding +
22 ' PlaneCoordProjected := Vector2(' + LineEnding +
23 ' TVector3.DotProduct(PlaneCoord, CameraSide),' + LineEnding +
24 ' TVector3.DotProduct(PlaneCoord, CameraUp)' + LineEnding +
25 ' );' + LineEnding +
26 ' Exit(Vector2(' + LineEnding +
27 ' (PlaneCoordProjected.Data[0] - FrustumDimensions.Left) / FrustumDimensions.Width,' + LineEnding +
28 ' (PlaneCoordProjected.Data[1] - FrustumDimensions.Bottom) / FrustumDimensions.Height' + LineEnding +
29 ' ));' + LineEnding +
30 ' */' + LineEnding +
31 '' + LineEnding +
32 ' float plane_d =' + LineEnding +
33 ' - dot(castle_NormalizedPlane.xyz, vertex_world.xyz)' + LineEnding +
34 ' - castle_NormalizedPlane.w;' + LineEnding +
35 ' vec3 vertex_on_plane = vertex_world.xyz + castle_NormalizedPlane.xyz * plane_d;' + LineEnding +
36 '' + LineEnding +
37 ' vertex_on_plane -= castle_CameraPositionOnPlane;' + LineEnding +
38 '' + LineEnding +
39 ' vec2 projected = vec2(' + LineEnding +
40 ' dot(vertex_on_plane, castle_CameraSide),' + LineEnding +
41 ' dot(vertex_on_plane, castle_CameraUp));' + LineEnding +
42 '' + LineEnding +
43 ' return vec3(' + LineEnding +
44 ' (projected.x - castle_FrustumDimensions.x) / castle_FrustumDimensions.z,' + LineEnding +
45 ' (projected.y - castle_FrustumDimensions.y) / castle_FrustumDimensions.w,' + LineEnding +
46 ' 0.0);' + LineEnding +
47 '}' + LineEnding +
48 '#endif' + LineEnding +
49 '' + LineEnding +
50 '/* Sphere mapping in GLSL adapted from' + LineEnding +
51 ' http://www.ozone3d.net/tutorials/glsl_texturing_p04.php#part_41' + LineEnding +
52 ' by Jerome Guinot aka ''JeGX'', many thanks!' + LineEnding +
53 '*/' + LineEnding +
54 'vec2 castle_generate_tex_coords_sphere(const in vec4 vertex_eye, const in vec3 normal_eye)' + LineEnding +
55 '{' + LineEnding +
56 ' vec3 r = reflect( normalize(vec3(vertex_eye)), normal_eye );' + LineEnding +
57 ' float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );' + LineEnding +
58 ' /* Using 1.0 / 2.0 instead of 0.5 to workaround fglrx bugs */' + LineEnding +
59 ' return r.xy / m + vec2(1.0, 1.0) / 2.0;' + LineEnding +
60 '}' + LineEnding +
61 ''