Debuggingh the reflection jittering

This commit is contained in:
samcake 2016-03-31 01:51:26 -07:00
parent cb34847177
commit 10ddecd536
3 changed files with 17 additions and 6 deletions

View file

@ -39,6 +39,7 @@ Column {
"Shadow",
"Pyramid Depth",
"Ambient Occlusion",
"Ambient Occlusion Blurred",
"Custom Shader"
]
RadioButton {

View file

@ -583,7 +583,7 @@ gpu::Texture* TextureUsage::createCubeTextureFromImage(const QImage& srcImage, c
// If the 6 faces have been created go on and define the true Texture
if (faces.size() == gpu::Texture::NUM_FACES_PER_TYPE[gpu::Texture::TEX_CUBE]) {
theTexture = gpu::Texture::createCube(formatGPU, faces[0].width(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR, gpu::Sampler::WRAP_CLAMP));
theTexture = gpu::Texture::createCube(formatGPU, faces[0].width(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR/*, gpu::Sampler::WRAP_CLAMP*/));
theTexture->autoGenerateMips(-1);
int f = 0;
for (auto& face : faces) {

View file

@ -30,7 +30,8 @@ vec4 evalSkyboxLight(vec3 direction, float lod) {
// Transform directions to worldspace
vec3 fragNormal = vec3(invViewMat * vec4(normal, 0.0));
vec3 fragEyeVector = vec3(invViewMat * vec4(-position, 0.0));
// vec3 fragEyeVector = vec3(invViewMat * vec4(-position, 0.0));
vec3 fragEyeVector = vec3(invViewMat * vec4(-normalize(position), 0.0));
vec3 fragEyeDir = normalize(fragEyeVector);
// Get light
@ -90,13 +91,22 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
// Specular highlight from ambient
vec3 direction = -reflect(fragEyeDir, fragNormal);
if (gl_FragCoord.x > 1000)
return 0.5 * direction + vec3(0.5);
float levels = getLightAmbientMapNumMips(light);
float lod = min(floor((roughness) * levels), levels);
vec4 skyboxLight = evalSkyboxLight(direction, lod);
vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1 - roughness);
color += ambientFresnel * skyboxLight.rgb * obscurance * getLightAmbientIntensity(light);
// vec4 skyboxLight = evalSkyboxLight(direction, lod);
vec4 skyboxLight = evalSkyboxLight(direction, levels * 0.5);
return skyboxLight.xyz;
return color;
//vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1 - roughness);
//color += ambientFresnel * skyboxLight.rgb * obscurance * getLightAmbientIntensity(light);
//return color;
}
<@endfunc@>