Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by starstriker1 · Jul 15, 2012 at 11:18 PM · shadernormalsclipping3d texttext mesh

Doing a clipping effect with a 3D text mesh using shaders

I'm using a custom shader on my 3D text objects in order to create an effect where the text is revealed from left to right. I'm doing this with a surface shader that clips all pixels to the right of a certain screen position. This works great, and is just what I wanted, but Unity is throwing a lot of warnings because surface shaders are expected to use normals and the Text Mesh component doesn't generate any normals.

While this is workable for now, in the long run I need a way to stop getting my console spammed with these warnings. I can think of three approaches: 1) write a fragment shader that clips the text in the same way, 2) suppress the warning (which I'd prefer not to do) or 3) find a way to make the Text Mesh generate proper normals for its geometry. I'm not sure how to do any of these things... can someone point me in the right direction?

Thanks!

Comment
Add comment · Show 7
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 Jessy · Jul 16, 2012 at 12:35 AM 0
Share

A surface shader that doesn't use normals is pointless.

avatar image starstriker1 · Jul 16, 2012 at 01:06 AM 0
Share

Like I said, I don't know how to write a fragment shader that would clip based on screen space, but the surface shader WOR$$anonymous$$S, so it's hardly pointless. Inappropriate, perhaps, but it DOES do the job. If there's a better way to do it, I'm all ears.

avatar image Jessy · Jul 16, 2012 at 01:17 AM 0
Share

Just because you don't know how to do it without a surface shader doesn't mean that there's a point to using a surface shader. Surface shaders exist to make working with Unity's undocumented lighting system feasible. I don't see a clear question here. You just don't know how to use Cg or GLSL?

avatar image starstriker1 · Jul 16, 2012 at 02:30 AM 0
Share

"Pointless" is a bit of a strong term for something that's fully functional.

The shader is basically just this:

void surf (Input IN, inout SurfaceOutput o)

{

clip(_ScreenXCull - IN.screenPos.x / IN.screenPos.w);

fixed4 c = tex2D($$anonymous$$ainTex, IN.uv$$anonymous$$ainTex) * _Color;

o.Albedo = c.rgb * _Color;

o.Alpha = c.a;

}

It functions as intended, but throws a warning when applied to my 3D Text meshes since they do not generate normals. How do I stop it from throwing warnings at me when applying it to a text mesh?

avatar image Jessy · Jul 16, 2012 at 02:39 AM 0
Share

You don't; that's an annoyance of Unity, and has existed since the beginning. I logged a bug about it long ago; you can too. I don't think the term is strong; if I were to write this, I'd be using GLSL, and I'd see no point in using a surface shader. It depends on what you want to learn. I believe you should learn Cg. All you need to do is multiply the vertex position by the $$anonymous$$VP, and work with the result.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ScroodgeM · Jul 17, 2012 at 07:53 AM

the best and i think the only one way to complete this quest is to write a vertex shader. it's a good in perfomance reason, cause it doesn't use a lot of calculations like light and others, and it doesn't use any normals. show a shader u use for text - i'm sure it needs a bit changes to became a vertex 8)

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

3D Text diffuse shader? 1 Answer

How to use sprite mask interation for 3d text mesh ? 0 Answers

3D Texture and normals 0 Answers

CutOut diffuse shader visible from both sides on a plane? 1 Answer

Generic clipsafe fading ✿ 0 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