1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- Shader "BabylonJS/NewShaderProgram" {
- Properties {
- _Color ("Color", Color) = (1,1,1,1)
- [NoScaleOffset] _MainTex ("Albedo (RGB)", 2D) = "white" {}
- _Glossiness ("Smoothness", Range(0,1)) = 0.5
- _Metallic ("Metallic", Range(0,1)) = 0.0
- _ScaleX ("Scale Factor X", Range (0.0, 10.0)) = 1.0
- _ScaleY ("Scale Factor Y", Range (0.0, 10.0)) = 1.0
- }
- SubShader {
- Tags { "RenderType"="Opaque" }
- LOD 200
- CGPROGRAM
- //////////////////////////////////////////////////////////
- // BABYLON WEBGL RUNTIME SHADER PROGRAM SECTIONS (GLSL) //
- //////////////////////////////////////////////////////////
- #ifdef BABYLON
- attributes: ["position", "normal", "uv"]
- uniforms: ["worldViewProjection, _Color, _Glossiness, _Metallic, _ScaleX, _ScaleY"]
- samplers: []
- defines: []
- #endif //BABYLON-END
- #ifdef VERTEX
- attribute vec3 position;
- attribute vec3 normal;
- attribute vec2 uv;
- uniform mat4 worldViewProjection;
- precision highp float;
- varying vec2 vUV;
-
- void main(void)
- {
- gl_Position = worldViewProjection * vec4(position, 1.0);
- vUV = uv;
- }
- #endif //VERTEX-END
- #ifdef FRAGMENT
- precision highp float;
- varying vec2 vUV;
- uniform vec4 _Color;
- uniform float _Glossiness;
- uniform float _Metallic;
- uniform float _ScaleX;
- uniform float _ScaleY;
- uniform sampler2D _MainTex;
- void main(void)
- {
- gl_FragColor = texture2D(_MainTex, vec2(vUV.x * _ScaleX, vUV.y * _ScaleY)) * _Color;
- }
- #endif //FRAGMENT-END
- ////////////////////////////////////////////////////////
- // DEFAULT UNITY EDITOR SHADER PROGRAM SECTION (HLSL) //
- ////////////////////////////////////////////////////////
- #pragma exclude_renderers d3d11 xbox360 gles
- #pragma surface surf Standard fullforwardshadows
- #pragma target 3.0
- sampler2D _MainTex;
- struct Input {
- float2 uv_MainTex;
- };
- half _Glossiness;
- half _Metallic;
- half _ScaleX;
- half _ScaleY;
- fixed4 _Color;
- void surf (Input IN, inout SurfaceOutputStandard o) {
- // Albedo comes from a texture tinted by color
- float2 vUV = IN.uv_MainTex;
- fixed4 c = tex2D (_MainTex, float2(vUV.x * _ScaleX, vUV.y * _ScaleY)) * _Color;
- o.Albedo = c.rgb;
- // Metallic and smoothness come from slider variables
- o.Metallic = _Metallic;
- o.Smoothness = _Glossiness;
- o.Alpha = c.a;
- }
- ENDCG
- }
- FallBack "Diffuse"
- }
|