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