Ignore:
Timestamp:
10/19/08 23:42:15 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3041 r3045  
    33{ 
    44  float4 position: POSITION; 
    5   float3 normal: NORMAL; 
     5  float4 normal: NORMAL; 
    66  float4 color: COLOR0; 
    77  float4 texCoord: TEXCOORD0; 
     
    1717        float4 color: COLOR0;   
    1818        float4 eyePos: TEXCOORD1; // eye position 
    19         float3 normal: TEXCOORD2; 
     19        float4 normal: TEXCOORD2; 
    2020}; 
    2121 
     
    3030        float4 winPos: WPOS; 
    3131        float4 eyePos: TEXCOORD1; // eye position 
    32         float3 normal: TEXCOORD2; 
     32        float4 normal: TEXCOORD2; 
    3333}; 
    3434 
     
    5656        OUT.position = mul(glstate.matrix.mvp, IN.position); 
    5757 
    58         OUT.normal = IN.normal; 
     58        OUT.normal = mul(glstate.matrix.invtrans.modelview[0], IN.normal); 
    5959 
    6060        return OUT; 
     
    6363 
    6464pixel fragtex(fragin IN,  
    65                           uniform sampler2D tex 
     65                          uniform sampler2D tex, 
     66                          uniform float4x4 viewMatrix 
    6667                          ) 
    6768{ 
     
    7677        // hack: use combination of emmisive + diffuse (emmisive used as constant ambient term) 
    7778        pix.col = (glstate.material.emission + glstate.material.diffuse) * texColor;  
    78         // save world space normal in rt 
    79         pix.norm = IN.normal; 
     79        // save world space normal in rt => transform back into world space by 
     80        // multiplying with inverse view. since transforming normal with T means to  
     81        // multiply with the inverse transpose of T, we multiple with Transp(Inv(Inv(view))) = Transp(view) 
     82        pix.norm = mul(transpose(viewMatrix), IN.normal); 
    8083        // compute eye linear depth 
    8184        pix.col.w = length(IN.eyePos.xyz); 
     
    8790 
    8891 
    89 pixel frag(fragin IN) 
     92pixel frag(fragin IN,  uniform float4x4 viewMatrix) 
    9093{ 
    9194        pixel pix; 
    9295        // hack: use comination of emmisive + diffuse (emmisive used as constant ambient term) 
    9396        pix.col = glstate.material.diffuse + glstate.material.emission; 
    94         // save world space normal in rt 
    95         pix.norm = IN.normal; 
     97        // save world space normal in rt => transform back into world space by 
     98        // multiplying with inverse view. since transforming normal with T means to  
     99        // multiply with the inverse transpose of T, we multiple with Transp(Inv(Inv(view))) = Transp(view) 
     100        pix.norm = mul(transpose(viewMatrix), IN.normal); 
    96101        // eye space depth 
    97102        pix.col.w = length(IN.eyePos.xyz); 
Note: See TracChangeset for help on using the changeset viewer.