- Home /
clones bugging with Shader Offset command?
If you copy and paste 2 planes with a shader "Offset" value (to prevent coplanar pixel jumbling) they have artefacts, same if you clone them, but if you import them both separately through the "browser>GameObject>Create" and give them the same shader the offset works great. So for example you couldn't clone posters on a wall, windows on a house, etc.
I also tried Setting the offset value during clone instantiation, it didn't solve it:
InstantiateObject.renderer.material.mainTextureOffset = Vector2(-8,-6);
Here is the shader code that only works in manually placed objects, but fails when you copy the same objects into a shared space.
Pass {
Cull Front
Offset -8,-8
SetTexture [_MainTex] {
Combine Primary * Texture
}
if you test this out, Artefacting is always apparent if the 2 plane objects are rotated like cards. why dont clones take pixel offset commands? do i have to force a "deep copy" in JS:
panel.renderer.material.mainTexure = Instantiate (panel.renderer.material.mainTexture) as Texture2D;
Answer by Mortennobel · Jul 24, 2011 at 09:19 AM
I think you are mixing two different offset.
The offset in the shader code moves the geometry towards the camera to prevent z-fightling
The mainTextureOffset is a UV-mapping offset.
Checkout solutions for z-fighting in the following answer:
http://answers.unity3d.com/questions/27519/z-fighting-problem.html
Thanks $$anonymous$$orten! The ShaderLab "offset" command also doesn't work with clones and copies, because i have been searching for a solution for more than 24 hours now and i tried everything i can amateurishly think of. if you make clones using a shaderlab code with offset -10,-10 etc, it doesnt solve the z fighting at all!
But isn't your problem in the picture that you use the same offset on both shaders? To me it looks like it is the same material and shader (I'm guessing here). Besides it is a mystery to me why you are using a offset factor of -8 and not 0? (I have only found Offset 0,-1 useful)
That is what i also presumed: Same offset value and shader on 2 objects would make artefacts... However, the same offset value works fine when 2 objects are created in browser and set to same shader, i tried it, but if i copy-paste/clone the same plane the offset solution suddenly is ineffective.
here is jessy demonstrating the advantage of the -8,-8 setting compared to 0,-1 http://www.youtube.com/watch?v=$$anonymous$$lLvQxZv3h4
I will attempt a clear demo of the bug.
Your answer
Follow this Question
Related Questions
How to apply offset to touch position when dragging object 4 Answers
Play(offsetInSamples) acuracy - still cannot get it to work perfectly 5 Answers
SetTextureOffset, small offset skip? 1 Answer
How to make a plane with a texture flicker, as if it was animated? 1 Answer
Shader CG not taking tiling into account 2 Answers