Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/Tutorial/Media/materials/scripts/OffsetMapping.material @ 44

Last change on this file since 44 was 44, checked in by bknecht, 17 years ago

merge from tutorial branche to trunk

File size: 6.2 KB
RevLine 
[25]1// Bump map with Parallax offset vertex program, support for this is required
2vertex_program Examples/OffsetMappingVP cg
3{
4   source OffsetMapping.cg
5   entry_point main_vp
6   profiles vs_1_1 arbvp1
7}
8
9// Bump map with parallax fragment program
10fragment_program Examples/OffsetMappingFP cg
11{
12   source OffsetMapping.cg
13   entry_point main_fp
14   profiles ps_2_0 arbfp1
15}
16
17// Bump map with parallax fragment program
18fragment_program Examples/OffsetMappingPS asm
19{
20   source OffsetMapping_specular.asm
21   // sorry, only for ps_1_4 and above:)
22   syntax ps_1_4
23}
24
25
26material Examples/OffsetMapping/Specular
27{
28
29  // This is the preferred technique which uses both vertex and
30   // fragment programs, supports coloured lights
31   technique
32   {
33      // do the lighting  and bump mapping with parallax pass
34      pass
35      {
36       
37         // Vertex program reference
38         vertex_program_ref Examples/OffsetMappingVP
39         {
40            param_named_auto lightPosition light_position_object_space 0
41            param_named_auto eyePosition camera_position_object_space
42            param_named_auto worldViewProj worldviewproj_matrix
43         }
44
45         // Fragment program
46         fragment_program_ref Examples/OffsetMappingFP
47         {
48            param_named_auto lightDiffuse light_diffuse_colour 0
49            param_named_auto lightSpecular light_specular_colour 0
50            // Parallax Height scale and bias
51            param_named scaleBias float4 0.04 -0.02 1 0
52         }
53         
54         // Normal + height(alpha) map
55         texture_unit
56         {
57            texture rockwall_NH.tga
58            tex_coord_set 0
59         }
60
61         // Base diffuse texture map
62         texture_unit
63         {
64            texture rockwall.tga
65            tex_coord_set 1
66         }
67      }
68   }
69
70
71   // This is the preferred technique which uses both vertex and
72   // fragment programs, supports coloured lights
73   technique
74   {
75      // do the lighting  and bump mapping with parallax pass
76      pass
77      {
78       
79         // Vertex program reference
80         vertex_program_ref Examples/OffsetMappingVP
81         {
82            param_named_auto lightPosition light_position_object_space 0
83            param_named_auto eyePosition camera_position_object_space
84            param_named_auto worldViewProj worldviewproj_matrix
85         }
86
87         // Fragment program
88         fragment_program_ref Examples/OffsetMappingPS
89         {
90            param_indexed_auto 0 light_diffuse_colour 0
91            param_indexed_auto 1 light_specular_colour 0
92            // Parallax Height scale and bias
93            param_indexed 2 float4 0.04 -0.02 1 0
94         }
95         
96         // Normal + height(alpha) map
97         texture_unit
98         {
99            texture rockwall_NH.tga
100            tex_coord_set 0
101         }
102
103         // Base diffuse texture map
104         texture_unit
105         {
106            texture rockwall.tga
107            tex_coord_set 1
108         }
109      }
110   }
111   
112   // Simple no-shader fallback
113   technique
114   {
115      pass
116      {
117         // Base diffuse texture map
118         texture_unit
119         {
120            texture rockwall.tga
121         }
122          }
123   }
124
125}
126
127
128
129// Single-pass offset mapping with shadows
130vertex_program Examples/OffsetMappingIntegratedShadowsVPhlsl hlsl
131{
132   source OffsetMapping.hlsl
133   entry_point integratedshadows_vp
134   target vs_2_0
135}
136vertex_program Examples/OffsetMappingIntegratedShadowsVPglsl glsl
137{
138   source OffsetMappingVp.glsl
139}
140
141// Single-pass offset mapping with shadows
142fragment_program Examples/OffsetMappingIntegratedShadowsFPhlsl hlsl
143{
144   source OffsetMapping.hlsl
145   entry_point integratedshadows_fp
146   target ps_2_0
147}
148fragment_program Examples/OffsetMappingIntegratedShadowsFPglsl glsl
149{
150        source OffsetMappingFp.glsl
151        default_params
152        {
153                // assign samplers as required by GLSL
154                param_named normalHeightMap int 0
155                param_named diffuseMap int 1
156                param_named shadowMap1 int 2
157                param_named shadowMap2 int 3
158        }
159}
160// Single-pass offset mapping with shadows
161vertex_program Examples/OffsetMappingIntegratedShadowsVP unified
162{
163        delegate Examples/OffsetMappingIntegratedShadowsVPhlsl
164        delegate Examples/OffsetMappingIntegratedShadowsVPglsl
165}
166// Single-pass offset mapping with shadows
167fragment_program Examples/OffsetMappingIntegratedShadowsFP unified
168{
169        delegate Examples/OffsetMappingIntegratedShadowsFPhlsl
170        delegate Examples/OffsetMappingIntegratedShadowsFPglsl
171}
172
173
174
175material Examples/OffsetMapping/IntegratedShadows
176{
177
178   technique
179   {
180      // do the lighting  and bump mapping with parallax pass
181      pass
182      {
183       
184         // Vertex program reference
185         vertex_program_ref Examples/OffsetMappingIntegratedShadowsVP
186         {
187            param_named_auto lightPosition light_position_object_space 0
188            param_named_auto eyePosition camera_position_object_space
189            param_named_auto worldViewProj worldviewproj_matrix
190                        param_named_auto spotDirection light_direction_object_space 0
191
192            param_named_auto lightPosition1 light_position_object_space 1
193                        param_named_auto spotDirection1 light_direction_object_space 1
194                        // shadow texture projections
195                        param_named_auto worldMatrix world_matrix
196                        param_named_auto texViewProj1 texture_viewproj_matrix 0
197                        param_named_auto texViewProj2 texture_viewproj_matrix 1
198         }
199
200         // Fragment program
201         fragment_program_ref Examples/OffsetMappingIntegratedShadowsFP
202         {
203            param_named_auto lightDiffuse light_diffuse_colour 0
204                        param_named_auto spotParams spotlight_params 0
205
206                        param_named_auto lightDiffuse1 light_diffuse_colour 1
207                        param_named_auto spotParams1 spotlight_params 1
208            // Parallax Height scale and bias
209            param_named scaleBias float4 0.04 -0.02 1 0
210         }
211         
212         // Normal + height(alpha) map
213         texture_unit
214         {
215            texture rockwall_NH.tga
216            tex_coord_set 0
217         }
218
219         // Base diffuse texture map
220         texture_unit
221         {
222            texture rockwall.tga
223            tex_coord_set 1
224         }
225
226                 // shadowmap 1
227                 texture_unit
228                 {
229                        content_type shadow
230                 }
231                 // shadowmap 2
232                 texture_unit
233                 {
234                        content_type shadow
235                 }
236      }
237   }
238
239
240
241}
242
Note: See TracBrowser for help on using the repository browser.