zoukankan      html  css  js  c++  java
  • 关于Shader的学习记录


    float4 _EmissiveColor; float4 _AmbientColor; float _MySliderValue; void surf (Input IN, inout SurfaceOutput o) { // Albedo comes from a texture tinted by color float4 c; c = pow((_EmissiveColor + _AmbientColor), _MySliderValue); o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Alpha = c.a;

    1.如果没注意将_MySliderValue的数据类型声明成float4,那么shader将不会起作用并且不会报错。

    CGPROGRAM
    			#pragma surface surf BasicDiffuse
    
    		inline float4 LightingBasicDiffuse(SurfaceOutput s,fixed3 lightDir, fixed atten)
    	{
    		float difLight = max(0, dot(s.Normal, lightDir));
    		float4 col;
    		col.rgb = s.Albedo * _LightColor0.rgb * (difLight * atten * 2);
    		col.a = s.Alpha;
    		return col;
    	}
    

    2.自建光照模型 定义要在#下

    <1> 疑问:关于rgb的运算方式,是如何进行运算得出颜色值的,0,1对它的运算影响。

    3. 报错Too many texture interpolators would be used for ForwardBase pass at line

    错误原因是在报错Shader里,在结构体Input中定义了大于等于3个的额外的uv变量信息。?

    struct Input {  
                float2 offset1;  
                float2 offset2;  
                float2 offset3;  
                float4 pos;  
                fixed4 color;  
            };  
    

    <2> shader入门资料

    http://www.360doc.com/content/13/0923/15/12282510_316492286.shtml
  • 相关阅读:
    一篇文章讲清楚markdown
    webservice初体验-cxf
    IReport与web项目整合
    泛型
    观察者模式
    策略模式
    设计模式与面向对象
    JavaI/O(输入/输出)
    面向对象
    Java基础类库
  • 原文地址:https://www.cnblogs.com/white-L/p/6523383.html
Copyright © 2011-2022 走看看