Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.07k stars 1.15k forks source link

How to modify background shader #621

Closed joondong closed 4 years ago

joondong commented 4 years ago

How to change background shader? I am trying to apply some filter to background of camera streaming. Kind of color filtering. However, whenever I changed Library/PackageCache/com.unity.xr.core@4.0.8/Assets/Shaders/ARCoreBackground.shader it returns to original code.

Can I modify the shader?

How to shake background texture? What I am trying to make is "Camera shake" which is used for bomb explosion. In my AR apps, I need to shake background as well because shaking just rendering camera looks weird.

How to shake background texture for this work?

joondong commented 4 years ago

At 0~1 sec, camera shakes but not background. https://www.youtube.com/watch?v=94wq_2ohrRU&feature=youtu.be

@tdmowrer My bad, I uploaded new one

tdmowrer commented 4 years ago

You can override the material (with a custom shader) instead of directly modifying the one in the package. See my comment here: https://github.com/Unity-Technologies/arfoundation-samples/issues/620#issuecomment-705027617

That video seems to have been removed, but if you want the background texture to shake, try adding a small random offset to the gl_Vertex in the shader, around this line:

// Transform the position from object space to clip space.
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

joondong commented 4 years ago

@tdmowrer Thanks for your help!!!!! I made it! https://www.youtube.com/watch?v=iXWl5f_iW7k

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

busiyg commented 3 years ago

You can override the material (with a custom shader) instead of directly modifying the one in the package. See my comment here: #620 (comment)

That video seems to have been removed, but if you want the background texture to shake, try adding a small random offset to the gl_Vertex in the shader, around this line:

// Transform the position from object space to clip space.
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

Hello, I want to modify the color to make the AR scene look darker, which parameter to change, thank you

tdmowrer commented 3 years ago

You'd need to change the gl_FragColor in the fragment shader.