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 Sondre-S · Jan 26, 2015 at 03:45 PM · shadercardecal

Add decal parameter to shader

I have a nice car paint shader, but it doesnt have a decal parameter. How would I go about adding a decal parameter?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by MaT227 · Jan 26, 2015 at 04:25 PM

You need to add a new texture parameter and in you shader add a blending between your decal texture and your regular car texture using the decal alpha channel.

It could be hard if you don't have any shader programming experience. I suggest you to post some code sample so we might be able to help you.

Comment
Add comment · Show 13 · 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 Sondre-S · Jan 26, 2015 at 05:05 PM 0
Share

Thanks, yeah I don't have any shader program$$anonymous$$g experience, but here's the shader:

//Hard Surface Shader Package, Written for the Unity engine by Bruno Rime: http://www.behance.net/brunorime brunorime@gmail.com Shader "HardSurface/Hardsurface Free/Opaque Specular"{ Properties { _Color ("$$anonymous$$ain Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (1, 1, 1, 1) _Shininess ("Shininess", Range (0.01, 3)) = 1.5 _Gloss("Gloss", Range (0.00, 1)) = .5 _Reflection("Reflection", Range (0.00, 1)) = 0.5 _Cube ("Reflection Cubemap", Cube) = "Black" { TexGen CubeReflect } _FrezPow("Fresnel Reflection",Range(0,2)) = .25 _FrezFalloff("Fresnal/EdgeAlpha Falloff",Range(0,10)) = 4 EdgeAlpha("Edge Alpha",Range(0,1)) = 0 $$anonymous$$etalics("$$anonymous$$etalics",Range(0,1)) = .5

 _$$anonymous$$ainTex ("Diffuse(RGB) Alpha(A)",2D) = "White" {}
 _Bump$$anonymous$$ap ("Normalmap", 2D) = "Bump" {}
 _Spec_Gloss_Reflec_$$anonymous$$asks ("Spec(R) Gloss(G) Reflec(B)",2D) = "White" {}
 

}

 SubShader {
     
     Tags {"Queue"="Geometry" "RenderType"="Opaque" "IgnoreProjector"="False" }
     UsePass "Hidden/Hardsurface Pro Front Opaque Specular/FORWARD"
     
 } 
     Fallback "Diffuse"
 }
avatar image MaT227 Sondre-S · Jan 26, 2015 at 05:18 PM 0
Share

Ok, this is a shader from the Hard Surface Shader Package which is a great package :) but it's going to be hard as it is separated in multiple pass and files and I don't think that you have the right to publish those files. I suggest you to write to the author of the package, he might be able to help you. You should also format your post.

avatar image Sondre-S Sondre-S · Jan 26, 2015 at 05:30 PM 0
Share

Thanks, sorry bout the formatting. I'll try to contact him.

avatar image MaT227 Sondre-S · Jan 26, 2015 at 09:48 PM 1
Share

This should not be a problem then.

Show more comments
avatar image MaT227 · Jan 31, 2015 at 05:57 PM 0
Share

According to the code you posted, you need to find the file Hidden/Hardsurface Pro Front Opaque Specular/FORWARD then your need to find the albedo variable then you could use the alpha channel of your decal function to blend between the default albedo and the decal texture. Unfortunately, without the source code it's hard to tell where to do this blending.

avatar image Sondre-S · Jan 31, 2015 at 09:02 PM 0
Share

Yes, exactly. I have found the pass its using, unfortunately is 18 thousand lines long :(

avatar image MaT227 · Feb 01, 2015 at 10:41 AM 0
Share

What you can do is test every variable of the function by returning each one by one and look at the output in your scene view. Once you've found the good one, you can blend between this variable and the decal texture using the decal alpha channel like this:

 lerp(variable.rgb, decal.rgb, decal.a);

Or use any blending technic. Don't forget to convert you decal sampler2D into a RGBA variable using the tex2D function.

avatar image Sondre-S · Feb 01, 2015 at 12:06 PM 0
Share

Thanks. I've aready gone through a lot of the code but with no luck. I will investigate further, so I appreciate your advice. However I'm also looking into using a projector for this.

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

20 People are following this question.

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

Related Questions

Project vertices on surface, make a shape 1 Answer

Shader to paint at coords? 1 Answer

Decal Alpha Blend 0 Answers

How do I build A texture from decals? 0 Answers

Shader that only shows mesh at the point where it is colliding with terrain? (A projector?) 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