• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by pkamat · Dec 13, 2009 at 11:53 AM · movietexture

Projecting a movie texture

Anybody know how to project a movie texture?

I modified the blob shadow project in the standard assets folder to project a MovieTexutre onto a plane. It works fine as long as the material in the projector properties is of type "Diffuse" if i change that to "Fx/Project Multiply" The texture is rendered black.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Noise crime · Jun 13, 2010 at 08:22 PM

The problem is pretty straightforward.

As far as I can tell movieTextures do not support embedded alpha so in the shader ( ShadowProjection.shader - FX/Projector Multiply) the line 'AlphaTest Greater 0' will always fail on every pixel of the movieTexture as the alpha is never > 0, its always 0 as there is no alpha.

The solution then is to remove that line, you could change it to 'AlphaTest GEqual 0' which will work, but actually that lets everything pass, ignoring any alpha that might be in normal diffuse textures. By just deleting the line you should find movieTextures work fine and diffuse still work as expected, due to the blending.

Of course then you'll come across bleeding/smearing of the projected movieTexture, but thats a whole different issue.

.

How to fix bleeding/smearing in projected movieTextures

Projective MovieTextures Package - Demo and collection of shaders to support movieTexture projection.

Bleeding of the movieTexture, where the clamped pixels of its border smear across the scene is perfectly normal. Its caused by using TexGen to create the uv mapping onto models within the 'projector' frustrum. Unfortunately whilst within the frustrum the uv maps from 0 to 1, outside it continues (i.e. negative up and left, > 1 down and right). Since the texture is clamped, this results in the border textures smearing. If you change the wrapmode to repeat, you'd get the texture repeat outside the frustrum instead.

The Blob shadow demo and shader get around this by using a mask/cookie using its alpha, where it is zero at the edges thus preventing the smearing from being rendered. If movieTextures had alpha support it could be used to similar effect.

So the simplest method to fix this would appear to be adding an additional texture layer (a mask), one that uses its alpha to control what pixels are finally rendered to screen. By making the alpha pure white except for say 1 pixel black border around the edges and ensuring wrapmode=clamp, we can force the area that is normally smeared to be hidden as the alpha will be 0 and it will not be rendered.

You need to ensure the alpha is exactly the same dimensions as you movie, so the black border is not scaled and its best to use 'point' sampling as opposed to bilinear. The shaders themselves have more information on this.

The provided a demo package features a simple test scene and contains 6 shaders, Additive, Multiply and Replace projection modes, each with an alternative that supports the 'falloff' method provided by the original shadowProjection shader in Unity.

enjoy.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Noise crime · Jun 14, 2010 at 09:56 PM 0
Share

Of course you don't just have to use the alpha mask for defining the border, you use it to actually mask out parts of the movie too, although obviously its just static.

avatar image chuckbergeron · May 05, 2012 at 07:23 PM 0
Share

Noisecrime, that demo & prefab was perfect. Thanks a million for this!

avatar image chuckbergeron · May 05, 2012 at 07:24 PM 0
Share

(ps I'd upvote you but I still have no voting privileges)

avatar image
-2
Wiki

Answer by Nicolaj Schweitz · Dec 14, 2009 at 06:52 PM

Hi. I tinkered a bit with the blob shadow projector and this piece of C# code. That was the closest I could get, so I thought I would just post it and see if anyone would pick it up and bring the question home.

C#:

using UnityEngine; using System.Collections;

public class PlayMovieTexture : MonoBehaviour {

private Projector proj; public MovieTexture tex;

void Start () { proj = transform.GetComponent<Projector>(); //proj.material.mainTexture.Play(); proj.material.SetTexture("_ShadowTex",tex); //proj.material.mainTexture = tex; tex.Play(); } }

I ticked the "community wiki" box, so please just change the code if you see something that should be corrected. I might add that it is not working right now... but in theory, it should, so it is prone for a bug report. However, I want get this reviewed before filing a bug report.

cheers

Edit: Not tested this code, but then it was irrelevant to the original question as the problem was in the shader.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pkamat · Dec 15, 2009 at 06:54 AM 0
Share

Did this work for you? I found that the problem lies within the Shader. Check this link, i used the Shader written by Jonathan Czeck. It has problems but it works.

http://forum.unity3d.com/viewtopic.php?p=242881#242881

avatar image Nicolaj Schweitz · Dec 21, 2009 at 01:04 PM 0
Share

No... :-( it did not work. However, in theory, it should. I just wanted to wikify the example, so the community can build on it and I really hope someone will pick it up and work it out. And again: if it is not possible, it should be reported as a bug.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Movies on Android. Is it possible? 2 Answers

BCE0051: Operator '<' cannot be used... ? 1 Answer

Issue Building my Video scene to Android 1 Answer

How to import the object from server to unity 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges