====== Camera ====== ===== Camera.SetReplacementShader ===== SetReplacementShader will not render objects if their original materials don't contain any properties required by the replacement shader. For example, if your replacement shader uses _MainTex, and there is an object in the scene that doesn't have _MainTex, it won't be rendered at all. SetReplacementShader will use the Materials of the existing objects in the scene((all of the textures and instance data is still sent to the replaced)). However, it only seems to apply keywords that are registered as ''multi_compile''. Per-material keywords registered with ''shader_feature'' do not get applied. For example, if you call SetReplacementShader with the default URP ''Lit.shader'', these keywords will all be turned off: {{:rider64_ulivqdfbym.png}} Shaders can be replaced in the SceneView using ''[[sceneview|SceneView]].SetSceneViewShaderReplace''. ---- ===== Camera.targetTexture ===== According to the Unity Documentation: "When rendering into a texture, the camera always renders into the whole texture; effectively rect and pixelRect are ignored." This behavior is inconsistent across target platforms. On windows, the camera will use the rect and/or pixelRect. On OSX, Android, and iOS, the camera rect will be ignored. (tested on Built-in Render Pipeline, Unity 6000.0.34f1) If you have need to render into a sub-rect on render texture on those platforms, there are workarounds: * For BiRP, using Camera.SetTargetBuffers will render to the target buffers utilizing the rect/pixelRect. (tested on Unity 6000.0.34f1) [[https://discussions.unity.com/t/dynamic-viewport-for-a-camera-rendering-to-a-target-texture/176258|unity discussion]] * For URP/HDRP, a similar effect can be achieved with CommandBuffer.SetViewport and CommandBuffer.EnableScissorRect. (untested) [[https://discussions.unity.com/t/rendering-into-part-of-a-render-texture/636179/39|unity discussion]]