Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

预滤波HDR环境贴图 #7

Open
TOMBrian881 opened this issue Sep 27, 2024 · 2 comments
Open

预滤波HDR环境贴图 #7

TOMBrian881 opened this issue Sep 27, 2024 · 2 comments

Comments

@TOMBrian881
Copy link

您好,目前我发现镜面IBL中的预滤波HDR环境贴图并非是根据粗糙度生成的mipMap图,这导致了对于不同粗糙度的镜面反射都一样
image
可以从上面的图片看到,铁桶上方锈迹斑斑的地方反射也很强

 // Prefilter
osg::ref_ptr<osg::Image> img1 = new osg::Image;
{
    osg::Shader* fs = osgDB::readShaderFile(
        osg::Shader::FRAGMENT, SHADER_DIR "std_environment_prefiltering.frag.glsl");
    osgVerse::Pipeline::createShaderDefinitions(fs, 100, 130);
    img1->allocateImage(w, h, 1, GL_RGB, GL_UNSIGNED_BYTE);
    img1->setInternalTextureFormat(GL_RGB8);

    osg::ref_ptr<osg::Program> prog = new osg::Program;
    prog->addShader(vs); prog->addShader(fs);
    cam1 = createRTTCameraForImage(osg::Camera::COLOR_BUFFER, img1.get(), true);
    cam1->getOrCreateStateSet()->setAttributeAndModes(
        prog.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
    cam1->getOrCreateStateSet()->setTextureAttributeAndModes(0, hdrMap.get());
    cam1->getOrCreateStateSet()->addUniform(new osg::Uniform("EnvironmentMap", (int)0));
    cam1->getOrCreateStateSet()->addUniform(new osg::Uniform("GlobalRoughness", 4.0f));
}
@TOMBrian881
Copy link
Author

TOMBrian881 commented Sep 27, 2024

同样的模型在filament的渲染结果
image

@xarray
Copy link
Owner

xarray commented Sep 28, 2024

您好,非常感谢。我会检查一下生成数据的程序,有可能是没有正确使用texLod函数。如果您能帮忙找到问题所在并提交pull request,那就再感谢不过了~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants