Hmm I figured it should be possible but for some reason I can’t seem to be able to (the material doesn’t compile), do I need to add an include or something like that?
Otherwise I must have done something wrong.
If that is ordinary material you are using, you can paste your function or add an include to MaterialTemplate.usf
for PostProcess material it is PostProcessCommon.usf
Both worked fine for me in the past. In any case, you can always do Window-> HLSL code in material editor to view what includes are relevant for your shader.
Please note, that after editing those USF files, you will need to recompile the shaders, as described here
Internally the engine uses something called HZB occlusion to generate the mips. That code is the HZB setup mips code. I am not sure how you would go about reading the mips from that but if you delve around the HZB code maybe you will find something.
Also, re: why can opaque materials read from scene color? They can’t, themselves. All materials in the scene do it at once (thanks to deferred) and there is some cost to making the scene texture available to do that. Actually when you read scene color in translucent materials it stores a separate copy for each mesh in the world that uses it so its pretty inefficient. It can’t be accessed during the base pass unfortunately without engine code changes. I am not sure what the performance implications would be but they would not be good.
I took a brief look at that but as far as I can tell that would require changes in the engine side to expose to materials (which is not an option, I want to be able to share this as a material or a plugin… not an engine branch :p).
Is there any chance we can add a feature request for this maybe :p? probably not eh