Open Robadob opened 6 years ago
Dynamic environment mapping now implemented in branch.
BasicScene
MultiPassScene
Entity
dynamic env maps continue to work after reloadModel
dynamic env maps continue to work after reloadBasicScene
to Blit the skybox instead of render?
material_phong.frag
)Fixed the deer lighting issue on latest commit.
Fixed Bob model default shader reload bug, might not track custom textures but this isn't something I've really tested on Model's yet anyway (do they even support it??).
This appears to have a clear example of using Fresnels law for localised reflection.
uniform float Kr, // intensity of reflection
uniform float KrMin, // typical: 0.05 * Kr
uniform float FresExp, // typical: 5.0
float3 Nu = normalize(IN.LightingNormal);
float3 Vu = normalize(IN.LightingEyeVec);
float vdn = dot(Vu, Nb); // or "Nu" if unbumped - see text
float fres = KrMin + (Kr - KrMin) * pow((1.0 - abs(vdn)), FresExp);
float3 reflVect = normalize(reflect(Vu, Nb)); // yes, normalize
// now use the new intersection location as the 3D direction
reflColor = fres * texCUBE(EnvMap, reflVect);
float4 result = SurfColor * reflColor;
More: https://chetanjags.wordpress.com/2015/08/26/image-based-lighting/ https://learnopengl.com/PBR/IBL/Specular-IBL
This follows on from Materials/Lighting. Hopefully a quick branch for some nice resulting visuals.
https://learnopengl.com/Advanced-OpenGL/Cubemaps (high level pure reflection example + refraction) https://en.wikibooks.org/wiki/GLSL_Programming/GLUT/Glossy_Textures (Introduced shininessStrength, as a multiplier for level of glossiness, encoded in alpha channel of texture).
To access reflection sample we use
Alternatively, replace
reflect()
withrefract()
to simulate light moving through materials of different light properties. Utilising the refractive index. This makes models appear transparent, rather than reflective/glossy. Refraction should actually occur twice (as the light exits the material too), however this is harder to achieve within complex models.More@wikipedia
Ratio is calculated as source/destination.
Need to find more info on doing dynamic cubemaps, seen suggestion that rendering over a static skybox gives fastest results. Try this, although I can't see from their example how/if view matrix is transformed. Otherwise seems sensible. Another attempt here.