Merge branch 'dev_robotaxi-d_230912_6.1.0' of gitlab.zhidaoauto.com:SCA/L4HA/AndroidApp/MoGoEagleEye into dev_robotaxi-d_230912_6.1.0

This commit is contained in:
xinfengkun
2023-09-25 15:09:12 +08:00
1542 changed files with 77840 additions and 7659 deletions

1
libraries/mapmodule/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,72 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
buildConfigField 'String', 'MAPMODULE_VERSION', '"'+MAP_SDK_VERSION+'"'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
zipAlignEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/proguard/coroutines.pro'
exclude 'META-INF/*'
exclude 'META-INF/io.netty.versions.properties'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/MANIFEST.MF'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation rootProject.ext.dependencies.coroutinescore
implementation rootProject.ext.dependencies.coroutinesandroid
implementation rootProject.ext.dependencies.kotlinstdlib
implementation rootProject.ext.dependencies.androidxrecyclerview
implementation rootProject.ext.dependencies.androidxannotation
implementation rootProject.ext.dependencies.androidxappcompat
// implementation rootProject.ext.dependencies.recyclerviewadapterhelper
implementation rootProject.ext.dependencies.retrofit
implementation rootProject.ext.dependencies.retrofitconvertergson
implementation rootProject.ext.dependencies.okhttpinterceptor
implementation ('com.alibaba:fastjson:1.2.73'){
exclude group: 'io.netty', module: 'netty-all'
}
implementation 'io.netty:netty-all:4.1.50.Final'
implementation 'com.zhidaoauto.map:net:1.0.1'
implementation "com.zhidaoauto.machine:mapcore:${MAP_SDK_VERSION}"
implementation "com.zhidaoauto.machine:mapdata:${MAP_SDK_DATA_VERSION}"
}

182
libraries/mapmodule/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,182 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
### 忽略警告
#-ignorewarning
#Basic 包名不混合大小写
-dontusemixedcaseclassnames
#Basic不忽略非公共的库类
-dontskipnonpubliclibraryclasses
#Basic输出混淆日志
-verbose
# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
#Basic不进行优化
-dontoptimize
#Basic不进行预检验
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.
#混淆注意事项第一条保留四大组件及Android的其它组件
-keep public class * extends android.app.Activity
#Basic
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
#Basic
-keep public class com.google.vending.licensing.ILicensingService
#Basic
-keep public class com.android.vending.licensing.ILicensingService
#Basic混淆注意事项第二条保持 native 方法不被混淆
-keepclasseswithmembernames class * {
native <methods>;
}
# 混淆注意事项第四条保持WebView中JavaScript调用的方法
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
#混淆注意事项第五条 自定义View Basic
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# Basic混淆注意事项第七条保持 Parcelable 不被混淆
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR;
}
#Basic 混淆注意事项第八条,保持枚举 enum 类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#Basic
-keepclassmembers class **.R$* {
public static <fields>;
}
#Basic保留注解
-keepattributes *Annotation*
# Basic排除警告
-dontwarn android.support.**
# Understand the @Keep support annotation.
# Basic不混淆指定的类及其类成员
-keep class android.support.annotation.Keep
# Basic不混淆使用注解的类及其类成员
-keep @android.support.annotation.Keep class * {*;}
# Basic不混淆所有类及其类成员中的使用注解的方法
-keepclasseswithmembers class * {
@android.support.annotation.Keep <methods>;
}
# Basic不混淆所有类及其类成员中的使用注解的字段
-keepclasseswithmembers class * {
@android.support.annotation.Keep <fields>;
}
# 不混淆所有类及其类成员中的使用注解的初始化方法
-keepclasseswithmembers class * {
@android.support.annotation.Keep <init>(...);
}
#保留源文件以及行号 方便查看具体的崩溃信息
-keepattributes SourceFile,LineNumberTable
#kotlin
-keep class kotlin.** { *; }
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
-keep class kotlinx.coroutines.android.** {*;}
# ServiceLoader support
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}
# Most of volatile fields are updated with AFU and should not be mangled
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}
-keepclasseswithmembernames class * {
native <methods>;
}
-target 1.6
-useuniqueclassmembernames
-renamesourcefileattribute SourceFile
-adaptresourcefilenames **.properties
-adaptresourcefilecontents **.properties,META-INF/MANIFEST.MF
-verbose
# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * {
native <methods>;
}
#如果有其它包有warning在报出warning的包加入下面类似的-dontwarn 报名
-dontwarn org.apache.*.**
-dontwarn org.dom4j.*.**
-dontwarn com.pdager.*.**
-dontwarn com.*.**
-dontwarn javax.*.**
#如果引用了v4或者v7包
-dontwarn android.support.**
-keepattributes EnclosingMethod
-keep class com.autonavi.nge.**{*;}
-keep class io.netty.**{*;}
-keep class com.zhidaoauto.map.sdk.inner.abs.**{*;}
-keep class com.zhidaoauto.map.sdk.inner.panel.**{*;}
-keep class com.zhidaoauto.map.sdk.inner.search.**{*;}
-keep class com.zhidaoauto.map.sdk.inner.element.**{*;}
-keep class com.zhidaoauto.map.sdk.inner.obj.**{*;}
-keep class com.zhidaoauto.map.sdk.open.**{*;}
-keepattributes Exceptions,InnerClasses
-keep class com.zhidaoauto.map.sdk.open.camera.**{ *; }
-keep class com.zhidaoauto.map.sdk.open.camera.CameraPosition$B { *; }
-keep class com.zhidaoauto.map.sdk.open.camera.CameraPosition$C { *; }

View File

@@ -0,0 +1,23 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.zhidaoauto.map.sdk">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest>

View File

@@ -0,0 +1,85 @@
//package com.autonavi.nge.dm;
//
//import android.os.IBinder;
//import com.autonavi.nge.guidance.RouteBook;
//import com.autonavi.nge.guidance.NaviInfo;
//import com.autonavi.nge.guidance.RouteImage;
//import com.autonavi.nge.guidance.LaneMask;
//import com.autonavi.nge.obj.Category;
//import com.autonavi.nge.obj.UpdateRegion;
//import com.autonavi.nge.trafficInfo.TMCID;
//import com.autonavi.nge.search.SPPoiItem;
//import com.autonavi.nge.search.SPCategories;
//import com.autonavi.nge.search.SPQuery;
//import com.autonavi.nge.search.SPSearchResult;
//import com.autonavi.nge.map.LonLat;
//import com.autonavi.nge.guidance.GuidanceStatListener;
//interface INavigationCore {
//// IBinder getHandler();
// void Routing_SetOrigin(float lon, float lat, int sessionid);
// void Routing_SetDest(float lon, float lat, int sessionid);
// void Routing_GetRoute(int sessionid);
// boolean Routing_GetStatus(int sessionid);
// void Routing_Reset(int sessionid);
// void Routing_ClearTour(int sessionid);
// void RoutingSetCostModel(int model, int sessionid);
// void RoutingSetAvoidHighway(boolean isAvoidHighway, int sessionid);
// void RoutingSetAvoidToll(boolean isAvoidToll, int sessionid);
//
// void Traffic_Update(in List<TMCID> ids, int evt);
// void Traffic_UpdateByTile(int tile, in int[] ids, in byte[] speeds);
// void RoutingSetUseTraffic(boolean useTraffic, int sessionid);
// int RoutingGetRouteNum(int sessionid);
// int RoutingGetLength(int route, int sessionid);
// int RoutingGetSTime(int route, int sessionid);
// int RoutingGetDTime(int route, int sessionid);
// void addwaypoint(float lon, float lat, int heading, int sessionid);
// void clearwaypoints(int sessionid);
//
// void Guidance_UpdatePosition(float lon, float lat, float speed, float heading);
// void Guidance_StartNavi(int type);
// void Guidance_StopNavi();
// void Guidance_SetSimSpeed(int speed);
// void Guidance_PauseSimNavi();
// void Guidance_ResumeSimNavi();
// RouteBook Guidance_RouteBook(int session,int start,int end);
// NaviInfo Guidance_NaviInfo();
// NaviInfo GetNaviInfo(in byte[] datas);
// String Guidance_TTS();
// RouteImage Guidance_Image(int imageUr,int imageBg,int imageArrow,int type);
// LaneMask Guidance_LaneMask();
// double Guidance_getRoadAngle();
//
// List<SPPoiItem> Search_getSearchResult(int productId, double lon, double lat, double radius, int kindfilter, int updateregionId, String keyWord, int pageIdx, int searchType);
// SPPoiItem getPoiItemByPoiId(int poiId);
// List<SPPoiItem> getPoiItemListByLonLat(int prodId, int urId, float lon, float lat, int pageCount, int pageIdx);
// List<SPPoiItem> queryPoiItemByCircle(float centerLon,float centerLat,float radius);
// List<SPPoiItem> queryPoiItemByRect(float topLeftLon,float topLeftLat,float bottomRightLon,float bottomRightLat);
// List<SPPoiItem> queryPoiItemByPolygon(in List<LonLat> latLonPoints);
// List getFTSDataByDA( int urid, String keyStr, int keytype, int maxResultCount);
// List<String> getInputResult(int productId, int updateregionId, String inputStr);
// List<String> getInputResultByDA();
// List<Category> getCatList(int urid);
// List<UpdateRegion> getURListByDA(int prodid);
// void play(String text,boolean forcePlay);
//
// int RoutingGetSearchedCnt(int route, int sessionid);
//
// int [] getMemoryInfo();
//
// void startServer();
//
// void stopServer();
//
// int getMDSVersion();
// String getDataVersion();
// String getCopyRight();
// String getCompilerVersion();
//
// void onGuidanceStatusChanged(int statCode, in byte[] datas);
//
// void setGuidanceStatListener(GuidanceStatListener listener);
//
// SPCategories getAllPoiCategories(int languageCode);
// List<SPSearchResult> getPoiItemList(in SPQuery query);
//}

View File

@@ -0,0 +1,5 @@
package com.autonavi.nge.guidance;
oneway interface GuidanceStatListener{
void onGuidanceStatusChanged(int statCode, in byte[] datas);
}

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.guidance;
parcelable LaneMask;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.guidance;
parcelable NaviInfo;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.guidance;
parcelable RouteBook;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.guidance;
parcelable RouteImage;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.hdmap;
parcelable HDMapBlock;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.hdmap;
parcelable LonLat;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.map;
parcelable LonLat;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.obj;
parcelable Category;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.obj;
parcelable PoiBase;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.obj;
parcelable UpdateRegion;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.search;
parcelable SPCategories;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.search;
parcelable SPPoiItem;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.search;
parcelable SPQuery;

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.search;
parcelable SPSearchResult;

View File

@@ -0,0 +1,11 @@
package com.autonavi.nge.server;
import android.os.IBinder;
interface IMapServer {
IBinder getHandler();
void start(IBinder dm);
void stop();
void heartbeat();
}

View File

@@ -0,0 +1,10 @@
package com.autonavi.nge.trafficInfo;
import android.os.IBinder;
import com.autonavi.nge.trafficInfo.TMCID;
interface ITrafficClient {
IBinder getHandler();
void On_Traffic_Update(in List<TMCID> ids, int evt);
void On_Traffic_UpdateByTile(int tile, in int[] links,in byte[] speeds);
}

View File

@@ -0,0 +1,12 @@
package com.autonavi.nge.trafficInfo;
import android.os.IBinder;
import com.autonavi.nge.trafficInfo.ITrafficClient;
interface ITrafficServer {
IBinder getHandler();
void register(ITrafficClient client);
void start();
void stop();
}

View File

@@ -0,0 +1,3 @@
package com.autonavi.nge.trafficInfo;
parcelable TMCID;

View File

@@ -0,0 +1,45 @@
#version 300 es
precision highp float;
uniform float u_r;
uniform float u_add;
uniform float u_offset;
uniform float u_waveVel;
uniform vec4 u_waveColor;
in lowp float _type;
in lowp float _flag;
in highp float _off;
in highp float _time;
in highp vec3 _pos;
in lowp vec4 _color;
out lowp vec4 color;
void main()
{
if (_type == 1.0)
{
lowp float r_base= 4.0;
lowp float r_max = u_r * 32.0;
highp vec3 l_pos = vec3(0, 2, -(u_offset+60.0));
highp vec3 v = _pos - l_pos;
v.x = v.x*2.25; v.z = v.z/2.25;
highp float d = length(v);
highp float r = d - r_base;
color = _color;
if (r < r_max)
{
highp float p = pow((r_max-r)/r_max, 2.0);
highp float t = u_add*p * 0.15;
lowp vec4 c_light = _color + vec4(t,t,t*1.5,0);
color = c_light;
}
}
else if (_type == 2.0)
{
highp float k = clamp(cos(_time/20.0*u_waveVel-_off), 0.0,1.0);
k = pow(k, 25.0);
if (k > 0.98) k = 1.0;
else if (k < 0.02) k = 0.0;
color = u_waveColor * k + _color * (1.0-k);
}
else
color = _color;
}

View File

@@ -0,0 +1,82 @@
#version 300 es
precision highp float;
uniform float u_main_shine;
uniform float u_other_shine;
uniform sampler2D u_texture;
uniform vec4 u_color;
uniform vec4 u_light_diffuse;
uniform vec4 u_light_specular;
uniform float u_shadow_black;
in float _type;
in float _flag;
in float _cmd;
in float _off;
in float _time;
in vec2 _tex;
in vec3 _nor;
in vec3 _v1;
in vec3 _v2;
in vec4 _back;
out vec4 color;
void main()
{
vec4 tex = texture(u_texture, _tex);
if (_flag == 0.0)
color = texture(u_texture, _tex);
else if (_flag < 10.0)
{
float d = _flag * 0.08;
color = vec4(vec3(0,0,0),(0.4-d)) * u_shadow_black;
}
else
{
float shine1A = 60.0 * u_main_shine;
float shine2A = 30.0 * u_main_shine;
float shine1B = 20.0 * u_other_shine;
float shine2B = 10.0 * u_other_shine;
vec3 v1 = _type == 1.0 ? vec3(0,-1.2,1) : _v1;
float k1 = max(dot(normalize(_nor),normalize(- v1)), 0.0);
float k2 = max(dot(normalize(_nor),normalize(-_v2)), 0.0);
float dif1 = min(max(k1*(_type==1.0?1.2:2.4), 0.40), 0.60);
float dif2 = min(max(k2*(_type==1.0?0.6:1.2), 0.40), 0.60);
float spc1 = min(pow(k1,_type==1.0?shine1A:shine1B)*(_type==1.0?10.0:0.5), _type==1.0?0.2:0.3);
float spc2 = min(pow(k2,_type==1.0?shine2A:shine2B)*(_type==1.0?15.0:0.5), _type==1.0?0.2:0.1);
float dif = min(dif1+dif2, _type==1.0?0.85:0.80);
float spc = min(spc1+spc2, _type==1.0?0.25:0.20);
if (_type == 1.0)
color = tex*u_light_diffuse*dif + vec4(1,1,1,1)*spc1 + _back*spc2;
else if (_type == 2.0)
{
if (_cmd == 0.0)
{
vec4 c = u_color.r+u_color.g+u_color.b > 0.01 ? u_color : tex;
color = c*dif + u_light_specular*spc;
}
else if (_time == 0.0)
{
if (_cmd == 1.0)
color = (tex*0.5+u_color*0.5)*dif + u_light_specular*spc;
else
color = tex*dif + u_light_specular*spc;
}
else
{
vec4 c;
float d = mod(abs(_cmd), 2.0);
vec4 tex_ = tex*0.5 + u_color*0.5;
float t = _cmd > 0.0 ? (d==1.0?_time:1.0-_time) : (d==1.0?1.0-_time:_time);
if (t > _off+0.2)
c = d==1.0 ? tex_ : tex;
else if (t > _off)
{
float k = d==1.0 ? 0.5-(_off+0.2-t)/0.4 : (_off+0.2-t)/0.4;
c = u_color*k + tex*(1.0-k);
}
else
c = d==1.0 ? tex : tex_;
color = c*dif + u_light_specular*spc;
}
}
color.a = 1.0;
}
}

View File

@@ -0,0 +1,64 @@
#version 300 es
precision highp float;
uniform vec4 u_color;
uniform sampler2D u_texture;
uniform int vr_type;
in float _type;
in float _flag;
in vec3 _pos;
in vec2 _tex;
in vec4 _clr;
out vec4 color;
void main()
{
if (_type == 1.0)
{
vec4 c = texture(u_texture, _tex);
float a = c.a > 0.8 ? 1.0 : 0.0;
color = vec4(c.rgb, a);
}
else if (_type >= 2.0 && _type < 70.0)
{
float k = 1.0; // 渐进衰减
if (_flag > 110.0)
k = 0.8;
else if (_flag > 10.0)
k = 1.0 - (_flag-10.0)/500.0;
vec4 c = texture(u_texture, _tex*_type);
float a = c.a > 0.8 ? 1.0 : 0.0;
color = vec4(c.rgb*k, a);
}
else if (_type >= 70.0 && _type < 74.0)
{
float alpha = _flag / 100.0;
float h = _clr.a / 170.0;
float hs = 8.0 * h;
float hi = floor(hs);
float f = (hs) - floor(hs);
float q = 1.0 - f;
if (hi <= 0.0)
if(vr_type == 1)
color = vec4(0.0, 0.9, 1.0, alpha);
else
color = vec4(0.15,0.99,1.0, alpha);
else if (hi <= 1.0)
if(vr_type == 1)
color = vec4(0.0, f, 0.9, alpha);
else
color = vec4(0.20,0.73,0.92, alpha);
else if (hi <= 2.0)
if(vr_type == 1)
color = vec4(0.35, 1.0, 0.8, alpha);
else
color = vec4(0.15,0.99,1.0, alpha);
else
if(vr_type == 1)
color = vec4(0.15, 0.73, 1.0, alpha);
else
color = vec4(0.15,0.99,1.0, alpha);
}
else if (u_color.r+u_color.g+u_color.b > 0.01)
color = u_color;
else
color = texture(u_texture, _tex);
}

View File

@@ -0,0 +1,229 @@
#version 300 es
precision highp float;
precision highp sampler2DShadow;
precision mediump int;
uniform float colorFac;
uniform bool isTex; //是否是纹理
uniform bool isShadow; //是否渲染阴影
uniform bool isNightDay; //是否是白天模式
uniform bool isRenderZebra; //斑马线渲染
uniform bool isSpotLight; //是否聚光灯
uniform bool isPcf; //是否聚光灯
uniform bool isWave; //流光效果
uniform sampler2D texId;
uniform sampler2DShadow depthTex; //深度纹理
uniform bool isRenderSignalLine; //信号线
uniform float signalLineTime; //信号线时间
uniform float signalLineCnt; //信号线时间
uniform int signalLineStep; //信号线时间
uniform int signalLineObj; //信号线对象
uniform vec4 shadowColor;
uniform float spotRadius; //聚光灯半径范围
uniform float spotBright; //聚光灯亮度
uniform float spotOffset; //聚光灯偏移
uniform bool isRenderText; //是否是文字渲染
uniform vec4 textColor; //信号线时间
uniform bool isWater; //水系
uniform vec4 waterColor;
uniform vec3 cameraPos;
uniform float shadowResolution;
uniform bool isLightWave;
in vec4 posInLight;
in vec4 _color;
in highp vec3 posInEye;
in vec3 worldPos;
in vec2 _uv;
in float signalLineTexY;
uniform float waveVel;
uniform vec4 waveColor;
uniform float waveTime;
in highp float waveOff;
out vec4 fragColor;
in float distanceFromCamera;
in float guideLineTexY;
uniform bool isFogEnable;
uniform vec3 fogColor;
uniform float fogStart;
uniform float fogEnd;
uniform float fogDensity;
uniform bool isGuideLine; //引导线
uniform vec3[4] streetLightWorldPos;
uniform int streetLightCnt;
uniform bool isBlurEnable;
uniform vec3 blurColor;
uniform float blurStart;
uniform float blurEnd;
uniform float blurDensity;
uniform float zoom;
void setSpotLightColor(){ //聚光灯光照效果
lowp float r_base= 4.0;
lowp float r_max = spotRadius * 32.0;
highp vec3 l_pos = vec3(0, 2, -(spotOffset+60.0));
highp vec3 v = posInEye - l_pos;
v.x = v.x*2.25; v.z = v.z/2.25;
highp float d = length(v);
highp float r = d - r_base;
if (r < r_max)
{
highp float p = pow((r_max-r)/r_max, 2.0);
lowp float t = spotBright*p * 0.15;
lowp vec4 c_light = fragColor + vec4(t*2.0,t*2.0,t*3.0,0);
fragColor = c_light;
}
}
float isInStreetLightArea(){
for(int i=0;i<streetLightCnt;i++){
float l = length(streetLightWorldPos[i]-worldPos);
if(l<3.0)
return l;
}
return 5.0;
}
void setStreetLight(float l){
// fragColor = vec4(1.0,0.0,0.0,1.0);
// float radius = 3.0;
// float l = length(streetLightWorldPos[i]-worldPos);
// float fac = 1.0 - l / radius;
// fac = pow(fac, 2.0)*0.15;
float fac = (1.0 - smoothstep(0.0,3.0,l))*0.15;
vec4 c_light = vec4(fac,fac,fac,0.0);
fragColor = fragColor + c_light;
}
bool isInScreen(vec4 p){ //是否在包围盒[(0,0)-(1,1)]内
if(p.x < 0.0 || p.x > 1.0 || p.y < 0.0 || p.y > 1.0)
return false;
else
return true;
}
void setZebra(){
vec4 c = texture(texId, _uv);
fragColor = vec4(c.rgb, step(0.8,c.a));
}
void setColor(){
fragColor = _color;
}
void setTex(){
fragColor = texture(texId,_uv);
}
float getShadowOffset(float x, float y)
{
float pixelSize = 1.0/shadowResolution;
vec4 offset = vec4(x,y,0.0, 0.0)*pixelSize * posInLight.w;
return textureProj(depthTex,posInLight + offset);
}
float getPcf(){
// 3x3 kernel with 4 taps per sample, effectively 6x6 PCF
float sum = 0.0;
for(int x=-2;x<=2;x+=2)
for(int y=-2;y<=2;y+=2)
sum+=getShadowOffset(float(x),float(y));
// divide sum by 9.0
sum = sum * 0.11;
return sum;
}
void setShadow(){
vec4 p = posInLight / posInLight.w; //ndc坐标
if(isInScreen(p)){ //坐标不在[0,1]内,光源看不到此片元,那就不用处理此片元的阴影
// float f = textureProj(depthTex,posInLight); //textureProj在阴影中返回0否则返回1。即是否通过深度测试
float k;
if(isPcf)
k = 1.0-getPcf();
else
k = 1.0-textureProj(depthTex,posInLight); //textureProj在阴影中返回0否则返回1。即是否通过深度测试
fragColor = vec4(mix(vec3(fragColor),vec3(shadowColor*k),shadowColor.a*k),fragColor.a);
}
}
void setWave(){
highp float k = clamp(cos(waveTime/20.0*waveVel-waveOff), 0.0,1.0);
k = clamp(pow(k, 25.0),0.02,0.98);
fragColor = mix(_color,waveColor,k);
}
void setSignalLine(){
if(signalLineObj==0){
if(signalLineStep==0 && _uv.y>1.0)
discard;
}else if(signalLineObj==1){
if(_uv.x<0.0 || _uv.x>1.0)
discard;
if(signalLineStep==1){
if(_uv.y<signalLineCnt)
discard;
}
}
fragColor = texture(texId,_uv);
// fragColor *= 1.0-0.5*smoothstep(0.0,signalLineCnt,signalLineTexY);
if(signalLineObj==1)
fragColor *= clamp(smoothstep(0.0,signalLineCnt,signalLineTexY)+0.5,0.0,1.0);
}
void setText(){
fragColor = vec4(vec3(textColor),texture(texId,_uv).a);
}
void setLinearFog()
{
if(!isFogEnable)
return;
float distanceFromCamera = length(posInEye-cameraPos);
if(distanceFromCamera<fogStart)
return;
float fogAlpha=(distanceFromCamera-fogStart)/(fogEnd-fogStart);
fogAlpha=clamp(fogAlpha,0.0,1.0)*fogDensity;
fragColor.rgb = mix(fragColor.rgb,fogColor,fogAlpha);
}
void setGuideLine(){
fragColor = texture(texId,_uv);
// if(fragColor.a>0.1)
// fragColor.a = clamp(1.0/guideLineTexY,0.0,1.0);
}
void setBlur()
{
if(!isBlurEnable)
return;
float distanceFromOrigin = length(worldPos-vec3(0.0,0.0,0.0));
if(distanceFromOrigin<(blurStart*zoom))
return;
float blurAlpha= 1.0-exp(-(distanceFromOrigin/50.0));
// float blurAlpha = smoothstep(distanceFromOrigin,blurStart*zoom,blurEnd*zoom);
// float blurAlpha = (distanceFromOrigin - (blurStart*zoom)) / ((blurEnd*zoom) - (blurStart*zoom));
blurAlpha=clamp(blurAlpha,0.0,1.0)*blurDensity;
fragColor.rgb = mix(fragColor.rgb,blurColor,blurAlpha);
}
void main()
{
if (isRenderZebra)
setZebra();
else if (isRenderSignalLine)
setSignalLine();
else if (isWave)
setWave();
else if(isGuideLine)
setGuideLine();
else if (isRenderText)
setText();
else if (isTex)
setTex();
else
setColor();
if (isWater){
fragColor = waterColor*dot(normalize(fragColor.rgb), vec3(0.0, 0.0, 1.0));
fragColor.a = 1.0;
}
if(isLightWave){
if(_uv.y>0.9)
fragColor.a = 0.0;
}
fragColor*=colorFac;
if (isSpotLight)
setSpotLightColor();
float streetLightDis = isInStreetLightArea();
if(streetLightDis<3.0){
setStreetLight(streetLightDis);
}else{
if (isShadow)
setShadow();
}
setLinearFog();
setBlur();
}

View File

@@ -0,0 +1,109 @@
#version 300 es
precision mediump float;
uniform sampler2D texId;
uniform float colorFac;
uniform vec4 ambientColor; //环境光颜色
uniform vec4 diffuseColor; //漫反射光颜色
uniform vec4 specularColor; //高光颜色
uniform float specularPow; //高光光泽度
uniform vec4 replacedColor; //把元素替换为另外一种颜色
uniform bool isReplaceColor; //是否把元素替换为另外一种颜色
in vec2 fragTexCoord;
in vec3 fragEyeNormal;
in vec3 fragEyePos;
in vec3 lightEyePos;
in float _changeColorCmd;
in float _changeColorRatio;
in float _changeColorOff;
in float distanceFromCamera;
uniform bool isFogEnable;
uniform vec3 fogColor;
uniform float fogStart;
uniform float fogEnd;
uniform float fogDensity;
uniform bool isBlurEnable;
uniform vec3 blurColor;
uniform float blurStart;
uniform float blurEnd;
uniform float blurDensity;
uniform vec3 cameraPos;
uniform float zoom;
uniform bool isIce;
in vec3 posInEye;
layout(location = 0) out vec4 fragColor;
//锚点变色逻辑,高爽写得代码,逻辑没变,复制到这
//变色有两种策略一种是直接立刻变色s1另一种是缓慢变色s2。保持原色为s0
vec4 changeColorMethod(vec4 texColor){
vec4 retColor = vec4(0.0);
if(_changeColorCmd==0.0){
if(isReplaceColor)
retColor = mix(texColor,replacedColor,1.0); //s1
else
retColor = texColor; //s0
}else if(_changeColorRatio==0.0){
if(_changeColorCmd==1.0)
retColor = mix(texColor,replacedColor,0.5);
else
retColor = texColor;
}else{
float d = mod(abs(_changeColorCmd), 2.0);
vec4 tex_ = mix(texColor,replacedColor,0.5);
float t = _changeColorCmd > 0.0 ? (d==1.0?_changeColorRatio:1.0-_changeColorRatio) : (d==1.0?1.0-_changeColorRatio:_changeColorRatio);
if (t > _changeColorOff+0.2)
retColor = d==1.0 ? tex_ : texColor;
else if (t > _changeColorOff)
{
float k = d==1.0 ? 0.5-(_changeColorOff+0.2-t)/0.4 : (_changeColorOff+0.2-t)/0.4;
retColor = replacedColor*k + texColor*(1.0-k);
}
else
retColor = d==1.0 ? texColor : tex_;
}
return retColor;
}
void setLinearFog()
{
if(!isFogEnable)
return;
float distanceFromCamera = length(posInEye-cameraPos);
if(distanceFromCamera<fogStart)
return;
float fogAlpha=(distanceFromCamera-fogStart)/(fogEnd-fogStart);
fogAlpha=clamp(fogAlpha,0.0,1.0)*fogDensity;
fragColor.rgb = mix(fragColor.rgb,fogColor,fogAlpha);
}
void setBlur()
{
if(!isBlurEnable)
return;
float distanceFromOrigin = length(posInEye-vec3(0.0,0.0,0.0));
if(distanceFromOrigin<(blurStart*zoom))
return;
float blurAlpha= 1.0-exp(-(distanceFromOrigin/50.0));
// float blurAlpha = smoothstep(distanceFromOrigin,blurStart*zoom,blurEnd*zoom);
// float blurAlpha = (distanceFromOrigin - (blurStart*zoom)) / ((blurEnd*zoom) - (blurStart*zoom));
blurAlpha=clamp(blurAlpha,0.0,1.0)*blurDensity;
fragColor.rgb = mix(fragColor.rgb,blurColor,blurAlpha);
}
void main()
{
//点光源光照Blinn-Phong模型
vec3 L = normalize(fragEyePos - lightEyePos); //光源到此片元的方向
vec3 N = normalize(fragEyeNormal); //此片元法线
vec3 V = normalize(fragEyePos); //眼睛观察此片元的方向
vec3 H = normalize(-L-V); //半向量
float diffuse = max(dot(-L,N),0.0); //漫反射系数
float specular = 0.0; //高光系数
if(diffuse!=0.0)
specular = pow(max(dot(H, N),0.0), specularPow); //高光系数
vec4 oriColor=vec4(0.0); //片元原来的颜色
oriColor = changeColorMethod(texture(texId,fragTexCoord) * colorFac);
fragColor = oriColor * (ambientColor + diffuseColor * diffuse) + specularColor * specular; //融合这几种颜色
fragColor+=oriColor*vec4(0.3)*max(dot(vec3(0,0,1),N),0.0); //罗欢说模型屁股那太黑,给屁股那增加点颜色
if(isIce)
fragColor+=vec4(.0,.0,0.2,0.0);
fragColor.a = oriColor.a;
setLinearFog();
setBlur();
}

View File

@@ -0,0 +1,8 @@
#version 300 es
precision mediump float;
in vec4 v_color;
out vec4 o_fragColor;
void main()
{
o_fragColor = v_color;
}

View File

@@ -0,0 +1,30 @@
#version 300 es
precision mediump float;
uniform vec4 u_light_ambient;
uniform vec4 u_light_diffuse;
uniform vec4 u_light_specular;
uniform vec3 u_light_dir;
uniform float u_material_shiness;
in vec3 v_position;
in vec4 v_color;
in vec3 v_normal;
out vec4 o_fragColor;
void main()
{
// ambient
vec4 ambient = u_light_ambient;
// diffuse
vec3 norm = normalize(v_normal.xyz);
vec3 lightDir = normalize(u_light_dir);
float diff = max(dot(norm, lightDir), 0.0);
vec4 diffuse = u_light_diffuse * diff;
// specular
vec4 specular = vec4(0, 0, 0, 1);
if (u_material_shiness>0.0){
vec3 viewDir = normalize(-v_position);
vec3 reflectDir = normalize(reflect(-lightDir, norm));
float spec = pow(max(dot(viewDir, reflectDir), 0.0), u_material_shiness);
specular = u_light_specular * spec;
}
o_fragColor = (ambient + diffuse)*v_color + specular;
}

View File

@@ -0,0 +1,32 @@
#version 300 es
precision mediump float;
uniform vec4 u_light_ambient;
uniform vec4 u_light_diffuse;
uniform vec4 u_light_specular;
uniform vec3 u_light_dir;
uniform vec4 u_material_ambient;
uniform vec4 u_material_diffuse;
uniform vec4 u_material_specular;
uniform float u_material_shiness;
in vec3 v_position;
in vec3 v_normal;
out vec4 o_fragColor;
void main()
{
// ambient \n"
vec4 ambient = u_material_ambient * u_light_ambient;
// diffuse
vec3 norm = normalize(v_normal.xyz);
vec3 lightDir = normalize(u_light_dir);
float diff = max(dot(norm, lightDir), 0.0);
vec4 diffuse = u_material_diffuse * u_light_diffuse * diff;
// specular
vec4 specular = vec4(0, 0, 0, 1);
if (u_material_shiness>0.0){
vec3 viewDir = normalize(-v_position);
vec3 reflectDir = normalize(reflect(-lightDir, norm));
float spec = pow(max(dot(viewDir, reflectDir), 0.0), u_material_shiness);
specular = u_material_specular * u_light_specular * spec;
}
o_fragColor = ambient + diffuse + specular;
}

View File

@@ -0,0 +1,16 @@
#version 300 es
precision mediump float;
uniform sampler2D s_texture;
uniform int u_texture_env_mode;
in vec4 v_color;
in vec2 v_texcoord;
out vec4 o_fragColor;
void main()
{
const int texture_env_mode_replace = 0x1E01;
const int texture_env_mode_modulate = 0x2100;
if (u_texture_env_mode==texture_env_mode_replace)
o_fragColor = texture( s_texture, v_texcoord );
if (u_texture_env_mode==texture_env_mode_modulate)
o_fragColor = texture( s_texture, v_texcoord )*v_color;
}

View File

@@ -0,0 +1,19 @@
#version 300 es
precision mediump float;
uniform sampler2D s_texture;
uniform int u_texture_env_mode;
in vec4 v_color;
in vec2 v_texcoord;
out vec4 o_fragColor;
void main()
{
const int texture_env_mode_replace = 0x1E01;
const int texture_env_mode_modulate = 0x2100;
if (u_texture_env_mode==texture_env_mode_replace)
o_fragColor = texture( s_texture, v_texcoord).aaaa;
if (u_texture_env_mode==texture_env_mode_modulate){
// o_fragColor = texture( s_texture, v_texcoord).aaaa*v_color;
o_fragColor = vec4(1, 1, 1, texture( s_texture, v_texcoord).a)*v_color;
}
// o_fragColor = v_color;
}

View File

@@ -0,0 +1,41 @@
#version 300 es
precision mediump float;
uniform sampler2D s_texture;
uniform int u_texture_env_mode;
uniform vec4 u_light_ambient;
uniform vec4 u_light_diffuse;
uniform vec4 u_light_specular;
uniform vec3 u_light_dir;
uniform float u_material_shiness;
in vec3 v_position;
in vec2 v_texcoord;
in vec3 v_normal;
out vec4 o_fragColor;
void main()
{
const int texture_env_mode_replace = 0x1E01;
const int texture_env_mode_modulate = 0x2100;
vec4 color = texture( s_texture, v_texcoord );
if (u_texture_env_mode==texture_env_mode_replace)
o_fragColor = color;
else if (u_texture_env_mode==texture_env_mode_modulate){
// ambient
vec4 ambient = u_light_ambient;
// diffuse
vec3 norm = normalize(v_normal.xyz);
vec3 lightDir = normalize(u_light_dir);
float diff = max(dot(norm, lightDir), 0.0);
vec4 diffuse = u_light_diffuse * diff;
// specular
vec4 specular = vec4(0, 0, 0, 1);
if (u_material_shiness>0.0){
vec3 viewDir = normalize(-v_position);
vec3 reflectDir = normalize(reflect(-lightDir, norm));
float spec = pow(max(dot(viewDir, reflectDir), 0.0), u_material_shiness);
specular = u_light_specular * spec;
}
o_fragColor = (ambient + diffuse)*color + specular;
}
else
o_fragColor = vec4(0, 0, 0, 1);
}

View File

@@ -0,0 +1,9 @@
#version 300 es
precision mediump float;
in vec4 v_color;
out vec4 o_fragColor;
void main()
{
o_fragColor = v_color;
}

View File

@@ -0,0 +1,23 @@
#version 300 es
precision mediump float;
uniform samplerCube texId;
uniform bool isFogEnable;
uniform vec3 fogColor;
uniform float fogStart;
uniform float fogEnd;
uniform float fogDensity;
uniform vec2 resolution;
in vec3 _uv;
out vec4 fragColor;
void setLinearFog()
{
if(!isFogEnable)
return;
float a = clamp(0.0,1.0,(1.0-gl_FragCoord.y/resolution.y)*3.0);
fragColor.rgb = mix(fragColor.rgb,fogColor,fogDensity*a);
}
void main()
{
fragColor = texture(texId, _uv);
setLinearFog();
}

View File

@@ -0,0 +1,13 @@
#version 300 es
precision mediump float;
uniform sampler2D tex;
in float _alphaFac;
layout(location = 0) out vec4 color;
void main()
{
vec4 c = texture(tex,gl_PointCoord);
if(c.a<0.3)
discard;
color = c;
color.a = color.a * _alphaFac;
}

View File

@@ -0,0 +1,24 @@
#version 300 es
precision highp float;
uniform int u_type;
uniform mat4 u_mvMatrix;
uniform mat4 u_projMatrix;
uniform float u_time;
in vec4 pos;
in vec4 color;
out float _type;
out float _flag;
out float _off;
out float _time;
out vec3 _pos;
out vec4 _color;
void main()
{
_type = float(u_type % 100);
_flag = float(u_type / 100);
_pos = (u_mvMatrix * pos).xyz;
_color = color;
_off = pos.y / 1000.0;
_time = u_time;
gl_Position = u_projMatrix * u_mvMatrix * pos;
}

View File

@@ -0,0 +1,76 @@
#version 300 es
uniform int u_type;
uniform mat4 u_mvMatrix;
uniform mat4 u_projMatrix;
uniform vec4 u_light_dir;
uniform int u_cmd;
uniform float u_time;
uniform float u_shadow_offset;
in vec4 pos;
in vec2 tex;
in vec4 nor;
out float _type;
out float _flag;
out float _cmd;
out float _off;
out float _time;
out vec2 _tex;
out vec3 _nor;
out vec3 _v1;
out vec3 _v2;
out vec4 _back;
void main()
{
_type = float(u_type % 100);
_flag = float(u_type / 100);
vec4 p = pos;
_tex = tex;
_nor = nor.xzy;
_cmd = float(u_cmd);
_time = u_time;
if (_cmd == 0.0)
_off = 0.0;
else if (abs(_cmd) < 3.0)
_off = pos.x/500.0 + 0.5;
else
_off = pos.y/1000.0 + 0.5;
if (_type > 0.0 && _type < 10.0)
{
if (_flag < 10.0)
{
mat4 m = u_projMatrix * u_mvMatrix;
float dk = (2.0 - 0.1*pow((5.0-_flag),2.0)) * u_shadow_offset;
float dx = 0.05 * (_type==1.0 ? dk/4.0 : dk);
float dz = -0.20 * dk * length(m[0].xyz)*110.0;
p *= vec4(1.0+dx,1,1,1);
p = m * p;
p += vec4(0,dz,8,0);
gl_Position = p;
}
else
{
if (_type == 1.0)
{
_back = vec4(0.2,0.2,0.2,1);
if (pos.z > 180.0 && pos.z < 250.0)
{
if (_flag == 40.0)
_back = vec4(1,0,0,1);
else if (_flag == 50.0 || _flag == 20.0 && pos.x < -50.0 || _flag == 30.0 && pos.x > 50.0)
_back = vec4(1,1,0,1);
}
}
_v1 = vec3(u_light_dir.x, -u_light_dir.y, 0);
_v1 = (u_mvMatrix * vec4(_v1,0)).xyz;
_v1.y = length(_v1) * -1.2;
_v2 = (u_mvMatrix * vec4(0,-1,_type==1.0?-0.5:-0.25, 0)).xyz;
gl_Position = u_projMatrix * u_mvMatrix * p;
}
}
else
{
if (_type == 10.0 && _flag > 0.0)
p.x *= _flag / 100.0;
gl_Position = u_projMatrix * u_mvMatrix * p;
}
}

View File

@@ -0,0 +1,23 @@
#version 300 es
uniform int u_type;
uniform float point_size;
uniform mat4 u_mvMatrix;
uniform mat4 u_projMatrix;
in vec4 pos;
in vec2 tex;
in vec4 clr;
out float _type;
out float _flag;
out vec3 _pos;
out vec2 _tex;
out vec4 _clr;
void main()
{
_type = float(u_type % 100);
_flag = float(u_type / 100);
_pos = pos.xyz;
_tex = tex;
_clr = clr;
gl_PointSize = point_size;
gl_Position = u_projMatrix * u_mvMatrix * pos;
}

View File

@@ -0,0 +1,129 @@
#version 300 es
precision highp float;
precision mediump int;
uniform mat4 modelMat;
uniform mat4 viewMat;
uniform mat4 projMat;
uniform mat4 mvMat;
uniform mat4 mvpMat;
uniform vec3 zebraPos0;
uniform vec3 zebraPos1;
uniform mat4 lightEyeMat; //光源的lookat矩阵
uniform mat4 lightProjMat;
uniform mat4 biasMat; //映射矩阵,将[-1,1]映射到[0,1]
uniform bool isRenderZebra; //斑马线渲染
uniform bool isShadow; //是否渲染阴影
uniform bool isSpotLight; //是否聚光灯
uniform bool isTex; //是否是纹理
uniform bool isWave; //流光效果
uniform bool isRenderSignalLine; //信号线
uniform float signalLineTime; //信号线时间
uniform int signalLineStep; //信号线阶段
uniform int signalLineObj; //信号线对象
uniform bool isWater; //水系
uniform float waterTime; //水系滚动时间
uniform bool isRenderDivider;
uniform vec3 dividerPos0;
uniform vec3 dividerPos1;
uniform bool isGuideLine; //引导线
uniform float guideLineTime;
layout( location = 0 ) in vec4 pos;
layout(location = 1) in vec4 color;
layout(location = 3) in vec2 uv;
out vec4 posInLight; //从光源位置看此片元的proj坐标
out vec4 _color;
out vec3 posInEye; //片元的view坐标
out vec3 worldPos; //片元的view坐标
out vec2 _uv;
out float signalLineTexY;
out float waveOff;
out float guideLineTexY;
void setZebra(){
vec4 pos0 = projMat*viewMat*modelMat * vec4(zebraPos0,1.0);
vec4 pos1 = projMat*viewMat*modelMat * vec4(zebraPos1,1.0);
float d = distance(pos0.xy/pos0.w,pos1.xy/pos1.w); //求出斑马线长边的长度
int cnt = 0; //根据长边的长度决定画几根斑马线
if(d<0.03)
cnt = 1;
else if(d<0.1)
cnt = 3;
else if(d<0.3)
cnt = 5;
else if(d<0.5)
cnt = 15;
else if(d < 1.4)
cnt = 30;
else
cnt = 30;
_uv = uv*float(cnt);
}
void setColor(){
_color = color;
}
void setTex(){
_uv = uv;
}
bool hasSetPosInEye = false;
void setPosInEye(){
if(!hasSetPosInEye){
posInEye = (viewMat * modelMat * pos).xyz;
hasSetPosInEye = true;
}
}
void setPosInLight(){
posInLight = biasMat*lightProjMat * lightEyeMat * modelMat * pos;
}
void setWater(){
_uv.x = _uv.x + waterTime;
}
void setWave(){
waveOff = pos.y / 1000.0;
}
void setSignalLine(){
if(signalLineObj==1 && signalLineStep>0){
_uv.x = (uv.x - 0.5)*3.0 + 0.5; //x方向缩放
_uv.y = uv.y;
signalLineTexY = _uv.y;
_uv = _uv + vec2(0.0,1.0)*signalLineTime;
}
}
void setGuideLine(){
_uv.x = uv.x;
_uv.y = -uv.y;
_uv = _uv + vec2(0.0,1.0)*guideLineTime;
guideLineTexY = uv.y;
}
void main()
{
worldPos = (modelMat * pos).xyz;
setPosInEye();
if(isRenderDivider){
vec4 pos0 = projMat*viewMat*modelMat * vec4(dividerPos0,1.0);
vec4 pos1 = projMat*viewMat*modelMat * vec4(dividerPos1,1.0);
float d = distance(pos0.xy/pos0.w,pos1.xy/pos1.w); //求出车道线的宽度
if(d<0.001) //线宽小于阈值,丢弃
return;
}
if(isShadow){
setPosInLight();
setPosInEye();
}
if(isSpotLight){
setPosInEye();
}
if(isTex)
setTex();
else
setColor();
if(isRenderZebra)
setZebra();
if(isWave)
setWave();
if(isWater)
setWater();
if(isRenderSignalLine)
setSignalLine();
if(isGuideLine)
setGuideLine();
gl_Position = projMat*viewMat*modelMat * pos;
}

View File

@@ -0,0 +1,39 @@
#version 300 es
precision mediump float;
uniform mat4 modelMat;
uniform mat4 viewMat;
uniform mat4 projMat;
uniform vec3 lightWorldPos; //光源的世界坐标
uniform int changeColorCmd;
uniform float changeColorRatio;
layout(location = 0) in vec4 pos;
layout(location = 2) in vec3 normal;
layout(location = 3) in vec2 texCoord;
out vec2 fragTexCoord;
out vec3 fragEyeNormal;
out vec3 fragEyePos; //光源的人眼坐标
out vec3 lightEyePos;
out vec3 posInEye;
out float _changeColorCmd;
out float _changeColorRatio;
out float _changeColorOff;
void main()
{
_changeColorCmd = float(changeColorCmd);
_changeColorRatio = changeColorRatio;
if(_changeColorCmd==0.0)
_changeColorOff = 0.0;
else if(abs(_changeColorCmd)<3.0)
_changeColorOff = pos.x/500.0 + 0.5;
else
_changeColorOff = pos.y/1000.0 + 0.5;
gl_Position = projMat * viewMat * modelMat * pos;
fragTexCoord = texCoord;
mat3 normalMat = mat3(transpose(inverse(viewMat * modelMat)));
fragEyeNormal = normalize(normalMat * normal); //法线矩阵变换
fragEyePos = (viewMat * modelMat * pos).xyz;
lightEyePos = (viewMat*vec4(lightWorldPos,1.0)).xyz;
posInEye = (modelMat * pos).xyz;
}

View File

@@ -0,0 +1,12 @@
#version 300 es
uniform mat4 u_projMatrix;
uniform mat4 u_mvMatrix;
uniform float u_colorScaleFactor;
layout(location = 0) in vec4 a_position;
layout(location = 1) in vec4 a_color;
out vec4 v_color;
void main()
{
v_color = a_color*u_colorScaleFactor;
gl_Position = u_projMatrix * u_mvMatrix * a_position;
}

View File

@@ -0,0 +1,17 @@
#version 300 es
uniform mat4 u_projMatrix;
uniform mat4 u_mvMatrix;
uniform float u_colorScaleFactor;
layout(location = 0) in vec4 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec4 a_normal;
out vec3 v_position;
out vec4 v_color;
out vec3 v_normal;
void main()
{
v_position = (u_mvMatrix * a_position).xyz;
v_color = a_color*u_colorScaleFactor;
v_normal = (transpose(inverse(u_mvMatrix)) * a_normal).xyz;
gl_Position = u_projMatrix * u_mvMatrix * a_position;
}

View File

@@ -0,0 +1,13 @@
#version 300 es
uniform mat4 u_projMatrix;
uniform mat4 u_mvMatrix;
layout(location = 0) in vec4 a_position;
layout(location = 1) in vec4 a_normal;
out vec3 v_position;
out vec3 v_normal;
void main()
{
v_position = (u_mvMatrix * a_position).xyz;
v_normal = (transpose(inverse(u_mvMatrix)) * a_normal).xyz;
gl_Position = u_projMatrix * u_mvMatrix * a_position;
}

View File

@@ -0,0 +1,15 @@
#version 300 es
uniform mat4 u_projMatrix;
uniform mat4 u_mvMatrix;
uniform float u_colorScaleFactor;
layout(location = 0) in vec4 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texcoord;
out vec4 v_color;
out vec2 v_texcoord;
void main()
{
v_color = a_color*u_colorScaleFactor;
v_texcoord = a_texcoord;
gl_Position = u_projMatrix * u_mvMatrix * a_position;
}

View File

@@ -0,0 +1,16 @@
#version 300 es
uniform mat4 u_projMatrix;
uniform mat4 u_mvMatrix;
layout(location = 0) in vec4 a_position;
layout(location = 1) in vec2 a_texcoord;
layout(location = 2) in vec4 a_normal;
out vec3 v_position;
out vec2 v_texcoord;
out vec3 v_normal;
void main()
{
v_position = (u_mvMatrix * a_position).xyz;
v_texcoord = a_texcoord;
v_normal = (transpose(inverse(u_mvMatrix)) * a_normal).xyz;
gl_Position = u_projMatrix * u_mvMatrix * a_position;
}

View File

@@ -0,0 +1,11 @@
#version 300 es
uniform mat4 u_projMatrix;
uniform mat4 u_mvMatrix;
layout(location = 0) in vec4 a_position;
layout(location = 1) in vec4 a_color;
out vec4 v_color;
void main()
{
v_color = a_color;
gl_Position = u_projMatrix * u_mvMatrix * a_position;
}

View File

@@ -0,0 +1,12 @@
#version 300 es
precision mediump float;
uniform mat4 modelMat;
uniform mat4 viewMat;
uniform mat4 projMat;
layout( location = 0) in vec4 pos;
out vec3 _uv;
void main()
{
gl_Position = (projMat * viewMat * modelMat * pos).xyww;
_uv = pos.xyz;
}

View File

@@ -0,0 +1,14 @@
#version 300 es
precision mediump float;
uniform mat4 modelMat;
uniform mat4 viewMat;
uniform mat4 projMat;
uniform float pointSize;
layout(location = 0) in vec4 pos;
out float _alphaFac;
void main()
{
gl_Position = projMat*viewMat*modelMat*vec4(pos.xyz,1.0);
gl_PointSize = (1.0-gl_Position.z/gl_Position.w)*pointSize;
_alphaFac = pos.w;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Some files were not shown because too many files have changed in this diff Show More