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

PlanarReflections rendering bug with two-sided lighting #369

Open
jwwalker opened this issue Apr 11, 2023 · 4 comments
Open

PlanarReflections rendering bug with two-sided lighting #369

jwwalker opened this issue Apr 11, 2023 · 4 comments
Labels
bug Something isn't working Priority: Normal

Comments

@jwwalker
Copy link
Contributor

System Information

  • Ogre Version: master branch, revision c1c24ca (April 9)
  • Operating System / Platform: macOS 13.3.1
  • RenderSystem: Metal
  • GPU: AMD Radeon Pro 960X

Detailed description

When the PlanarRelections library mirrors objects with a Pbs data blocks set to use two-sided lighting, the reflections look wrong. This is especially obvious when using unlit mirrors.

Steps to reproduce:

  • Change the code body of HlmsPbs::createDatablockImpl in OgreHlmsPbs.cpp to say:
	HlmsPbsDatablock* block = OGRE_NEW HlmsPbsDatablock( datablockName, this,
		macroblock, blendblock, paramVec );
	block->setTwoSidedLighting( true, false );
	return block;
  • Recompile the HlmsPbs library.
  • Build and run Sample_PlanarReflections.

Screenshot 2023-04-11 at 3 23 38 PM

Ogre.log

15:42:22: Creating resource group General
15:42:22: Creating resource group Internal
15:42:22: Creating resource group Autodetect
15:42:22: SceneManagerFactory for type 'DefaultSceneManager' registered.
15:42:22: Registering ResourceManager for type Material
15:42:22: Registering ResourceManager for type Mesh
15:42:22: Registering ResourceManager for type Mesh2
15:42:22: Registering ResourceManager for type OldSkeleton
15:42:22: MovableObjectFactory for type 'ParticleSystem' registered.
15:42:22: ArchiveFactory for archive type FileSystem registered.
15:42:22: ArchiveFactory for archive type Zip registered.
15:42:22: ArchiveFactory for archive type EmbeddedZip registered.
15:42:22: DDS codec registering
15:42:22: FreeImage version: 3.18.0
15:42:22: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
15:42:22: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,psb,cut,xbm,xpm,gif,hdr,g3,sgi,rgb,rgba,bw,exr,j2k,j2c,jp2,pfm,pct,pict,pic,3fr,arw,bay,bmq,cap,cine,cr2,crw,cs1,dc2,dcr,drf,dsc,dng,erf,fff,ia,iiq,k25,kc2,kdc,mdc,mef,mos,mrw,nef,nrw,orf,pef,ptx,pxn,qtk,raf,raw,rdc,rw2,rwl,rwz,sr2,srf,srw,sti,x3f,webp
15:42:22: OITD codec registering
15:42:22: Registering ResourceManager for type HighLevelGpuProgram
15:42:22: MovableObjectFactory for type 'Decal' registered.
15:42:22: MovableObjectFactory for type 'InternalCubemapProbe' registered.
15:42:22: MovableObjectFactory for type 'Entity' registered.
15:42:22: MovableObjectFactory for type 'Item' registered.
15:42:22: MovableObjectFactory for type 'Light' registered.
15:42:22: MovableObjectFactory for type 'Rectangle2Dv2' registered.
15:42:22: MovableObjectFactory for type 'BillboardSet' registered.
15:42:22: MovableObjectFactory for type 'ManualObject2' registered.
15:42:22: MovableObjectFactory for type 'BillboardChain' registered.
15:42:22: MovableObjectFactory for type 'RibbonTrail' registered.
15:42:22: MovableObjectFactory for type 'WireAabb' registered.
15:42:22: Loading library RenderSystem_Metal
15:42:22: Installing plugin: Metal RenderSystem
15:42:22: Metal: Devices Detection Starts
15:42:22: Metal: "AMD Radeon Pro 560X"
15:42:22: Metal: "Intel(R) UHD Graphics 630"
15:42:22: Metal: Devices Detection Ends
15:42:22: Plugin successfully installed
15:42:22: Loading library Plugin_ParticleFX
15:42:22: Installing plugin: ParticleFX
15:42:22: Particle Emitter Type 'Point' registered
15:42:22: Particle Emitter Type 'Box' registered
15:42:22: Particle Emitter Type 'Ellipsoid' registered
15:42:22: Particle Emitter Type 'Cylinder' registered
15:42:22: Particle Emitter Type 'Ring' registered
15:42:22: Particle Emitter Type 'HollowEllipsoid' registered
15:42:22: Particle Affector Type 'LinearForce' registered
15:42:22: Particle Affector Type 'ColourFader' registered
15:42:22: Particle Affector Type 'ColourFader2' registered
15:42:22: Particle Affector Type 'ColourImage' registered
15:42:22: Particle Affector Type 'ColourInterpolator' registered
15:42:22: Particle Affector Type 'ScaleInterpolator' registered
15:42:22: Particle Affector Type 'Scaler' registered
15:42:22: Particle Affector Type 'Rotator' registered
15:42:22: Particle Affector Type 'DirectionRandomiser' registered
15:42:22: Particle Affector Type 'DeflectorPlane' registered
15:42:22: Plugin successfully installed
15:42:22: *-*-* OGRE Initialising
15:42:22: *-*-* Version 3.0.0unstable (E)
15:42:25: CPU Identifier & Features
15:42:25: -------------------------
15:42:25:  *   CPU ID: GenuineIntel: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
15:42:25:  *   Logical cores: 12
15:42:25:  *      SSE: yes
15:42:25:  *     SSE2: yes
15:42:25:  *     SSE3: yes
15:42:25:  *      MMX: yes
15:42:25:  *   MMXEXT: yes
15:42:25:  *    3DNOW: no
15:42:25:  * 3DNOWEXT: no
15:42:25:  *     CMOV: yes
15:42:25:  *      TSC: yes
15:42:25:  *      FPU: yes
15:42:25:  *      PRO: yes
15:42:25:  *       HT: no
15:42:25: -------------------------
15:42:25: Metal: Devices Detection Starts
15:42:25: Metal: "AMD Radeon Pro 560X"
15:42:25: Metal: "Intel(R) UHD Graphics 630"
15:42:25: Metal: Devices Detection Ends
15:42:25: Metal: Requested "AMD Radeon Pro 560X", selected "AMD Radeon Pro 560X"
15:42:25: Supports: OSX_GPUFamily1_v1
15:42:25: Registering ResourceManager for type GpuProgram
15:42:25: DefaultWorkQueue('Root') initialising on thread main.
15:42:25: Particle Renderer Type 'billboard' registered
15:42:25: OverlayElementFactory for type Panel registered.
15:42:25: OverlayElementFactory for type BorderPanel registered.
15:42:25: OverlayElementFactory for type TextArea registered.
15:42:25: Registering ResourceManager for type Font
15:42:25: Creating resource group Essential
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/DebugPack.zip' of type 'Zip' to resource group 'Essential'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/CornellBox.zip' of type 'Zip' to resource group 'Essential'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/materials/Common' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/materials/Common/Any' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/materials/Common/GLSL' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/materials/Common/GLSLES' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/materials/Common/HLSL' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/materials/Common/Metal' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/Hlms/Common/Any' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/Hlms/Common/GLSL' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/Hlms/Common/HLSL' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/Hlms/Common/Metal' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/Compute/Algorithms/IBL' of type 'FileSystem' to resource group 'General'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/Compute/Tools/Any' of type 'FileSystem' to resource group 'General'
15:42:25: Creating resource group Popular
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/Compositors' of type 'FileSystem' to resource group 'Popular'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/models' of type 'FileSystem' to resource group 'Popular'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/textures' of type 'FileSystem' to resource group 'Popular'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/textures/Cubemaps' of type 'FileSystem' to resource group 'Popular'
15:42:25: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build4/bin/Debug/Sample_PlanarReflections.app/Contents/Resources/2.0/scripts/materials/PlanarReflections' of type 'FileSystem' to resource group 'General'
15:42:25: Loading HlmsDiskCache from hlmsDiskCache1.bin
15:42:25: Applying HlmsDiskCache 1
15:42:25: Shader 100000000VertexShader_vs compiled successfully.
15:42:25: Shader 100000001VertexShader_vs compiled successfully.
15:42:25: Shader 100000002VertexShader_vs compiled successfully.
15:42:25: Shader 100000002PixelShader_ps compiled successfully.
15:42:25: Shader 100000003VertexShader_vs compiled successfully.
15:42:25: Shader 100000003PixelShader_ps compiled successfully.
15:42:25: Shader 100000004VertexShader_vs compiled successfully.
15:42:25: Shader 100000004PixelShader_ps compiled successfully.
15:42:25: Shader 100000005VertexShader_vs compiled successfully.
15:42:25: Shader 100000005PixelShader_ps compiled successfully.
15:42:25: Shader 100000006VertexShader_vs compiled successfully.
15:42:25: Shader 100000006PixelShader_ps compiled successfully.
15:42:25: Shader 100000007VertexShader_vs compiled successfully.
15:42:25: Shader 100000007PixelShader_ps compiled successfully.
15:42:25: Shader 100000008VertexShader_vs compiled successfully.
15:42:25: Shader 100000008PixelShader_ps compiled successfully.
15:42:25: Shader 100000009VertexShader_vs compiled successfully.
15:42:25: Shader 100000009PixelShader_ps compiled successfully.
15:42:25: Shader 100000010VertexShader_vs compiled successfully.
15:42:25: Shader 100000010PixelShader_ps compiled successfully.
15:42:25: Shader 100000011VertexShader_vs compiled successfully.
15:42:25: Shader 100000011PixelShader_ps compiled successfully.
15:42:25: Loading HlmsDiskCache from hlmsDiskCache3.bin
15:42:25: Applying HlmsDiskCache 3
15:42:25: Shader 300000000VertexShader_vs compiled successfully.
15:42:25: Shader 300000001VertexShader_vs compiled successfully.
15:42:25: Shader 300000002VertexShader_vs compiled successfully.
15:42:25: Shader 300000002PixelShader_ps compiled successfully.
15:42:25: Shader 300000003VertexShader_vs compiled successfully.
15:42:25: Shader 300000003PixelShader_ps compiled successfully.
15:42:25: Parsing scripts for resource group Autodetect
15:42:25: Finished parsing scripts for resource group Autodetect
15:42:25: Creating resources for group Autodetect
15:42:25: All done
15:42:25: Parsing scripts for resource group Essential
15:42:25: Parsing script Materials.material
15:42:25: Parsing script CornellBox.material.json
15:42:25: Parsing script DebugFont.fontdef
15:42:25: Finished parsing scripts for resource group Essential
15:42:25: Creating resources for group Essential
15:42:25: All done
15:42:25: Parsing scripts for resource group General
15:42:25: Parsing script Quad.program
15:42:25: Shader Ogre/Compositor/Quad_vs_Metal compiled successfully.
15:42:25: Shader Ogre/Compositor/QuadCameraDir_vs_Metal compiled successfully.
15:42:25: Shader Ogre/Compositor/QuadCameraDirNoUV_vs_Metal compiled successfully.
15:42:25: Parsing script HiddenAreaMeshVr.material
15:42:25: Shader Ogre/VR/HiddenAreaMeshVr_vs_Metal compiled successfully.
15:42:25: Shader Ogre/VR/HiddenAreaMeshVr_ps_Metal compiled successfully.
15:42:25: Parsing script EsmGaussianBlurLogFilter.material
15:42:25: Shader ESM/GaussianLogFilterH_ps_Metal compiled successfully.
15:42:25: Shader ESM/GaussianLogFilterV_ps_Metal compiled successfully.
15:42:25: Parsing script RadialDensityMask.material
15:42:25: Shader Ogre/Compositor/RadialDensityMask_vs_Metal compiled successfully.
15:42:25: Shader Ogre/VR/RadialDensityMask_ps_Metal compiled successfully.
15:42:25: Parsing script DPSM.material
15:42:25: Shader Ogre/DPSM/CubeToDpsm_ps_Metal compiled successfully.
15:42:25: Shader Ogre/DPSM/CubeToDpsm_Colour_ps_Metal compiled successfully.
15:42:25: Parsing script Atmosphere.material
15:42:25: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource metal_stdlib in resource group General or any other group. in ResourceGroupManager::openResource at /Volumes/Work/git-repos/ogre-next-fork/OgreMain/src/OgreResourceGroupManager.cpp (line 737)
15:42:25: Shader Ogre/Atmo/NprSky_ps_Metal compiled successfully.
15:42:25: Parsing script DPM.material
15:42:25: Shader Ogre/DPM/CubeToDpm_4xFP16_ps_Metal compiled successfully.
15:42:25: Parsing script PccDepthCompressor.material
15:42:25: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource metal_stdlib in resource group General or any other group. in ResourceGroupManager::openResource at /Volumes/Work/git-repos/ogre-next-fork/OgreMain/src/OgreResourceGroupManager.cpp (line 737)
15:42:25: Shader PccDepthCompressor_ps_Metal compiled successfully.
15:42:25: Parsing script DepthUtils.material
15:42:25: Shader Ogre/Depth/DownscaleMax_ps_Metal compiled successfully.
15:42:25: Parsing script Sky.material
15:42:25: Shader Ogre/Sky/Cubemap_ps_Metal compiled successfully.
15:42:25: Shader Ogre/Sky/Equirectangular_ps_Metal compiled successfully.
15:42:25: Parsing script Copyback.material
15:42:25: Shader Ogre/Copy/4xFP32_ps_Metal compiled successfully.
15:42:25: Shader Ogre/Copy/4xFP32_2DArray_ps_Metal compiled successfully.
15:42:25: Shader Ogre/Copy/1xFP32_ps_Metal compiled successfully.
15:42:25: Shader Ogre/Resolve/1xFP32_Subsample0_ps_Metal compiled successfully.
15:42:25: Parsing script PlanarReflections.material
15:42:25: Parsing script EsmGaussianBlurLogFilter.material.json
15:42:25: Parsing script Mipmaps.material.json
15:42:25: Parsing script IBL.material.json
15:42:25: Finished parsing scripts for resource group General
15:42:25: Creating resources for group General
15:42:25: All done
15:42:25: Parsing scripts for resource group Internal
15:42:25: Finished parsing scripts for resource group Internal
15:42:25: Creating resources for group Internal
15:42:25: All done
15:42:25: Parsing scripts for resource group Popular
15:42:25: Parsing script LocalCubemaps.compositor
15:42:25: Parsing script StencilTest.compositor
15:42:25: Parsing script TutorialUav02_Setup.compositor
15:42:25: Parsing script StereoRendering.compositor
15:42:25: Parsing script ScreenSpaceReflections.compositor
15:42:25: Parsing script StaticShadowMaps.compositor
15:42:25: Parsing script UvBaking.compositor
15:42:25: Parsing script ShadowMapDebugging.compositor
15:42:25: Parsing script Refractions.compositor
15:42:25: Parsing script Tutorial_DynamicCubemap.compositor
15:42:25: Parsing script IrradianceFieldRaster.compositor
15:42:25: Parsing script PbsMaterials.compositor
15:42:25: Parsing script Tutorial_Terrain.compositor
15:42:25: Parsing script InstancedStereo.compositor
15:42:25: Parsing script Tutorial_OpenVRWorkspace.compositor
15:42:25: Parsing script TutorialUav01_Setup.compositor
15:42:25: Parsing script TutorialSky_Postprocess.compositor
15:42:25: Parsing script Tutorial_ReconstructPosFromDepth.compositor
15:42:25: Parsing script PlanarReflections.compositor
15:42:25: Finished parsing scripts for resource group Popular
15:42:25: Creating resources for group Popular
15:42:25: All done
15:42:25: Mesh: Loading Cube_d.mesh.
15:42:25: WARNING: Cube_d.mesh is an older format ([MeshSerializer_v2.1 R1]); you should upgrade it as soon as possible using the OgreMeshTool tool.
15:42:25: Shader 0GaussianBlurBase_cs compiled successfully.
15:42:25: Shader 1GaussianBlurBase_cs compiled successfully.
15:42:25: Font DebugFont using texture size 512x512
15:42:25: Info: Freetype returned null for character 127 in font DebugFont
15:42:25: Info: Freetype returned null for character 128 in font DebugFont
15:42:25: Info: Freetype returned null for character 129 in font DebugFont
15:42:25: Info: Freetype returned null for character 130 in font DebugFont
15:42:25: Info: Freetype returned null for character 131 in font DebugFont
15:42:25: Info: Freetype returned null for character 132 in font DebugFont
15:42:25: Info: Freetype returned null for character 133 in font DebugFont
15:42:25: Info: Freetype returned null for character 134 in font DebugFont
15:42:25: Info: Freetype returned null for character 135 in font DebugFont
15:42:25: Info: Freetype returned null for character 136 in font DebugFont
15:42:25: Info: Freetype returned null for character 137 in font DebugFont
15:42:25: Info: Freetype returned null for character 138 in font DebugFont
15:42:25: Info: Freetype returned null for character 139 in font DebugFont
15:42:25: Info: Freetype returned null for character 140 in font DebugFont
15:42:25: Info: Freetype returned null for character 141 in font DebugFont
15:42:25: Info: Freetype returned null for character 142 in font DebugFont
15:42:25: Info: Freetype returned null for character 143 in font DebugFont
15:42:25: Info: Freetype returned null for character 144 in font DebugFont
15:42:25: Info: Freetype returned null for character 145 in font DebugFont
15:42:25: Info: Freetype returned null for character 146 in font DebugFont
15:42:25: Info: Freetype returned null for character 147 in font DebugFont
15:42:25: Info: Freetype returned null for character 148 in font DebugFont
15:42:25: Info: Freetype returned null for character 149 in font DebugFont
15:42:25: Info: Freetype returned null for character 150 in font DebugFont
15:42:25: Info: Freetype returned null for character 151 in font DebugFont
15:42:25: Info: Freetype returned null for character 152 in font DebugFont
15:42:25: Info: Freetype returned null for character 153 in font DebugFont
15:42:25: Info: Freetype returned null for character 154 in font DebugFont
15:42:25: Info: Freetype returned null for character 155 in font DebugFont
15:42:25: Info: Freetype returned null for character 156 in font DebugFont
15:42:25: Info: Freetype returned null for character 157 in font DebugFont
15:42:25: Info: Freetype returned null for character 158 in font DebugFont
15:42:25: Info: Freetype returned null for character 159 in font DebugFont
15:42:25: Info: Freetype returned null for character 160 in font DebugFont
15:42:29: Saving HlmsDiskCache to hlmsDiskCache1.bin
15:42:29: Saving HlmsDiskCache to hlmsDiskCache3.bin
15:42:29: Unregistering ResourceManager for type Font
15:42:29: DefaultWorkQueue('Root') shutting down on thread main.
15:42:29: *-*-* OGRE Shutdown
15:42:29: Unregistering ResourceManager for type OldSkeleton
15:42:29: Unregistering ResourceManager for type Mesh2
15:42:29: Unregistering ResourceManager for type Mesh
15:42:29: Unregistering ResourceManager for type Material
15:42:29: Unregistering ResourceManager for type HighLevelGpuProgram
15:42:29: Uninstalling plugin: ParticleFX
15:42:29: Plugin successfully uninstalled
15:42:29: Unloading library Plugin_ParticleFX
15:42:29: Uninstalling plugin: Metal RenderSystem
15:42:29: Unregistering ResourceManager for type GpuProgram
15:42:29: Plugin successfully uninstalled
15:42:29: Unloading library RenderSystem_Metal

-->

@darksylinc darksylinc added bug Something isn't working Priority: Normal labels Apr 11, 2023
@jwwalker
Copy link
Contributor Author

@darksylinc I have what I think is a fix for this, but I'm not sure I understand enough to make a PR. My idea is that instead of using an orientation-reversing camera for the reflection, do a horizontal flip at the shader level. More specifically:

In Math::makeViewMatrix, flip the signs in the top row:

        // Deal with reflections
        if( reflectMatrix )
        {
            viewMatrix = viewMatrix * ( *reflectMatrix );
            viewMatrix[0][0] *= -1.0f;
            viewMatrix[0][1] *= -1.0f;
            viewMatrix[0][2] *= -1.0f;
            viewMatrix[0][3] *= -1.0f;
        }

(There's probably a slicker way to express that.)

And in Hlms/Unlit/Any/800.PixelShader_piece_ps.any, when handling the property diffuse_map@n_reflection, replace

#define DiffuseUV@n gl_FragCoord.xy * passBuf.invWindowSize.xy

by

#define DiffuseUV@n float2( 1.0-gl_FragCoord.x * passBuf.invWindowSize.x, gl_FragCoord.y * passBuf.invWindowSize.y )

and replace

#define DiffuseUV@n float2( gl_FragCoord.x * passBuf.invWindowSize.x, 1.0f - gl_FragCoord.y * passBuf.invWindowSize.y )

by

#define DiffuseUV@n float2( 1.0-gl_FragCoord.x * passBuf.invWindowSize.x, 1.0f - gl_FragCoord.y * passBuf.invWindowSize.y )

An incomplete part is that in Hlms/Unlit/GLSLES/BlendModes_piece_ps.glsl, there is another reference to diffuse_map@n_reflection, and I don't know what that's about.

@jwwalker
Copy link
Contributor Author

I spoke too soon. The changes I outlined produce a better result for two-sided lighting, but a worse result for reflections of one-sided things.

@jwwalker
Copy link
Contributor Author

@darksylinc My current best attempt at getting the mirror image to look right for both 2-sided and 1-sided meshes is, besides the changes outlined above, to change SceneManager:: _cullPhase01 so that it never calls setInvertVertexWinding.

@jwwalker
Copy link
Contributor Author

The changes I've outlined above give good results for unlit mirrors, but break reflections in lit mirrors, and I don't know why. But for my personal purposes, unlit mirrors probably suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority: Normal
Projects
None yet
Development

No branches or pull requests

2 participants