Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 5 and Version 6 of content/BumpMapping


Ignore:
Timestamp:
Dec 5, 2018, 10:27:14 AM (5 years ago)
Author:
wiesep
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • content/BumpMapping

    v5 v6  
    4444== Important Notes ==
    4545During the implementation of the bump map functionality the problem of flickering flickering occurred.
     46This could be fixed by inserting the following lines into ever pass.
     47{{{#!cpp
     48 depth_write on
     49 depth_bias 1
     50}}}
     51* Ambient Pass: depth_bias 0
     52* Lightning Pass: depth_bias 1
     53* Decal Pass: depth_bias 2
    4654
     55[[Image(Flickering.png, 200px)]] 
    4756
    4857== Screenshot ==
    49 {{{#!imagebox
     58{{{#!rbox align=center)
    5059[[Image(bumpMap.png, 800px, align=center)]] 
    5160L: Bump map only, M: Bump map with texture, R: Normal texture
    5261}}}
    5362
     63== Source ==
     64[[CollapsibleStart(Base Material)]]
     65{{{#!cpp
     66// Any number of lights, diffuse
     67material BumpMap_Base
     68{
     69    technique
     70    {
     71        // Base ambient pass
     72        pass ambient
     73        {
     74          // base colours, not needed for rendering, but as information
     75          // to lighting pass categorisation routine
     76          diffuse 0 0 0
     77          depth_write on
     78          depth_bias 0
    5479
     80        }
     81        // Now do the lighting pass
     82        // NB we don't do decal texture here because this is repeated per light
     83        pass perlight
     84        {
     85
     86            // do this for each light
     87            iteration once_per_light
     88            scene_blend add
     89            depth_write on
     90            depth_bias 1
     91
     92            // base colours, not needed for rendering, but as information
     93            // to lighting pass categorisation routine
     94            ambient 0 0 0
     95
     96            // Vertex program reference
     97            vertex_program_ref BumpMapping/BumpMapVP
     98            {
     99                param_named_auto lightPosition light_position_object_space 0
     100                param_named_auto worldViewProj worldviewproj_matrix
     101            }
     102
     103            // Fragment program
     104            fragment_program_ref BumpMapping/BumpMapFP
     105            {
     106                param_named_auto lightDiffuse light_diffuse_colour 0
     107            }
     108
     109            // texture shadow receiver program
     110            shadow_receiver_vertex_program_ref BumpMapping/BumpMapVPShadowRcv
     111            {
     112                param_named_auto lightPosition light_position_object_space 0
     113                param_named_auto worldViewProj worldviewproj_matrix
     114                param_named_auto worldMatrix world_matrix
     115                param_named_auto texViewProj texture_viewproj_matrix
     116            }
     117            // Additive texture shadow receiver program
     118            shadow_receiver_fragment_program_ref BumpMapping/BumpMapFPShadowRcv
     119            {
     120                param_named_auto lightDiffuse light_diffuse_colour 0
     121            }
     122
     123            // Vertex program reference
     124            vertex_program_ref BumpMapping/BumpMapVPSpecular
     125            {
     126                param_named_auto lightPosition light_position_object_space 0
     127                param_named_auto eyePosition camera_position_object_space
     128                param_named_auto worldViewProj worldviewproj_matrix
     129            }
     130
     131            // Fragment program
     132            fragment_program_ref BumpMapping/BumpMapFPSpecular
     133            {
     134                param_named_auto lightDiffuse light_diffuse_colour 0
     135                param_named_auto lightSpecular light_specular_colour 0
     136            }
     137
     138
     139            // Base bump map
     140            texture_unit normalmap
     141            {
     142                texture Cube_Lava_NORM.jpg
     143                colour_op replace
     144            }
     145        }
     146
     147        // Decal pass
     148        pass decal
     149        {
     150            // base colours, not needed for rendering, but as information
     151            // to lighting pass categorisation routine
     152            lighting off
     153            depth_write on
     154            depth_bias 2
     155
     156            scene_blend dest_colour zero
     157            texture_unit decalmap
     158            {
     159                texture Cube_Lava_COLOR.jpg
     160            }
     161        }
     162    }
     163}
     164}}}
     165[[CollapsibleEnd]]