| [5119] | 1 |  | 
|---|
|  | 2 | //-------------- | 
|---|
|  | 3 | // Bump mapping | 
|---|
|  | 4 | //-------------- | 
|---|
|  | 5 |  | 
|---|
|  | 6 | // Bump map vertex program, support for this is required | 
|---|
| [5122] | 7 | vertex_program BumpMap2VP cg | 
|---|
| [5119] | 8 | { | 
|---|
|  | 9 | source BumpMapping.cg | 
|---|
|  | 10 | entry_point main_vp | 
|---|
|  | 11 | profiles vs_1_1 arbvp1 | 
|---|
|  | 12 | } | 
|---|
|  | 13 |  | 
|---|
|  | 14 | // Bump map fragment program, support for this is optional | 
|---|
| [5122] | 15 | fragment_program BumpMap2FP cg | 
|---|
| [5119] | 16 | { | 
|---|
|  | 17 | source BumpMapping.cg | 
|---|
|  | 18 | entry_point main_fp | 
|---|
|  | 19 | profiles ps_1_1 arbfp1 fp20 | 
|---|
|  | 20 | } | 
|---|
|  | 21 |  | 
|---|
|  | 22 | // Bump map with specular vertex program, support for this is required | 
|---|
| [5122] | 23 | vertex_program BumpMap2VPSpecular cg | 
|---|
| [5119] | 24 | { | 
|---|
|  | 25 | source BumpMapping.cg | 
|---|
|  | 26 | entry_point specular_vp | 
|---|
|  | 27 | profiles vs_1_1 arbvp1 | 
|---|
|  | 28 | } | 
|---|
|  | 29 |  | 
|---|
|  | 30 | // Bump map fragment program, support for this is optional | 
|---|
| [5122] | 31 | fragment_program BumpMap2FPSpecular cg | 
|---|
| [5119] | 32 | { | 
|---|
|  | 33 | source BumpMapping.cg | 
|---|
|  | 34 | entry_point specular_fp | 
|---|
|  | 35 | profiles ps_1_1 arbfp1 fp20 | 
|---|
|  | 36 |  | 
|---|
|  | 37 | default_params | 
|---|
|  | 38 | { | 
|---|
|  | 39 | param_named shine float 3 | 
|---|
|  | 40 | } | 
|---|
|  | 41 |  | 
|---|
|  | 42 | } | 
|---|
|  | 43 |  | 
|---|
|  | 44 |  | 
|---|
|  | 45 | // Any number of lights, diffuse and specular | 
|---|
|  | 46 | material BumpMapping/MultiLightSpecular | 
|---|
|  | 47 | { | 
|---|
|  | 48 |  | 
|---|
|  | 49 | // This is the preferred technique which uses both vertex and | 
|---|
|  | 50 | // fragment programs, supports coloured lights | 
|---|
|  | 51 | technique | 
|---|
|  | 52 | { | 
|---|
|  | 53 | // Base ambient pass | 
|---|
|  | 54 | pass | 
|---|
|  | 55 | { | 
|---|
|  | 56 | // base colours, not needed for rendering, but as information | 
|---|
|  | 57 | // to lighting pass categorisation routine | 
|---|
|  | 58 | ambient 1 1 1 | 
|---|
|  | 59 | diffuse 0 0 0 | 
|---|
|  | 60 | specular 0 0 0 0 | 
|---|
|  | 61 | // Really basic vertex program | 
|---|
|  | 62 | // NB we don't use fixed function here because GL does not like | 
|---|
|  | 63 | // mixing fixed function and vertex programs, depth fighting can | 
|---|
|  | 64 | // be an issue | 
|---|
|  | 65 | vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture | 
|---|
|  | 66 | { | 
|---|
|  | 67 | param_named_auto worldViewProj worldviewproj_matrix | 
|---|
|  | 68 | param_named_auto ambient ambient_light_colour | 
|---|
|  | 69 | } | 
|---|
|  | 70 |  | 
|---|
|  | 71 | } | 
|---|
|  | 72 | // Now do the lighting pass | 
|---|
|  | 73 | // NB we don't do decal texture here because this is repeated per light | 
|---|
|  | 74 | pass | 
|---|
|  | 75 | { | 
|---|
|  | 76 | // base colours, not needed for rendering, but as information | 
|---|
|  | 77 | // to lighting pass categorisation routine | 
|---|
|  | 78 | ambient 0 0 0 | 
|---|
|  | 79 | // do this for each light | 
|---|
|  | 80 | iteration once_per_light | 
|---|
|  | 81 |  | 
|---|
|  | 82 |  | 
|---|
|  | 83 | scene_blend add | 
|---|
|  | 84 |  | 
|---|
|  | 85 | // Vertex program reference | 
|---|
| [5122] | 86 | vertex_program_ref BumpMap2VPSpecular | 
|---|
| [5119] | 87 | { | 
|---|
|  | 88 | param_named_auto lightPosition light_position_object_space 0 | 
|---|
|  | 89 | param_named_auto eyePosition camera_position_object_space | 
|---|
|  | 90 | param_named_auto worldViewProj worldviewproj_matrix | 
|---|
|  | 91 | } | 
|---|
|  | 92 |  | 
|---|
|  | 93 | // Fragment program | 
|---|
| [5122] | 94 | fragment_program_ref BumpMap2FPSpecular | 
|---|
| [5119] | 95 | { | 
|---|
|  | 96 | param_named_auto lightDiffuse light_diffuse_colour 0 | 
|---|
|  | 97 | param_named_auto lightSpecular light_specular_colour 0 | 
|---|
|  | 98 | param_named shine float 20 | 
|---|
|  | 99 | } | 
|---|
|  | 100 |  | 
|---|
|  | 101 | // Base bump map | 
|---|
|  | 102 | texture_unit | 
|---|
|  | 103 | { | 
|---|
|  | 104 | texture NMnone.tga | 
|---|
|  | 105 | colour_op replace | 
|---|
|  | 106 | } | 
|---|
|  | 107 | // Normalisation cube map | 
|---|
|  | 108 | texture_unit | 
|---|
|  | 109 | { | 
|---|
|  | 110 | cubic_texture nm.tga combinedUVW | 
|---|
|  | 111 | tex_coord_set 1 | 
|---|
|  | 112 | tex_address_mode clamp | 
|---|
|  | 113 | } | 
|---|
|  | 114 | // Normalisation cube map #2 | 
|---|
|  | 115 | texture_unit | 
|---|
|  | 116 | { | 
|---|
|  | 117 | cubic_texture nm.tga combinedUVW | 
|---|
|  | 118 | tex_coord_set 2 | 
|---|
|  | 119 | tex_address_mode clamp | 
|---|
|  | 120 | } | 
|---|
|  | 121 | } | 
|---|
|  | 122 |  | 
|---|
|  | 123 | // Decal pass | 
|---|
|  | 124 | pass | 
|---|
|  | 125 | { | 
|---|
|  | 126 | lighting off | 
|---|
|  | 127 | // Really basic vertex program | 
|---|
|  | 128 | // NB we don't use fixed function here because GL does not like | 
|---|
|  | 129 | // mixing fixed function and vertex programs, depth fighting can | 
|---|
|  | 130 | // be an issue | 
|---|
|  | 131 | vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture | 
|---|
|  | 132 | { | 
|---|
|  | 133 | param_named_auto worldViewProj worldviewproj_matrix | 
|---|
|  | 134 | param_named ambient float4 1 1 1 1 | 
|---|
|  | 135 | } | 
|---|
|  | 136 | scene_blend dest_colour zero | 
|---|
|  | 137 | texture_unit | 
|---|
|  | 138 | { | 
|---|
|  | 139 | texture assff.jpg | 
|---|
|  | 140 | } | 
|---|
|  | 141 |  | 
|---|
|  | 142 | } | 
|---|
|  | 143 | } | 
|---|
|  | 144 |  | 
|---|
|  | 145 | // This is the fallback which cards which don't have fragment program | 
|---|
|  | 146 | // support will use, NB does not support specular colour | 
|---|
|  | 147 | // Note that it still requires vertex program support | 
|---|
|  | 148 | technique | 
|---|
|  | 149 | { | 
|---|
|  | 150 | // Base ambient pass | 
|---|
|  | 151 | pass | 
|---|
|  | 152 | { | 
|---|
|  | 153 | // base colours, not needed for rendering, but as information | 
|---|
|  | 154 | // to lighting pass categorisation routine | 
|---|
|  | 155 | ambient 1 1 1 | 
|---|
|  | 156 | diffuse 0 0 0 | 
|---|
|  | 157 | specular 0 0 0 0 | 
|---|
|  | 158 | // Really basic vertex program | 
|---|
|  | 159 | // NB we don't use fixed function here because GL does not like | 
|---|
|  | 160 | // mixing fixed function and vertex programs, depth fighting can | 
|---|
|  | 161 | // be an issue | 
|---|
|  | 162 | vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture | 
|---|
|  | 163 | { | 
|---|
|  | 164 | param_named_auto worldViewProj worldviewproj_matrix | 
|---|
|  | 165 | param_named_auto ambient ambient_light_colour | 
|---|
|  | 166 | } | 
|---|
|  | 167 |  | 
|---|
|  | 168 | } | 
|---|
|  | 169 | // Now do the lighting pass | 
|---|
|  | 170 | // NB we don't do decal texture here because this is repeated per light | 
|---|
|  | 171 | pass | 
|---|
|  | 172 | { | 
|---|
|  | 173 | // base colours, not needed for rendering, but as information | 
|---|
|  | 174 | // to lighting pass categorisation routine | 
|---|
|  | 175 | ambient 0 0 0 | 
|---|
|  | 176 | // do this for each light | 
|---|
|  | 177 | iteration once_per_light | 
|---|
|  | 178 |  | 
|---|
|  | 179 |  | 
|---|
|  | 180 | scene_blend add | 
|---|
|  | 181 |  | 
|---|
|  | 182 | // Vertex program reference | 
|---|
| [5122] | 183 | vertex_program_ref BumpMap2VP | 
|---|
| [5119] | 184 | { | 
|---|
|  | 185 | param_named_auto lightPosition light_position_object_space 0 | 
|---|
|  | 186 | param_named_auto worldViewProj worldviewproj_matrix | 
|---|
|  | 187 | } | 
|---|
|  | 188 |  | 
|---|
|  | 189 | // Base bump map | 
|---|
|  | 190 | texture_unit | 
|---|
|  | 191 | { | 
|---|
|  | 192 | texture NMnone.tga | 
|---|
|  | 193 | colour_op replace | 
|---|
|  | 194 | } | 
|---|
|  | 195 | // Normalisation cube map, with dot product on bump map | 
|---|
|  | 196 | texture_unit | 
|---|
|  | 197 | { | 
|---|
|  | 198 | cubic_texture nm.tga combinedUVW | 
|---|
|  | 199 | tex_coord_set 1 | 
|---|
|  | 200 | tex_address_mode clamp | 
|---|
|  | 201 | colour_op_ex dotproduct src_texture src_current | 
|---|
|  | 202 | colour_op_multipass_fallback dest_colour zero | 
|---|
|  | 203 | } | 
|---|
|  | 204 | } | 
|---|
|  | 205 |  | 
|---|
|  | 206 | // Decal pass | 
|---|
|  | 207 | pass | 
|---|
|  | 208 | { | 
|---|
|  | 209 | lighting off | 
|---|
|  | 210 | // Really basic vertex program | 
|---|
|  | 211 | // NB we don't use fixed function here because GL does not like | 
|---|
|  | 212 | // mixing fixed function and vertex programs, depth fighting can | 
|---|
|  | 213 | // be an issue | 
|---|
|  | 214 | vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture | 
|---|
|  | 215 | { | 
|---|
|  | 216 | param_named_auto worldViewProj worldviewproj_matrix | 
|---|
|  | 217 | param_named ambient float4 1 1 1 1 | 
|---|
|  | 218 | } | 
|---|
|  | 219 | scene_blend dest_colour zero | 
|---|
|  | 220 | texture_unit | 
|---|
|  | 221 | { | 
|---|
|  | 222 | texture assff.jpg | 
|---|
|  | 223 | } | 
|---|
|  | 224 |  | 
|---|
|  | 225 | } | 
|---|
|  | 226 |  | 
|---|
|  | 227 | } | 
|---|
|  | 228 | } | 
|---|
|  | 229 |  | 
|---|
|  | 230 |  | 
|---|
|  | 231 |  | 
|---|