| 1 | |
|---|
| 2 | //-------------- |
|---|
| 3 | // Bump mapping |
|---|
| 4 | //-------------- |
|---|
| 5 | |
|---|
| 6 | // Bump map vertex program, support for this is required |
|---|
| 7 | vertex_program BumpMapVP cg |
|---|
| 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 |
|---|
| 15 | fragment_program BumpMapFP cg |
|---|
| 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 |
|---|
| 23 | vertex_program BumpMapVPSpecular cg |
|---|
| 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 |
|---|
| 31 | fragment_program BumpMapFPSpecular cg |
|---|
| 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 Asteroid/BumpMap |
|---|
| 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 |
|---|
| 86 | vertex_program_ref BumpMapVPSpecular |
|---|
| 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 |
|---|
| 94 | fragment_program_ref BumpMapFPSpecular |
|---|
| 95 | { |
|---|
| 96 | param_named_auto lightDiffuse light_diffuse_colour 0 |
|---|
| 97 | param_named_auto lightSpecular light_specular_colour 0 |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | // Base bump map |
|---|
| 101 | texture_unit |
|---|
| 102 | { |
|---|
| 103 | texture NMrock.tga |
|---|
| 104 | colour_op replace |
|---|
| 105 | } |
|---|
| 106 | // Normalisation cube map |
|---|
| 107 | texture_unit |
|---|
| 108 | { |
|---|
| 109 | cubic_texture nm.tga combinedUVW |
|---|
| 110 | tex_coord_set 1 |
|---|
| 111 | tex_address_mode clamp |
|---|
| 112 | } |
|---|
| 113 | // Normalisation cube map #2 |
|---|
| 114 | texture_unit |
|---|
| 115 | { |
|---|
| 116 | cubic_texture nm.tga combinedUVW |
|---|
| 117 | tex_coord_set 2 |
|---|
| 118 | tex_address_mode clamp |
|---|
| 119 | } |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | // Decal pass |
|---|
| 123 | pass |
|---|
| 124 | { |
|---|
| 125 | lighting off |
|---|
| 126 | // Really basic vertex program |
|---|
| 127 | // NB we don't use fixed function here because GL does not like |
|---|
| 128 | // mixing fixed function and vertex programs, depth fighting can |
|---|
| 129 | // be an issue |
|---|
| 130 | vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture |
|---|
| 131 | { |
|---|
| 132 | param_named_auto worldViewProj worldviewproj_matrix |
|---|
| 133 | param_named ambient float4 1 1 1 1 |
|---|
| 134 | } |
|---|
| 135 | scene_blend dest_colour zero |
|---|
| 136 | texture_unit |
|---|
| 137 | { |
|---|
| 138 | texture rock.tga |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | } |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | // This is the fallback which cards which don't have fragment program |
|---|
| 145 | // support will use, NB does not support specular colour |
|---|
| 146 | // Note that it still requires vertex program support |
|---|
| 147 | technique |
|---|
| 148 | { |
|---|
| 149 | // Base ambient pass |
|---|
| 150 | pass |
|---|
| 151 | { |
|---|
| 152 | // base colours, not needed for rendering, but as information |
|---|
| 153 | // to lighting pass categorisation routine |
|---|
| 154 | ambient 1 1 1 |
|---|
| 155 | diffuse 0 0 0 |
|---|
| 156 | specular 0 0 0 0 |
|---|
| 157 | // Really basic vertex program |
|---|
| 158 | // NB we don't use fixed function here because GL does not like |
|---|
| 159 | // mixing fixed function and vertex programs, depth fighting can |
|---|
| 160 | // be an issue |
|---|
| 161 | vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture |
|---|
| 162 | { |
|---|
| 163 | param_named_auto worldViewProj worldviewproj_matrix |
|---|
| 164 | param_named_auto ambient ambient_light_colour |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | } |
|---|
| 168 | // Now do the lighting pass |
|---|
| 169 | // NB we don't do decal texture here because this is repeated per light |
|---|
| 170 | pass |
|---|
| 171 | { |
|---|
| 172 | // base colours, not needed for rendering, but as information |
|---|
| 173 | // to lighting pass categorisation routine |
|---|
| 174 | ambient 0 0 0 |
|---|
| 175 | // do this for each light |
|---|
| 176 | iteration once_per_light |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | scene_blend add |
|---|
| 180 | |
|---|
| 181 | // Vertex program reference |
|---|
| 182 | vertex_program_ref BumpMapVP |
|---|
| 183 | { |
|---|
| 184 | param_named_auto lightPosition light_position_object_space 0 |
|---|
| 185 | param_named_auto worldViewProj worldviewproj_matrix |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | // Base bump map |
|---|
| 189 | texture_unit |
|---|
| 190 | { |
|---|
| 191 | texture NMrock.tga |
|---|
| 192 | colour_op replace |
|---|
| 193 | } |
|---|
| 194 | // Normalisation cube map, with dot product on bump map |
|---|
| 195 | texture_unit |
|---|
| 196 | { |
|---|
| 197 | cubic_texture nm.tga combinedUVW |
|---|
| 198 | tex_coord_set 1 |
|---|
| 199 | tex_address_mode clamp |
|---|
| 200 | colour_op_ex dotproduct src_texture src_current |
|---|
| 201 | colour_op_multipass_fallback dest_colour zero |
|---|
| 202 | } |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | // Decal pass |
|---|
| 206 | pass |
|---|
| 207 | { |
|---|
| 208 | lighting off |
|---|
| 209 | // Really basic vertex program |
|---|
| 210 | // NB we don't use fixed function here because GL does not like |
|---|
| 211 | // mixing fixed function and vertex programs, depth fighting can |
|---|
| 212 | // be an issue |
|---|
| 213 | vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture |
|---|
| 214 | { |
|---|
| 215 | param_named_auto worldViewProj worldviewproj_matrix |
|---|
| 216 | param_named ambient float4 1 1 1 1 |
|---|
| 217 | } |
|---|
| 218 | scene_blend dest_colour zero |
|---|
| 219 | texture_unit |
|---|
| 220 | { |
|---|
| 221 | texture rock.tga |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | } |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | |
|---|