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 ChoosingOwl · Nov 26, 2014 at 01:30 PM · errorshader

Shader Error at line 13 and 14

 Shader "Esther/Fire" {
     Properties {
         _ColorTex ("ColorTexture and alpha", 2D) = "white" {}
         _NoiseTex ("NoiseTexture", 2D) = "white" {}
         _AlphaTex ("AlphaTexture", 2D) = "white" {}
         _WindPower ("WindPowerDirection", Vector) = (1,1,1)
     }
     SubShader {
         Tags { "QUeue"="Transparent" }
         zWrite off
         Blend SrcAlpha OneMinusSrcAlpha
         Pass {
             CGPROGRAM
             #pragma vertex vertexFunction
             #pragma fragment pixelFunction
             #pragma glsl
             #pragma target 3.0
         
         uniform sampler2D _ColorTex;
         uniform sampler2D _NoiseTex;
         uniform sampler2D _AlphaTex;
         uniform fixed3 _WindPower ;
 
 struct ApptoVert {
     half4 uvCoord : TEXCOORD0;
     half4 inPos : POSITION;
     fixed4 vertColor : COLOR;
     fixed3 inNormal : NORMAL;
 };
 
 struct VerttoPix {
     half4 outPos : SV_POSITION;
     half4 uvCoord : TEXCOORD0;
     half2 transUV1 : TEXCOORD1;
     half2 transUV2 : TEXCOORD2;
     half2 transUV3 : TEXCOORD3;
     half perturb : TEXCOORD4;
     half displaceV : TEXCOORD5;
     fixed3 viewDir : TEXCOORD6;
     fixed3 normalDir : TEXCOORD7;
 };
 
 VerttoPix vertexFunction(ApptoVert i) {
 
     VerttoPix o;
     o.uvCoord = i.uvCoord;
     
     //scroll and tile the uv's for the noise texture. later this will create a perlin noise like effect
     half3 scrollSpeedsY = ((-0.81*_Time.y),(-0.96*_Time.y),(-3.66*_Time.y));
     half scrollSpeedsX = (10*_Time.x);
     half3 scales = (1,2,3);
     
     o.transUV1 = (i.uvCoord.xy * scales.x);
     o.transUV1.y = o.transUV1.y + (scrollSpeedsY.x ) + i.vertColor;
     o.transUV1.x = o.transUV1.x + (scrollSpeedsX ) + i.vertColor;
     
     o.transUV2 = (i.uvCoord.xy * scales.y);
     o.transUV2.y = o.transUV2.y + (scrollSpeedsY.y ) + i.vertColor;
     o.transUV2.x = o.transUV2.x + (-0.8*scrollSpeedsX ) + i.vertColor;
     
     o.transUV3 = (i.uvCoord.xy * scales.z);
     o.transUV3.y = o.transUV3.y + (scrollSpeedsY.z ) + i.vertColor;
     o.transUV3.x = o.transUV3.x + (0.37*scrollSpeedsX ) + i.vertColor;
     
     //perturb effect, will be used in fragment shader
     //The distortion effects are multiplied with Ycoord to create a stronger effect at the top of the model.
     //Values have been tested and implemented
     o.perturb = ((i.uvCoord.y)*1.80)+0.6;
     
     //displace verts in their normal direction sampling noise texture for values. this creates jitter effect
     //the jitter has a slight delay for the different flame_models by adding their vertColor to the time
     
     half disScrol = (_Time.y + (i.vertColor.x*0.15))*2;
     half4 displaceValue = tex2Dlod(_NoiseTex.half4(disScrol,disScrol*0.17,0,0)); //scroll through texture. Y displacement *0.1 makes sure its not repeating
     half displacement = (displaceValue.x-0.5) * 0.05; //-0.5 makes sure scale goes from -0.5 to 0.5 the *0.05 decides how much
     i.inPos = (i.inPos + fixed4(i.inNormal,0) * displacement); // displaces the verts along their normal
     i.inPos.y = i.inPos.y + (pow(i.uvCoord.y,0.5) * (displaceValue + (i.vertColor*1.5)))*0.2; //make the flame jitter extra in the Y-axis. the flame model
     
     //make the torch wave in the windpowers direction
     fixed bellyGradient = pow(i.uvCoord.y * (1-i.uvCoord.y), 2);  //make the displacement only effect the middle of the model
     i.inPos.xyz = i.inPos.xyz + bellyGradient * _WindPower * ((sin(_Time.z)+1)*0.5 + (sin(_Time.z*2.33)+1)*0.25); //Multiply the effect by two difference
     
     //send displacement value to pixel shader, so color can be made birghter or less brighter depending on flicker.
     o.displaceV = displaceValue.x;
     
     half4 worldPos = mul(_Object2World, i.inPos);
     
     //calculate view and normal direction to calculate edge detection later on
     o.viewDir = normalize(_WorldSpaceCameraPos.xyz - worldPos.xyz);
     o.normalDir = normalize(mul(_Object2World,float4(i.inNormal,0))xyz);
     
     o.outPos = mul(UNITY_MATRIX_MVP,i.inPos);
     return o;
     
 }
 
 fixed4 pixelFunction(VerttoPix v) : COLOR {
 
     //sample the noise texture using the non-scaled, 2-scaled and 3-scaled uvs.
     fixed4 noiseColor1 = tex2D(_NoiseTex,v.transUV1.xy);
     fixed4 noiseColor2 = tex2D(_NoiseTex,v.transUV2.xy);
     fixed4 noiseColor3 = tex2D(_NoiseTex,v.transUV3.xy);
     
     //distort the noise textures. values were tested on good result and then implemented.
     noiseColor1.y *=0.1;
     noiseColor2.y *=-0.33;
     noiseColor3.y *=0.68;
     
     //add the different noise textures together
     fixed4 finalNoise = noiseColor1 + noiseColor2 + noiseColor3;
     
     //perturb the color texture by  using the stacked noise textures and the perturb values
     half2 noiseCoords;
     noiseCoords.x = (finalNoise.x*v.perturb) + v.uvCoord.x;
     noiseCoords.y = (finalNoise.y*v.perturb) + v.uvCoord.y;
     
     //extract color through distorted uv coordinates
     fixed4 baseColor = tex2D(_ColorTex,clamp(noiseCoords, 0.05,0.97));
     
     //make the color of fire flicker between bright or not together with the scaling of the vertices
     fixed4 texColor1 = baseColor + (fixed4(1,1,0.6,1)*((v.displaceV - 0.5)*0.5));
     
     fixed Alpha2 = tex2D(_AlphaTex,v.uvCoord.xy).x;
     fixed Alpha1 = tex2D(_AlphaTex,clamp(noiseCoords,0.005,0.95)); //the clamp reduces artifacts
     
     //edge detection, fade edge
     fixed edge = pow(saturate(dot(v.normalDir,v.viewDir)*2),3);
     texColor1.a = Alpha1*Alpha2*edge;
     return texColor1;
             }
         ENDCG
         } 
     }
     FallBack "Diffuse"
 }
 

I've taken this code from here: http://estherzuidgeest.nl/index.php/portfolio/2-uncategorised/29-torchshader

but the thing is that i am getting a shader error at line 13 and 14(specific error is: Shader error in 'Esther/Fire': GLSL vertex shader: 94: ERROR: '' : methods are not supported at line 13 and Shader error in 'Esther/Fire': Shader program had errors at line 14) which is this:

             CGPROGRAM
             #pragma vertex vertexFunction


I've tried a couple of things for around the last couple of hours, but nothing really seems to work. Can anyone help me out with this ? All i wanted is a shader when applied is giving the torch effect.

thanks in advance.

Comment
Add comment · Show 1
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 gjf · Nov 26, 2014 at 01:44 PM 0
Share

one obvious typo:

 Tags { "QUeue"="Transparent" }

should be

 Tags { "Queue"="Transparent" }

2 Replies

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

Answer by gjf · Nov 26, 2014 at 02:03 PM

couple more typos:

 half4 displaceValue = tex2Dlod(_NoiseTex.half4(disScrol,disScrol*0.17,0,0));

should be

 half4 displaceValue = tex2Dlod(_NoiseTex,half4(disScrol,disScrol*0.17,0,0));

and

 o.normalDir = normalize(mul(_Object2World,float4(i.inNormal,0))xyz);

should be

 o.normalDir = normalize(mul(_Object2World,float4(i.inNormal,0)).xyz);


that'll fix it.

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
avatar image
0

Answer by Gruffy · Nov 26, 2014 at 01:45 PM

Hey bud, firstly lets change this Tags { "QUeue"="Transparent" } to this Tags { "Queue"="Transparent" }

Then come back

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Shader worked in Unity 4.5, now Unity 5 kills it. 1 Answer

[Solved] False "variable not assigned" error 3 Answers

jungle terrain problem 0 Answers

Shader Error GLSL error 0 Answers

CG shader is treated as GLSL and doesn't compile 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