Some extra notes to clarify:
There are two ways to achieve Displaying a RenderTexture:
Plan A: Use a 3D Quad (MeshRenderer)
- Drag the renderTexuture onto this mesh according to the tutorial instructions.
- And add a light to your scene. Because this texture is used as an albedo for the mesh. Its final color is affected by lighting, if there is no lighting it is black.
Plan B: Use a 2D Square (SpriteRenderer)
- Create a
.shaderfile in yourAssetsdir. And copy the code above into it. - Create a new material and select the shader for it.(
Custom/NewShader) - Drag the renderTexuture file to the material(
_SubTex). - Drag the material to the 2D Square.
- Create a
the preview window displays my sprite fine, but my square is still white in the end.
Because the spriteRenderer is used to display a sprite, it will overwrite the texture of the sprite to the material at runtime. so _MainTex is already used by spriteRenderer. You can not use that.
So we could create a new shader with extra texture paramater(_SubTex) and just ignore _MainTex. It will be fine.
