Posts

Showing posts with the label INTERNAL DATA

CG Surface shader continued - normal maps, world reflection

Below  is code for a reflection map that takes the normal map into account - eg , it obeys all the bumpy bits. Notice - the reflection map is taken in as a CUBE type, in all caps & uses a samplerCUBE type in the subshader variable definition. The Normal map is taken in as a 2D, just like a standard texture map - but in the Properties, we initialise it to "bump".  We use the normal map by calling the UnpackNormal function - this converts the rgb values of the normal map (we get those by using tex2D) into the xyz vectors that the normals need. We're sticking the reflection map into the output Emission for now . World Reflection is actually based on the normal of the object - the polynormals are projected outwards and they hit a cubemap - the colour of the cubemap at this point is then returned as the world reflection - HOWEVER - because we are modifying the normals using our bump/normal map this is gonna get weird. Unity will actually freak out - UNLESS - we add the I...