I'm currently using a GPU shader to generate a texture. I want to be able to capture the output of this out I'm using Graphics.Blit to output the shaders result to a
RenderTexture(GPU Memory) and then using
Texture2D.ReadPixels(System Memory) to grab the data from the
So far I've got it almost perfect, unfortunately, I'm noticing a significant difference in quality between a plane that uses the shader output directly and a plane that uses the
Texture2D returned from my method and applied to the shared material.
The process of my static method is as follows:
Check if the static material variable is set. If not, create a new instance using the shader and assign it to, the static material variable, otherwise reuse the existing one.
Create a RenderTexture that uses the same width and height scale as the
ARGB32, Linear colorspace and 0 depth buffer.
Set the material keywords and properties based on method input. Call
RenderTexture(from 2) and material (from 1). Create a new Texture2D with the same dimensions as the render texture,
ARGB32and using linear colour space.
GetPixels()on the above
Texture2Dwith parameters, of a new Rect of
(0,0)and render texture dimensions and 0 for offsets.
Texture2Dand return it. I then use a simple editor script for the class that adds a button to call the above static function and then apply the output to the material of the object the script is on.
I don't know what's causing the quality loss, I've added a screenshot of what I'm currently getting below. The left plane is steps detailed above and the right plane is with the shader applied directly to a plane. Both use the same shader properties and keywords.
I don't normally post questions but I've tried everything I can think of to get the quality of texture to match the shader output. I'm wondering if I'm misunderstanding something about how the shader works or if it's a formatting issue. Any ideas are appreciated, thanks.