surface-effect.effect 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. // Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
  2. CCEffect %{
  3. techniques:
  4. - name: opaque
  5. passes:
  6. - switch: USE_OUTLINE_PASS
  7. vert: silhouette-edge-vs
  8. frag: silhouette-edge-fs
  9. rasterizerState: &r1
  10. cullMode: front
  11. depthStencilState: &d1
  12. depthFunc: less_equal
  13. depthTest: true
  14. depthWrite: true
  15. properties:
  16. lineWidth: { value: 10, target: outlineParams.x }
  17. depthBias: { value: 0, target: outlineParams.y }
  18. baseColor: { editor: { type: color } }
  19. baseColorMap: { value: grey }
  20. - vert: standard-vs
  21. frag: standard-fs
  22. properties: &props
  23. tilingOffset: { value: [1.0, 1.0, 0.0, 0.0] }
  24. mainColor: { value: [1.0, 1.0, 1.0, 1.0], target: albedo, linear: true, editor: { displayName: Albedo, type: color } }
  25. albedoScale: { value: [1.0, 1.0, 1.0], target: albedoScaleAndCutoff.xyz }
  26. alphaThreshold: { value: 0.5, target: albedoScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST, slide: true, range: [0, 1.0], step: 0.001 } }
  27. occlusion: { value: 0.0, target: pbrParams.x, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
  28. roughness: { value: 0.5, target: pbrParams.y, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
  29. metallic: { value: 0.0, target: pbrParams.z, editor: { slide: true, range: [0, 1.0], step: 0.001 } }
  30. specularIntensity: { value: 0.5, target: pbrParams.w, editor: { slide: true, range: [0.0, 1.0], step: 0.001 } }
  31. emissive: { value: [0.0, 0.0, 0.0, 1.0], linear: true, editor: { type: color } }
  32. emissiveScale: { value: [1.0, 1.0, 1.0], target: emissiveScaleParam.xyz }
  33. normalStrength: { value: 1.0, target: emissiveScaleParam.w, editor: { parent: USE_NORMAL_MAP, slide: true, range: [0, 5.0], step: 0.001 } }
  34. anisotropyIntensity: { value: 1.0, target: anisotropyParam.x, editor: { parent: IS_ANISOTROPY, slide : true, range : [0.0, 1.0] , step : 0.0001 } }
  35. anisotropyRotation: { value: 0.0, target: anisotropyParam.y, editor: { parent: IS_ANISOTROPY, slide : true, range : [0, 1.0] , step : 0.0001 } }
  36. anisotropyMapResolutionHeight: { value: 0.0, target: anisotropyParam.w, editor: { parent: FIX_ANISOTROPIC_ROTATION_MAP } }
  37. addOnShadowBias: { value: 0.0, target: anisotropyParam.z }
  38. mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
  39. normalMap: { value: normal }
  40. pbrMap: { value: grey }
  41. occlusionMap: { value: white }
  42. emissiveMap: { value: grey }
  43. anisotropyMap: { value: black, editor : { parent: IS_ANISOTROPY } }
  44. anisotropyMapNearestFilter: { value: black, editor : { parent: FIX_ANISOTROPIC_ROTATION_MAP } }
  45. - &forward-add
  46. vert: standard-vs
  47. frag: standard-fs
  48. phase: forward-add
  49. propertyIndex: 0
  50. embeddedMacros: { CC_FORWARD_ADD: true }
  51. depthStencilState:
  52. depthFunc: equal
  53. depthTest: true
  54. depthWrite: false
  55. blendState:
  56. targets:
  57. - blend: true
  58. blendSrc: one
  59. blendDst: one
  60. blendSrcAlpha: zero
  61. blendDstAlpha: one
  62. - &shadow-caster
  63. vert: shadow-caster-vs
  64. frag: shadow-caster-fs
  65. phase: shadow-caster
  66. propertyIndex: 0
  67. rasterizerState:
  68. cullMode: front
  69. properties:
  70. tilingOffset: { value: [1.0, 1.0, 0.0, 0.0] }
  71. mainColor: { value: [1.0, 1.0, 1.0, 1.0], target: albedo, editor: { displayName: Albedo, type: color } }
  72. albedoScale: { value: [1.0, 1.0, 1.0], target: albedoScaleAndCutoff.xyz }
  73. alphaThreshold: { value: 0.5, target: albedoScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST } }
  74. mainTexture: { value: grey, target: albedoMap, editor: { displayName: AlbedoMap } }
  75. - &reflect-map
  76. vert: standard-vs
  77. frag: reflect-map-fs
  78. phase: reflect-map
  79. propertyIndex: 0
  80. - &planar-shadow
  81. vert: planar-shadow-vs
  82. frag: planar-shadow-fs
  83. phase: planar-shadow
  84. propertyIndex: 0
  85. depthStencilState:
  86. depthTest: true
  87. depthWrite: false
  88. stencilTestFront: true
  89. stencilFuncFront: not_equal
  90. stencilPassOpFront: replace
  91. stencilRef: 0x80 # only use the leftmost bit
  92. stencilReadMask: 0x80
  93. stencilWriteMask: 0x80
  94. blendState:
  95. targets:
  96. - blend: true
  97. blendSrc: src_alpha
  98. blendDst: one_minus_src_alpha
  99. blendDstAlpha: one_minus_src_alpha
  100. - &deferred
  101. vert: standard-vs
  102. frag: standard-fs
  103. pass: gbuffer
  104. phase: gbuffer
  105. embeddedMacros: { CC_PIPELINE_TYPE: 1 }
  106. propertyIndex: 0
  107. - name: transparent
  108. passes:
  109. - vert: standard-vs
  110. frag: standard-fs
  111. embeddedMacros: { CC_FORCE_FORWARD_SHADING: true }
  112. depthStencilState: &d1
  113. depthTest: true
  114. depthWrite: false
  115. blendState: &b1
  116. targets:
  117. - blend: true
  118. blendSrc: src_alpha
  119. blendDst: one_minus_src_alpha
  120. blendDstAlpha: one_minus_src_alpha
  121. properties: *props
  122. - *forward-add
  123. - *shadow-caster
  124. - *planar-shadow
  125. - &deferred-forward
  126. vert: standard-vs
  127. frag: standard-fs
  128. phase: deferred-forward
  129. embeddedMacros: { CC_PIPELINE_TYPE: 0 }
  130. propertyIndex: 0
  131. depthStencilState: *d1
  132. blendState: *b1
  133. }%
  134. CCProgram shared-ubos %{
  135. uniform Constants {
  136. vec4 tilingOffset;
  137. vec4 albedo;
  138. vec4 albedoScaleAndCutoff;
  139. vec4 pbrParams;
  140. vec4 emissive;
  141. vec4 emissiveScaleParam;
  142. vec4 anisotropyParam;
  143. };
  144. }%
  145. CCProgram macro-remapping %{
  146. // ui displayed macros
  147. #pragma define-meta HAS_SECOND_UV
  148. #pragma define-meta USE_TWOSIDE
  149. #pragma define-meta IS_ANISOTROPY
  150. #pragma define-meta USE_VERTEX_COLOR
  151. #pragma define-meta FIX_ANISOTROPIC_ROTATION_MAP
  152. #define CC_SURFACES_USE_SECOND_UV HAS_SECOND_UV
  153. #define CC_SURFACES_USE_TWO_SIDED USE_TWOSIDE
  154. #define CC_SURFACES_LIGHTING_ANISOTROPIC IS_ANISOTROPY
  155. #define CC_SURFACES_USE_VERTEX_COLOR USE_VERTEX_COLOR
  156. // depend on UI macros
  157. #if IS_ANISOTROPY || USE_NORMAL_MAP
  158. #define CC_SURFACES_USE_TANGENT_SPACE 1
  159. #endif
  160. // functionality for each effect
  161. #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 31
  162. }%
  163. CCProgram surface-vertex %{
  164. #define CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS
  165. vec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)
  166. {
  167. return originShadowBias + vec2(anisotropyParam.z, 0.0);
  168. }
  169. /*#define CC_SURFACES_VERTEX_MODIFY_WORLD_POS
  170. vec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)
  171. {
  172. vec3 worldPos = In.worldPos;
  173. worldPos.x += sin(cc_time.x * worldPos.z);
  174. worldPos.y += cos(cc_time.x * worldPos.z);
  175. return worldPos;
  176. }
  177. #define CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL
  178. vec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)
  179. {
  180. vec3 worldNormal = In.worldNormal.xyz;
  181. worldNormal.x += sin(cc_time.x * 3.0);
  182. worldNormal.y += cos(cc_time.x * 3.0);
  183. #if CC_SURFACES_USE_TWO_SIDED
  184. worldNormal.xyz *= In.worldNormal.w;
  185. #endif
  186. return normalize(worldNormal);
  187. }
  188. // see <surfaces/default-functions/common-vs> for more overrided functions
  189. #define CC_SURFACES_VERTEX_MODIFY_SHARED_DATA
  190. void SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)
  191. {
  192. }
  193. */
  194. #define CC_SURFACES_VERTEX_MODIFY_UV
  195. void SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)
  196. {
  197. In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;
  198. #if CC_SURFACES_USE_SECOND_UV
  199. In.texCoord1 = In.texCoord1 * tilingOffset.xy + tilingOffset.zw;
  200. #endif
  201. }
  202. }%
  203. CCProgram surface-fragment %{
  204. #if USE_ALBEDO_MAP
  205. uniform sampler2D albedoMap;
  206. #pragma define-meta ALBEDO_UV options([v_uv, v_uv1])
  207. #endif
  208. #if USE_NORMAL_MAP
  209. uniform sampler2D normalMap;
  210. #pragma define-meta NORMAL_UV options([v_uv, v_uv1])
  211. #endif
  212. #pragma define-meta DEFAULT_UV options([v_uv, v_uv1])
  213. #if USE_PBR_MAP
  214. uniform sampler2D pbrMap;
  215. #endif
  216. #if USE_OCCLUSION_MAP
  217. uniform sampler2D occlusionMap;
  218. #endif
  219. #if USE_EMISSIVE_MAP
  220. uniform sampler2D emissiveMap;
  221. #pragma define-meta EMISSIVE_UV options([v_uv, v_uv1])
  222. #endif
  223. #if IS_ANISOTROPY && USE_ANISOTROPY_MAP
  224. uniform sampler2D anisotropyMap;
  225. uniform sampler2D anisotropyMapNearestFilter;
  226. #endif
  227. #pragma define OCCLUSION_CHANNEL r
  228. #pragma define ROUGHNESS_CHANNEL g
  229. #pragma define METALLIC_CHANNEL b
  230. #pragma define SPECULAR_INTENSITY_CHANNEL a
  231. #if USE_ALPHA_TEST
  232. #pragma define-meta ALPHA_TEST_CHANNEL options([a, r])
  233. #endif
  234. #define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY
  235. vec4 SurfacesFragmentModifyBaseColorAndTransparency()
  236. {
  237. vec4 baseColor = albedo;
  238. #if USE_VERTEX_COLOR
  239. baseColor.rgb *= SRGBToLinear(FSInput_vertexColor.rgb); // use linear
  240. baseColor.a *= FSInput_vertexColor.a;
  241. #endif
  242. #if USE_ALBEDO_MAP
  243. vec4 texColor = texture(albedoMap, ALBEDO_UV);
  244. texColor.rgb = SRGBToLinear(texColor.rgb);
  245. baseColor *= texColor;
  246. #endif
  247. #if USE_ALPHA_TEST
  248. if (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;
  249. #endif
  250. baseColor.rgb *= albedoScaleAndCutoff.xyz;
  251. return baseColor;
  252. }
  253. #define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY
  254. void SurfacesFragmentAlphaClipOnly()
  255. {
  256. #if USE_ALPHA_TEST
  257. float alpha = albedo.ALPHA_TEST_CHANNEL;
  258. #if USE_VERTEX_COLOR
  259. alpha *= FSInput_vertexColor.a;
  260. #endif
  261. #if USE_ALBEDO_MAP
  262. alpha = texture(albedoMap, ALBEDO_UV).ALPHA_TEST_CHANNEL;
  263. #endif
  264. if (alpha < albedoScaleAndCutoff.w) discard;
  265. #endif
  266. }
  267. #define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL
  268. vec3 SurfacesFragmentModifyWorldNormal()
  269. {
  270. vec3 normal = FSInput_worldNormal;
  271. #if USE_NORMAL_MAP
  272. vec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);
  273. normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleParam.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);
  274. #endif
  275. return normalize(normal);
  276. }
  277. #define CC_SURFACES_FRAGMENT_MODIFY_ANISOTROPY_PARAMS
  278. vec4 SurfacesFragmentModifyAnisotropyParams(out float isRotation)
  279. {
  280. float anisotropyRotation = anisotropyParam.y * PI;
  281. float anisotropyShape = anisotropyParam.x;
  282. #if IS_ANISOTROPY && USE_ANISOTROPY_MAP
  283. // Rotation angle should disable trilinear filtering
  284. vec4 tex = texture(anisotropyMap, DEFAULT_UV);
  285. anisotropyRotation = fract(anisotropyRotation * 0.5 + tex.y) * PI2;
  286. // less value is better for SP exported shape
  287. anisotropyShape *= tex.x;
  288. #endif
  289. // fix rotation map seam line of black and white
  290. #if FIX_ANISOTROPIC_ROTATION_MAP
  291. #if IS_ANISOTROPY && USE_ANISOTROPY_MAP
  292. vec4 reference = texture(anisotropyMapNearestFilter, DEFAULT_UV);
  293. vec2 oneTap = vec2(0.0, 1.0 / anisotropyParam.w);
  294. float threshold = 0.2;
  295. // scan more taps for stable result
  296. vec4 sample1 = texture(anisotropyMapNearestFilter, DEFAULT_UV + oneTap);
  297. vec4 sample2 = texture(anisotropyMapNearestFilter, DEFAULT_UV - oneTap);
  298. if (abs(sample1.y - reference.y) > threshold || abs(sample2.y - reference.y) > threshold) {
  299. tex.y = reference.y;
  300. }
  301. anisotropyRotation = fract(anisotropyParam.y * PI * 0.5 + tex.y) * PI2;
  302. #endif
  303. #endif
  304. isRotation = 1.0;
  305. return vec4(anisotropyShape, anisotropyRotation, 0.0, 0.0);
  306. }
  307. #define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE
  308. vec3 SurfacesFragmentModifyEmissive()
  309. {
  310. vec3 emissive = emissive.rgb;
  311. #if USE_EMISSIVE_MAP
  312. emissive = SRGBToLinear(texture(emissiveMap, EMISSIVE_UV).rgb);
  313. #endif
  314. return emissive * emissiveScaleParam.xyz;
  315. }
  316. #define CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS
  317. vec4 SurfacesFragmentModifyPBRParams()
  318. {
  319. vec4 pbr = pbrParams;
  320. pbr.x = 1.0;
  321. #if USE_PBR_MAP
  322. vec4 res = texture(pbrMap, DEFAULT_UV);
  323. pbr.x = mix(1.0, res.OCCLUSION_CHANNEL, pbrParams.x);
  324. pbr.y *= res.ROUGHNESS_CHANNEL;
  325. pbr.z *= res.METALLIC_CHANNEL;
  326. pbr.w *= res.SPECULAR_INTENSITY_CHANNEL;
  327. #endif
  328. #if USE_OCCLUSION_MAP
  329. pbr.x = mix(1.0, texture(occlusionMap, DEFAULT_UV).OCCLUSION_CHANNEL, pbrParams.x);
  330. #endif
  331. return pbr;
  332. }
  333. /*
  334. // definition of SurfacesMaterialData structure with corresponding shading-model
  335. #include <surfaces/data-structures/standard>
  336. //see <surfaces/default-functions/XXXX> for more overrided functions, XXXX is shading-model name
  337. #define CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA
  338. void SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData)
  339. {
  340. }
  341. // see <lighting-models/default-functions/XXXX> for more overrided functions, XXXX is lighting-model name
  342. #include <lighting-models/includes/common>
  343. #define CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT
  344. void SurfacesLightingModifyFinalResult(inout LightingResult result, in LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData, in LightingMiscData miscData)
  345. {
  346. }*/
  347. }%
  348. CCProgram standard-vs %{
  349. precision highp float;
  350. // 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros
  351. #include <macro-remapping>
  352. #include <surfaces/effect-macros/common-macros>
  353. // 2. common include with corresponding shader stage, include before surface functions
  354. #include <surfaces/includes/common-vs>
  355. // 3. user surface functions that can use user (effect) parameters (ubo Constants)
  356. // see surfaces/default-functions/xxx.chunk
  357. #include <shared-ubos>
  358. #include <surface-vertex>
  359. // 4. surface include with corresponding shader stage and shading-model (optional)
  360. #include <surfaces/includes/standard-vs>
  361. // 5. shader entry with corresponding shader stage and technique usage/type
  362. #include <shading-entries/main-functions/render-to-scene/vs>
  363. }%
  364. CCProgram shadow-caster-vs %{
  365. precision highp float;
  366. #include <macro-remapping>
  367. #include <surfaces/effect-macros/render-to-shadowmap>
  368. #include <surfaces/includes/common-vs>
  369. #include <shared-ubos>
  370. #include <surface-vertex>
  371. #include <shading-entries/main-functions/render-to-shadowmap/vs>
  372. }%
  373. CCProgram planar-shadow-vs %{
  374. precision highp float;
  375. #include <macro-remapping>
  376. #include <surfaces/effect-macros/render-planar-shadow>
  377. #include <surfaces/includes/common-vs>
  378. #include <shared-ubos>
  379. #include <surface-vertex>
  380. #include <shading-entries/main-functions/render-planar-shadow/vs>
  381. }%
  382. CCProgram standard-fs %{
  383. // shading-model : standard
  384. // lighting-model : standard (isotropy / anisotropy pbr)
  385. // shader stage : fs
  386. // technique usage/type : render-to-scene
  387. precision highp float;
  388. // 1. surface internal macros, for technique usage or remapping some user (material) macros to surface internal macros
  389. #include <macro-remapping>
  390. #include <surfaces/effect-macros/common-macros>
  391. // 2. common include with corresponding shader stage, include before surface functions
  392. #include <surfaces/includes/common-fs>
  393. // 3. user surface functions that can use user (effect) parameters (ubo Constants)
  394. // see surfaces/default-functions/xxx.chunk
  395. #include <shared-ubos>
  396. #include <surface-fragment>
  397. // 4. lighting-model (optional)
  398. #include <lighting-models/includes/standard>
  399. // 5. surface include with corresponding shader stage and shading-model (optional)
  400. #include <surfaces/includes/standard-fs>
  401. // 6. shader entry with corresponding shader stage and technique usage/type
  402. #include <shading-entries/main-functions/render-to-scene/fs>
  403. }%
  404. CCProgram shadow-caster-fs %{
  405. precision highp float;
  406. #include <macro-remapping>
  407. #include <surfaces/effect-macros/render-to-shadowmap>
  408. #include <surfaces/includes/common-fs>
  409. #include <shared-ubos>
  410. #include <surface-fragment>
  411. #include <shading-entries/main-functions/render-to-shadowmap/fs>
  412. }%
  413. CCProgram planar-shadow-fs %{
  414. precision highp float;
  415. #include <macro-remapping>
  416. #include <surfaces/effect-macros/render-planar-shadow>
  417. #include <surfaces/includes/common-fs>
  418. #include <shared-ubos>
  419. #include <surface-fragment>
  420. #include <shading-entries/main-functions/render-planar-shadow/fs>
  421. }%
  422. CCProgram reflect-map-fs %{
  423. precision highp float;
  424. #include <macro-remapping>
  425. #include <surfaces/effect-macros/common-macros>
  426. #include <surfaces/includes/common-fs>
  427. #include <shared-ubos>
  428. #include <surface-fragment>
  429. #include <lighting-models/includes/standard>
  430. #include <surfaces/includes/standard-fs>
  431. #include <shading-entries/main-functions/render-to-reflectmap/fs>
  432. }%
  433. ////////////////////////////////////////////////silhouette-edge sample
  434. // how to write a simple surface material
  435. // change technique outline-vs/fs:vert/frag to silhouette-edge-vs/fs
  436. CCProgram surface-vertex-silhouette-edge %{
  437. uniform OutlineVert {
  438. vec4 outlineParams; // x: line width, y: depth hack
  439. };
  440. #define CC_SURFACES_VERTEX_MODIFY_LOCAL_POS
  441. vec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)
  442. {
  443. float width = outlineParams.x * 0.001;
  444. vec3 localPos = In.position.xyz;
  445. #if USE_POSITION_SCALING
  446. vec3 dir = normalize(localPos);
  447. float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;
  448. localPos += flip * dir * width * 2.0;
  449. #else
  450. localPos += normalize(In.normal) * width;
  451. #endif
  452. return localPos;
  453. }
  454. #define CC_SURFACES_VERTEX_MODIFY_CLIP_POS
  455. vec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)
  456. {
  457. vec4 clipPos = In.clipPos;
  458. float scaleZ = cc_nearFar.z == 0.0 ? 0.5 : 1.0;
  459. clipPos.z -= outlineParams.y * 0.002 * scaleZ;
  460. return clipPos;
  461. }
  462. }%
  463. CCProgram surface-fragment-silhouette-edge %{
  464. uniform OutlineFrag {
  465. vec4 baseColor;
  466. };
  467. #if USE_BASE_COLOR_MAP
  468. uniform sampler2D baseColorMap;
  469. #endif
  470. // only for render-to-shadow-map or misc usage
  471. #define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY
  472. vec4 SurfacesFragmentModifyBaseColorAndTransparency()
  473. {
  474. vec4 color = vec4(cc_mainLitColor.rgb, 1.0);
  475. color.rgb = SRGBToLinear(baseColor.rgb);
  476. #if USE_BASE_COLOR_MAP
  477. vec4 texColor = texture(baseColorMap, FSInput_texcoord);
  478. texColor.rgb = SRGBToLinear(texColor.rgb);
  479. color *= texColor;
  480. #endif
  481. return color;
  482. }
  483. }%
  484. CCProgram silhouette-edge-vs %{
  485. precision highp float;
  486. #include <surfaces/effect-macros/silhouette-edge>
  487. #include <surfaces/includes/common-vs>
  488. #include <surface-vertex-silhouette-edge>
  489. #include <shading-entries/main-functions/misc/silhouette-edge-vs>
  490. }%
  491. CCProgram silhouette-edge-fs %{
  492. precision highp float;
  493. #include <surfaces/effect-macros/silhouette-edge>
  494. #include <surfaces/includes/common-fs>
  495. #include <surface-fragment-silhouette-edge>
  496. #include <shading-entries/main-functions/misc/silhouette-edge-fs>
  497. }%