12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301 |
- {
- "__type__": "cc.EffectAsset",
- "_name": "internal/editor/light-probe-visualization",
- "_objFlags": 0,
- "__editorExtras__": {},
- "_native": "",
- "techniques": [
- {
- "passes": [
- {
- "rasterizerState": {
- "cullMode": 0
- },
- "blendState": {
- "targets": [
- {
- "blend": true,
- "blendSrc": 2,
- "blendDst": 4,
- "blendDstAlpha": 4
- }
- ]
- },
- "program": "internal/editor/light-probe-visualization|gizmo-vs:vert|gizmo-fs:front",
- "priority": 245,
- "depthStencilState": {
- "depthTest": false,
- "depthWrite": false
- }
- },
- {
- "rasterizerState": {
- "cullMode": 0
- },
- "blendState": {
- "targets": [
- {
- "blend": true,
- "blendSrc": 2,
- "blendDst": 4,
- "blendDstAlpha": 4
- }
- ]
- },
- "program": "internal/editor/light-probe-visualization|gizmo-vs:vert|gizmo-fs:back",
- "priority": 245,
- "depthStencilState": {
- "depthTest": false,
- "depthWrite": false
- }
- }
- ]
- }
- ],
- "shaders": [
- {
- "blocks": [
- {
- "name": "Constant",
- "members": [
- {
- "name": "mainColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 16,
- "binding": 0
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": [],
- "attributes": [
- {
- "name": "a_position",
- "defines": [],
- "format": 32,
- "location": 0
- },
- {
- "name": "a_normal",
- "defines": [],
- "format": 32,
- "location": 1
- }
- ],
- "varyings": [
- {
- "name": "normal_w",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 0
- },
- {
- "name": "pos_w",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 1
- },
- {
- "name": "pos_l",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 2
- },
- {
- "name": "right",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 3
- },
- {
- "name": "up",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 4
- },
- {
- "name": "forward",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 5
- }
- ],
- "fragColors": [
- {
- "name": "cc_FragColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 16,
- "location": 0
- }
- ],
- "descriptors": [
- {
- "rate": 0,
- "blocks": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCLocal",
- "members": [
- {
- "name": "cc_matWorld",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matWorldIT",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_lightingMapUVParam",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_localShadowBias",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [],
- "stageFlags": 1
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 1,
- "blocks": [
- {
- "name": "Constant",
- "members": [
- {
- "name": "mainColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 16,
- "binding": 0
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 2,
- "blocks": [],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 3,
- "blocks": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCGlobal",
- "members": [
- {
- "name": "cc_time",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_screenSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nativeSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_probeInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_debug_view_mode",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCamera",
- "members": [
- {
- "name": "cc_matView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_cameraPos",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_surfaceTransform",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_screenScale",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_exposure",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitDir",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientSky",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientGround",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogBase",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogAdd",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nearFar",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_viewPort",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- }
- ],
- "hash": 4208657580,
- "glsl4": {
- "vert": "\nprecision mediump float;\nlayout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 0) out vec3 normal_w;\nlayout(location = 1) out vec3 pos_w;\nlayout(location = 2) out vec3 pos_l;\nlayout(location = 3) out vec3 right;\nlayout(location = 4) out vec3 up;\nlayout(location = 5) out vec3 forward;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n vec4 normal = vec4(a_normal, 0);\n pos_l = a_position;\n pos_w = (cc_matWorld * pos).xyz;\n normal_w = (cc_matWorldIT * normal).xyz;\n right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n return cc_matProj * (cc_matView * cc_matWorld) * pos;\n}\nvoid main() { gl_Position = vert(); }",
- "frag": "\nprecision mediump float;\nmat3 transposeMat3 (mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon (inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1) {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2) {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3) {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4) {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5) {\n n = 0;\n }\n else if (config == 6) {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7) {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8) {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9) {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10) {\n n = 0;\n }\n else if (config == 11) {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12) {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13) {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14) {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15) {\n n = 4;\n }\n if (n == 3) L[3] = L[0];\n if (n == 4) L[4] = L[0];\n}\nfloat IntegrateEdge (vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate (vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transposeMat3(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0) return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4) sum += IntegrateEdge(L[3], L[4]);\n if (n == 5) sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if CC_USE_LIGHT_PROBE\n vec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n }\n vec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n }\n vec4 CCFragOutput (vec4 color) {\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n }\n#else\n vec4 CCFragOutput (vec4 color) {\n return color;\n }\n#endif\nlayout(location = 0) in vec3 normal_w;\nlayout(location = 1) in vec3 pos_w;\nlayout(location = 2) in vec3 pos_l;\nlayout(location = 3) in vec3 right;\nlayout(location = 4) in vec3 up;\nlayout(location = 5) in vec3 forward;\nlayout(set = 1, binding = 0) uniform Constant {\n vec4 mainColor;\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n};\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n vec3 SHEvaluate(vec3 normal)\n {\n vec3 result;\n #if USE_INSTANCING\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(v_sh_linear_const_r, normal4);\n result.g = dot(v_sh_linear_const_g, normal4);\n result.b = dot(v_sh_linear_const_b, normal4);\n #else\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(cc_sh_linear_const_r, normal4);\n result.g = dot(cc_sh_linear_const_g, normal4);\n result.b = dot(cc_sh_linear_const_b, normal4);\n vec4 n14 = normal.xyzz * normal.yzzx;\n float n5 = normal.x * normal.x - normal.y * normal.y;\n result.r += dot(cc_sh_quadratic_r, n14);\n result.g += dot(cc_sh_quadratic_g, n14);\n result.b += dot(cc_sh_quadratic_b, n14);\n result += (cc_sh_quadratic_a.rgb * n5);\n #endif\n #if CC_USE_HDR\n result *= cc_exposure.w * cc_exposure.x;\n #endif\n return result;\n }\n #endif\n#endif\nvec4 gizmo_fs (float alpha) {\n #if CC_USE_LIGHT_PROBE\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 diffuse = SHEvaluate(N);\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #else\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 V = normalize(cc_cameraPos.xyz - pos_w);\n vec3 points [4];\n points[0] = (forward * 3.0 + right + up) * 40.0;\n points[1] = (forward * 3.0 - right + up) * 40.0;\n points[2] = (forward * 3.0 - right - up) * 40.0;\n points[3] = (forward * 3.0 + right - up) * 40.0;\n vec3 diffuse = LinearToSRGB(mainColor.rgb * LTC_Evaluate(N, V, pos_l, mat3(1), points));\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #endif\n}\nvec4 front () {\n return gizmo_fs(1.0);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = front(); }"
- },
- "glsl3": {
- "vert": "\nprecision mediump float;\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nin vec3 a_position;\nin vec3 a_normal;\nout vec3 normal_w;\nout vec3 pos_w;\nout vec3 pos_l;\nout vec3 right;\nout vec3 up;\nout vec3 forward;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n vec4 normal = vec4(a_normal, 0);\n pos_l = a_position;\n pos_w = (cc_matWorld * pos).xyz;\n normal_w = (cc_matWorldIT * normal).xyz;\n right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n return cc_matProj * (cc_matView * cc_matWorld) * pos;\n}\nvoid main() { gl_Position = vert(); }",
- "frag": "\nprecision mediump float;\nmat3 transposeMat3 (mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon (inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1) {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2) {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3) {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4) {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5) {\n n = 0;\n }\n else if (config == 6) {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7) {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8) {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9) {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10) {\n n = 0;\n }\n else if (config == 11) {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12) {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13) {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14) {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15) {\n n = 4;\n }\n if (n == 3) L[3] = L[0];\n if (n == 4) L[4] = L[0];\n}\nfloat IntegrateEdge (vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate (vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transposeMat3(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0) return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4) sum += IntegrateEdge(L[3], L[4]);\n if (n == 5) sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if CC_USE_LIGHT_PROBE\n vec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n }\n vec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n }\n vec4 CCFragOutput (vec4 color) {\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n }\n#else\n vec4 CCFragOutput (vec4 color) {\n return color;\n }\n#endif\nin vec3 normal_w;\nin vec3 pos_w;\nin vec3 pos_l;\nin vec3 right;\nin vec3 up;\nin vec3 forward;\nlayout(std140) uniform Constant {\n vec4 mainColor;\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n};\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n vec3 SHEvaluate(vec3 normal)\n {\n vec3 result;\n #if USE_INSTANCING\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(v_sh_linear_const_r, normal4);\n result.g = dot(v_sh_linear_const_g, normal4);\n result.b = dot(v_sh_linear_const_b, normal4);\n #else\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(cc_sh_linear_const_r, normal4);\n result.g = dot(cc_sh_linear_const_g, normal4);\n result.b = dot(cc_sh_linear_const_b, normal4);\n vec4 n14 = normal.xyzz * normal.yzzx;\n float n5 = normal.x * normal.x - normal.y * normal.y;\n result.r += dot(cc_sh_quadratic_r, n14);\n result.g += dot(cc_sh_quadratic_g, n14);\n result.b += dot(cc_sh_quadratic_b, n14);\n result += (cc_sh_quadratic_a.rgb * n5);\n #endif\n #if CC_USE_HDR\n result *= cc_exposure.w * cc_exposure.x;\n #endif\n return result;\n }\n #endif\n#endif\nvec4 gizmo_fs (float alpha) {\n #if CC_USE_LIGHT_PROBE\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 diffuse = SHEvaluate(N);\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #else\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 V = normalize(cc_cameraPos.xyz - pos_w);\n vec3 points [4];\n points[0] = (forward * 3.0 + right + up) * 40.0;\n points[1] = (forward * 3.0 - right + up) * 40.0;\n points[2] = (forward * 3.0 - right - up) * 40.0;\n points[3] = (forward * 3.0 + right - up) * 40.0;\n vec3 diffuse = LinearToSRGB(mainColor.rgb * LTC_Evaluate(N, V, pos_l, mat3(1), points));\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #endif\n}\nvec4 front () {\n return gizmo_fs(1.0);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = front(); }"
- },
- "glsl1": {
- "vert": "\nprecision mediump float;\nuniform highp mat4 cc_matWorld;\n uniform highp mat4 cc_matWorldIT;\nuniform highp mat4 cc_matView;\n uniform highp mat4 cc_matProj;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nvarying vec3 normal_w;\nvarying vec3 pos_w;\nvarying vec3 pos_l;\nvarying vec3 right;\nvarying vec3 up;\nvarying vec3 forward;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n vec4 normal = vec4(a_normal, 0);\n pos_l = a_position;\n pos_w = (cc_matWorld * pos).xyz;\n normal_w = (cc_matWorldIT * normal).xyz;\n right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n return cc_matProj * (cc_matView * cc_matWorld) * pos;\n}\nvoid main() { gl_Position = vert(); }",
- "frag": "\nprecision mediump float;\nmat3 transposeMat3 (mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon (inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1) {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2) {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3) {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4) {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5) {\n n = 0;\n }\n else if (config == 6) {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7) {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8) {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9) {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10) {\n n = 0;\n }\n else if (config == 11) {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12) {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13) {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14) {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15) {\n n = 4;\n }\n if (n == 3) L[3] = L[0];\n if (n == 4) L[4] = L[0];\n}\nfloat IntegrateEdge (vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate (vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transposeMat3(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0) return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4) sum += IntegrateEdge(L[3], L[4]);\n if (n == 5) sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nuniform highp vec4 cc_cameraPos;\n uniform mediump vec4 cc_exposure;\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if CC_USE_LIGHT_PROBE\n vec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n }\n vec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n }\n vec4 CCFragOutput (vec4 color) {\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n }\n#else\n vec4 CCFragOutput (vec4 color) {\n return color;\n }\n#endif\nvarying vec3 normal_w;\nvarying vec3 pos_w;\nvarying vec3 pos_l;\nvarying vec3 right;\nvarying vec3 up;\nvarying vec3 forward;\n uniform vec4 mainColor;\n uniform vec4 cc_sh_linear_const_r;\n uniform vec4 cc_sh_linear_const_g;\n uniform vec4 cc_sh_linear_const_b;\n uniform vec4 cc_sh_quadratic_r;\n uniform vec4 cc_sh_quadratic_g;\n uniform vec4 cc_sh_quadratic_b;\n uniform vec4 cc_sh_quadratic_a;\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n vec3 SHEvaluate(vec3 normal)\n {\n vec3 result;\n #if USE_INSTANCING\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(v_sh_linear_const_r, normal4);\n result.g = dot(v_sh_linear_const_g, normal4);\n result.b = dot(v_sh_linear_const_b, normal4);\n #else\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(cc_sh_linear_const_r, normal4);\n result.g = dot(cc_sh_linear_const_g, normal4);\n result.b = dot(cc_sh_linear_const_b, normal4);\n vec4 n14 = normal.xyzz * normal.yzzx;\n float n5 = normal.x * normal.x - normal.y * normal.y;\n result.r += dot(cc_sh_quadratic_r, n14);\n result.g += dot(cc_sh_quadratic_g, n14);\n result.b += dot(cc_sh_quadratic_b, n14);\n result += (cc_sh_quadratic_a.rgb * n5);\n #endif\n #if CC_USE_HDR\n result *= cc_exposure.w * cc_exposure.x;\n #endif\n return result;\n }\n #endif\n#endif\nvec4 gizmo_fs (float alpha) {\n #if CC_USE_LIGHT_PROBE\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 diffuse = SHEvaluate(N);\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #else\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 V = normalize(cc_cameraPos.xyz - pos_w);\n vec3 points [4];\n points[0] = (forward * 3.0 + right + up) * 40.0;\n points[1] = (forward * 3.0 - right + up) * 40.0;\n points[2] = (forward * 3.0 - right - up) * 40.0;\n points[3] = (forward * 3.0 + right - up) * 40.0;\n vec3 diffuse = LinearToSRGB(mainColor.rgb * LTC_Evaluate(N, V, pos_l, mat3(1), points));\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #endif\n}\nvec4 front () {\n return gizmo_fs(1.0);\n}\nvoid main() { gl_FragColor = front(); }"
- },
- "builtins": {
- "globals": {
- "blocks": [
- {
- "name": "CCGlobal",
- "defines": []
- },
- {
- "name": "CCCamera",
- "defines": []
- }
- ],
- "samplerTextures": [],
- "buffers": [],
- "images": []
- },
- "locals": {
- "blocks": [
- {
- "name": "CCLocal",
- "defines": []
- }
- ],
- "samplerTextures": [],
- "buffers": [],
- "images": []
- },
- "statistics": {
- "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 56,
- "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 50
- }
- },
- "defines": [
- {
- "name": "CC_USE_DEBUG_VIEW",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC",
- "type": "boolean",
- "defines": [
- "CC_USE_DEBUG_VIEW"
- ]
- },
- {
- "name": "CC_SURFACES_ENABLE_DEBUG_VIEW",
- "type": "boolean",
- "defines": [
- "CC_USE_DEBUG_VIEW",
- "CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC"
- ]
- },
- {
- "name": "CC_USE_LIGHT_PROBE",
- "type": "boolean",
- "defines": [],
- "default": 0
- },
- {
- "name": "CC_USE_RGBE_OUTPUT",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE"
- ]
- },
- {
- "name": "CC_USE_FLOAT_OUTPUT",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!CC_USE_RGBE_OUTPUT"
- ]
- },
- {
- "name": "CC_USE_HDR",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "CC_USE_LIGHT_PROBE"
- ]
- },
- {
- "name": "CC_TONE_MAPPING_TYPE",
- "type": "number",
- "defines": [
- "CC_USE_HDR",
- "CC_USE_LIGHT_PROBE",
- "!CC_USE_RGBE_OUTPUT",
- "!CC_USE_FLOAT_OUTPUT"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "HDR_TONE_MAPPING_ACES",
- "type": "boolean",
- "defines": [
- "CC_USE_HDR",
- "CC_TONE_MAPPING_TYPE",
- "CC_USE_LIGHT_PROBE",
- "!CC_USE_RGBE_OUTPUT",
- "!CC_USE_FLOAT_OUTPUT"
- ]
- },
- {
- "name": "USE_INSTANCING",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "CC_USE_LIGHT_PROBE"
- ]
- },
- {
- "name": "USE_FORWARD_PIPELINE",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE"
- ]
- }
- ],
- "name": "internal/editor/light-probe-visualization|gizmo-vs:vert|gizmo-fs:front"
- },
- {
- "blocks": [
- {
- "name": "Constant",
- "members": [
- {
- "name": "mainColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 16,
- "binding": 0
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": [],
- "attributes": [
- {
- "name": "a_position",
- "defines": [],
- "format": 32,
- "location": 0
- },
- {
- "name": "a_normal",
- "defines": [],
- "format": 32,
- "location": 1
- }
- ],
- "varyings": [
- {
- "name": "normal_w",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 0
- },
- {
- "name": "pos_w",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 1
- },
- {
- "name": "pos_l",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 2
- },
- {
- "name": "right",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 3
- },
- {
- "name": "up",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 4
- },
- {
- "name": "forward",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 5
- }
- ],
- "fragColors": [
- {
- "name": "cc_FragColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 16,
- "location": 0
- }
- ],
- "descriptors": [
- {
- "rate": 0,
- "blocks": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCLocal",
- "members": [
- {
- "name": "cc_matWorld",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matWorldIT",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_lightingMapUVParam",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_localShadowBias",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [],
- "stageFlags": 1
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 1,
- "blocks": [
- {
- "name": "Constant",
- "members": [
- {
- "name": "mainColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 16,
- "binding": 0
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 2,
- "blocks": [],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 3,
- "blocks": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCGlobal",
- "members": [
- {
- "name": "cc_time",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_screenSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nativeSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_probeInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_debug_view_mode",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCamera",
- "members": [
- {
- "name": "cc_matView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_cameraPos",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_surfaceTransform",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_screenScale",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_exposure",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitDir",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientSky",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientGround",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogBase",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogAdd",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nearFar",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_viewPort",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- }
- ],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- }
- ],
- "hash": 2568219391,
- "glsl4": {
- "vert": "\nprecision mediump float;\nlayout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n};\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 0) out vec3 normal_w;\nlayout(location = 1) out vec3 pos_w;\nlayout(location = 2) out vec3 pos_l;\nlayout(location = 3) out vec3 right;\nlayout(location = 4) out vec3 up;\nlayout(location = 5) out vec3 forward;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n vec4 normal = vec4(a_normal, 0);\n pos_l = a_position;\n pos_w = (cc_matWorld * pos).xyz;\n normal_w = (cc_matWorldIT * normal).xyz;\n right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n return cc_matProj * (cc_matView * cc_matWorld) * pos;\n}\nvoid main() { gl_Position = vert(); }",
- "frag": "\nprecision mediump float;\nmat3 transposeMat3 (mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon (inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1) {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2) {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3) {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4) {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5) {\n n = 0;\n }\n else if (config == 6) {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7) {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8) {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9) {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10) {\n n = 0;\n }\n else if (config == 11) {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12) {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13) {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14) {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15) {\n n = 4;\n }\n if (n == 3) L[3] = L[0];\n if (n == 4) L[4] = L[0];\n}\nfloat IntegrateEdge (vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate (vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transposeMat3(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0) return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4) sum += IntegrateEdge(L[3], L[4]);\n if (n == 5) sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if CC_USE_LIGHT_PROBE\n vec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n }\n vec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n }\n vec4 CCFragOutput (vec4 color) {\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n }\n#else\n vec4 CCFragOutput (vec4 color) {\n return color;\n }\n#endif\nlayout(location = 0) in vec3 normal_w;\nlayout(location = 1) in vec3 pos_w;\nlayout(location = 2) in vec3 pos_l;\nlayout(location = 3) in vec3 right;\nlayout(location = 4) in vec3 up;\nlayout(location = 5) in vec3 forward;\nlayout(set = 1, binding = 0) uniform Constant {\n vec4 mainColor;\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n};\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n vec3 SHEvaluate(vec3 normal)\n {\n vec3 result;\n #if USE_INSTANCING\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(v_sh_linear_const_r, normal4);\n result.g = dot(v_sh_linear_const_g, normal4);\n result.b = dot(v_sh_linear_const_b, normal4);\n #else\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(cc_sh_linear_const_r, normal4);\n result.g = dot(cc_sh_linear_const_g, normal4);\n result.b = dot(cc_sh_linear_const_b, normal4);\n vec4 n14 = normal.xyzz * normal.yzzx;\n float n5 = normal.x * normal.x - normal.y * normal.y;\n result.r += dot(cc_sh_quadratic_r, n14);\n result.g += dot(cc_sh_quadratic_g, n14);\n result.b += dot(cc_sh_quadratic_b, n14);\n result += (cc_sh_quadratic_a.rgb * n5);\n #endif\n #if CC_USE_HDR\n result *= cc_exposure.w * cc_exposure.x;\n #endif\n return result;\n }\n #endif\n#endif\nvec4 gizmo_fs (float alpha) {\n #if CC_USE_LIGHT_PROBE\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 diffuse = SHEvaluate(N);\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #else\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 V = normalize(cc_cameraPos.xyz - pos_w);\n vec3 points [4];\n points[0] = (forward * 3.0 + right + up) * 40.0;\n points[1] = (forward * 3.0 - right + up) * 40.0;\n points[2] = (forward * 3.0 - right - up) * 40.0;\n points[3] = (forward * 3.0 + right - up) * 40.0;\n vec3 diffuse = LinearToSRGB(mainColor.rgb * LTC_Evaluate(N, V, pos_l, mat3(1), points));\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #endif\n}\nvec4 back () {\n return gizmo_fs(0.2);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = back(); }"
- },
- "glsl3": {
- "vert": "\nprecision mediump float;\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nin vec3 a_position;\nin vec3 a_normal;\nout vec3 normal_w;\nout vec3 pos_w;\nout vec3 pos_l;\nout vec3 right;\nout vec3 up;\nout vec3 forward;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n vec4 normal = vec4(a_normal, 0);\n pos_l = a_position;\n pos_w = (cc_matWorld * pos).xyz;\n normal_w = (cc_matWorldIT * normal).xyz;\n right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n return cc_matProj * (cc_matView * cc_matWorld) * pos;\n}\nvoid main() { gl_Position = vert(); }",
- "frag": "\nprecision mediump float;\nmat3 transposeMat3 (mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon (inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1) {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2) {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3) {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4) {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5) {\n n = 0;\n }\n else if (config == 6) {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7) {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8) {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9) {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10) {\n n = 0;\n }\n else if (config == 11) {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12) {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13) {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14) {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15) {\n n = 4;\n }\n if (n == 3) L[3] = L[0];\n if (n == 4) L[4] = L[0];\n}\nfloat IntegrateEdge (vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate (vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transposeMat3(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0) return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4) sum += IntegrateEdge(L[3], L[4]);\n if (n == 5) sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if CC_USE_LIGHT_PROBE\n vec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n }\n vec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n }\n vec4 CCFragOutput (vec4 color) {\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n }\n#else\n vec4 CCFragOutput (vec4 color) {\n return color;\n }\n#endif\nin vec3 normal_w;\nin vec3 pos_w;\nin vec3 pos_l;\nin vec3 right;\nin vec3 up;\nin vec3 forward;\nlayout(std140) uniform Constant {\n vec4 mainColor;\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n};\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n vec3 SHEvaluate(vec3 normal)\n {\n vec3 result;\n #if USE_INSTANCING\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(v_sh_linear_const_r, normal4);\n result.g = dot(v_sh_linear_const_g, normal4);\n result.b = dot(v_sh_linear_const_b, normal4);\n #else\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(cc_sh_linear_const_r, normal4);\n result.g = dot(cc_sh_linear_const_g, normal4);\n result.b = dot(cc_sh_linear_const_b, normal4);\n vec4 n14 = normal.xyzz * normal.yzzx;\n float n5 = normal.x * normal.x - normal.y * normal.y;\n result.r += dot(cc_sh_quadratic_r, n14);\n result.g += dot(cc_sh_quadratic_g, n14);\n result.b += dot(cc_sh_quadratic_b, n14);\n result += (cc_sh_quadratic_a.rgb * n5);\n #endif\n #if CC_USE_HDR\n result *= cc_exposure.w * cc_exposure.x;\n #endif\n return result;\n }\n #endif\n#endif\nvec4 gizmo_fs (float alpha) {\n #if CC_USE_LIGHT_PROBE\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 diffuse = SHEvaluate(N);\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #else\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 V = normalize(cc_cameraPos.xyz - pos_w);\n vec3 points [4];\n points[0] = (forward * 3.0 + right + up) * 40.0;\n points[1] = (forward * 3.0 - right + up) * 40.0;\n points[2] = (forward * 3.0 - right - up) * 40.0;\n points[3] = (forward * 3.0 + right - up) * 40.0;\n vec3 diffuse = LinearToSRGB(mainColor.rgb * LTC_Evaluate(N, V, pos_l, mat3(1), points));\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #endif\n}\nvec4 back () {\n return gizmo_fs(0.2);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = back(); }"
- },
- "glsl1": {
- "vert": "\nprecision mediump float;\nuniform highp mat4 cc_matWorld;\n uniform highp mat4 cc_matWorldIT;\nuniform highp mat4 cc_matView;\n uniform highp mat4 cc_matProj;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nvarying vec3 normal_w;\nvarying vec3 pos_w;\nvarying vec3 pos_l;\nvarying vec3 right;\nvarying vec3 up;\nvarying vec3 forward;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n vec4 normal = vec4(a_normal, 0);\n pos_l = a_position;\n pos_w = (cc_matWorld * pos).xyz;\n normal_w = (cc_matWorldIT * normal).xyz;\n right = vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]);\n up = vec3(cc_matView[0][1], cc_matView[1][1], cc_matView[2][1]);\n forward = vec3(cc_matView[0][2], cc_matView[1][2], cc_matView[2][2]);\n return cc_matProj * (cc_matView * cc_matWorld) * pos;\n}\nvoid main() { gl_Position = vert(); }",
- "frag": "\nprecision mediump float;\nmat3 transposeMat3 (mat3 v) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\nvoid ClipQuadToHorizon (inout vec3 L[5], out int n) {\n int config = 0;\n if (L[0].z > 0.0) config += 1;\n if (L[1].z > 0.0) config += 2;\n if (L[2].z > 0.0) config += 4;\n if (L[3].z > 0.0) config += 8;\n config = 15;\n n = 0;\n if (config == 0)\n {\n }\n else if (config == 1) {\n n = 3;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 2) {\n n = 3;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 3) {\n n = 4;\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n L[3] = -L[3].z * L[0] + L[0].z * L[3];\n }\n else if (config == 4) {\n n = 3;\n L[0] = -L[3].z * L[2] + L[2].z * L[3];\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n }\n else if (config == 5) {\n n = 0;\n }\n else if (config == 6) {\n n = 4;\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 7) {\n n = 5;\n L[4] = -L[3].z * L[0] + L[0].z * L[3];\n L[3] = -L[3].z * L[2] + L[2].z * L[3];\n }\n else if (config == 8) {\n n = 3;\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n L[1] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = L[3];\n }\n else if (config == 9) {\n n = 4;\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n L[2] = -L[2].z * L[3] + L[3].z * L[2];\n }\n else if (config == 10) {\n n = 0;\n }\n else if (config == 11) {\n n = 5;\n L[4] = L[3];\n L[3] = -L[2].z * L[3] + L[3].z * L[2];\n L[2] = -L[2].z * L[1] + L[1].z * L[2];\n }\n else if (config == 12) {\n n = 4;\n L[1] = -L[1].z * L[2] + L[2].z * L[1];\n L[0] = -L[0].z * L[3] + L[3].z * L[0];\n }\n else if (config == 13) {\n n = 5;\n L[4] = L[3];\n L[3] = L[2];\n L[2] = -L[1].z * L[2] + L[2].z * L[1];\n L[1] = -L[1].z * L[0] + L[0].z * L[1];\n }\n else if (config == 14) {\n n = 5;\n L[4] = -L[0].z * L[3] + L[3].z * L[0];\n L[0] = -L[0].z * L[1] + L[1].z * L[0];\n }\n else if (config == 15) {\n n = 4;\n }\n if (n == 3) L[3] = L[0];\n if (n == 4) L[4] = L[0];\n}\nfloat IntegrateEdge (vec3 v1, vec3 v2) {\n float cosTheta = dot(v1, v2);\n float theta = acos(cosTheta);\n return cross(v1, v2).z * ((theta > 0.001) ? theta/sin(theta) : 4.0);\n}\nvec3 LTC_Evaluate (vec3 N, vec3 V, vec3 P, mat3 Minv, vec3 points[4]) {\n vec3 T1, T2;\n T1 = normalize(V - N*dot(V, N));\n T2 = cross(N, T1);\n Minv = Minv * transposeMat3(mat3(T1, T2, N));\n vec3 L[5];\n L[0] = Minv * (points[0] - P);\n L[1] = Minv * (points[1] - P);\n L[2] = Minv * (points[2] - P);\n L[3] = Minv * (points[3] - P);\n int n;\n ClipQuadToHorizon(L, n);\n if (n == 0) return vec3(0, 0, 0);\n L[0] = normalize(L[0]);\n L[1] = normalize(L[1]);\n L[2] = normalize(L[2]);\n L[3] = normalize(L[3]);\n L[4] = normalize(L[4]);\n float sum = 0.0;\n sum += IntegrateEdge(L[0], L[1]);\n sum += IntegrateEdge(L[1], L[2]);\n sum += IntegrateEdge(L[2], L[3]);\n if (n >= 4) sum += IntegrateEdge(L[3], L[4]);\n if (n == 5) sum += IntegrateEdge(L[4], L[0]);\n sum = max(0.0, sum);\n vec3 Lo_i = vec3(sum, sum, sum);\n return Lo_i;\n}\nuniform highp vec4 cc_cameraPos;\n uniform mediump vec4 cc_exposure;\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if CC_USE_LIGHT_PROBE\n vec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n }\n vec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n }\n vec4 CCFragOutput (vec4 color) {\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n #if CC_USE_HDR && CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n return color;\n }\n#else\n vec4 CCFragOutput (vec4 color) {\n return color;\n }\n#endif\nvarying vec3 normal_w;\nvarying vec3 pos_w;\nvarying vec3 pos_l;\nvarying vec3 right;\nvarying vec3 up;\nvarying vec3 forward;\n uniform vec4 mainColor;\n uniform vec4 cc_sh_linear_const_r;\n uniform vec4 cc_sh_linear_const_g;\n uniform vec4 cc_sh_linear_const_b;\n uniform vec4 cc_sh_quadratic_r;\n uniform vec4 cc_sh_quadratic_g;\n uniform vec4 cc_sh_quadratic_b;\n uniform vec4 cc_sh_quadratic_a;\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n vec3 SHEvaluate(vec3 normal)\n {\n vec3 result;\n #if USE_INSTANCING\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(v_sh_linear_const_r, normal4);\n result.g = dot(v_sh_linear_const_g, normal4);\n result.b = dot(v_sh_linear_const_b, normal4);\n #else\n vec4 normal4 = vec4(normal, 1.0);\n result.r = dot(cc_sh_linear_const_r, normal4);\n result.g = dot(cc_sh_linear_const_g, normal4);\n result.b = dot(cc_sh_linear_const_b, normal4);\n vec4 n14 = normal.xyzz * normal.yzzx;\n float n5 = normal.x * normal.x - normal.y * normal.y;\n result.r += dot(cc_sh_quadratic_r, n14);\n result.g += dot(cc_sh_quadratic_g, n14);\n result.b += dot(cc_sh_quadratic_b, n14);\n result += (cc_sh_quadratic_a.rgb * n5);\n #endif\n #if CC_USE_HDR\n result *= cc_exposure.w * cc_exposure.x;\n #endif\n return result;\n }\n #endif\n#endif\nvec4 gizmo_fs (float alpha) {\n #if CC_USE_LIGHT_PROBE\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 diffuse = SHEvaluate(N);\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #else\n vec3 N = normalize(normal_w) * (float(gl_FrontFacing) * 2.0 - 1.0);\n vec3 V = normalize(cc_cameraPos.xyz - pos_w);\n vec3 points [4];\n points[0] = (forward * 3.0 + right + up) * 40.0;\n points[1] = (forward * 3.0 - right + up) * 40.0;\n points[2] = (forward * 3.0 - right - up) * 40.0;\n points[3] = (forward * 3.0 + right - up) * 40.0;\n vec3 diffuse = LinearToSRGB(mainColor.rgb * LTC_Evaluate(N, V, pos_l, mat3(1), points));\n #if USE_FORWARD_PIPELINE\n return CCFragOutput(vec4(diffuse, mainColor.a * alpha));\n #else\n return vec4(diffuse, mainColor.a * alpha);\n #endif\n #endif\n}\nvec4 back () {\n return gizmo_fs(0.2);\n}\nvoid main() { gl_FragColor = back(); }"
- },
- "builtins": {
- "globals": {
- "blocks": [
- {
- "name": "CCGlobal",
- "defines": []
- },
- {
- "name": "CCCamera",
- "defines": []
- }
- ],
- "samplerTextures": [],
- "buffers": [],
- "images": []
- },
- "locals": {
- "blocks": [
- {
- "name": "CCLocal",
- "defines": []
- }
- ],
- "samplerTextures": [],
- "buffers": [],
- "images": []
- },
- "statistics": {
- "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 56,
- "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 50
- }
- },
- "defines": [
- {
- "name": "CC_USE_DEBUG_VIEW",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC",
- "type": "boolean",
- "defines": [
- "CC_USE_DEBUG_VIEW"
- ]
- },
- {
- "name": "CC_SURFACES_ENABLE_DEBUG_VIEW",
- "type": "boolean",
- "defines": [
- "CC_USE_DEBUG_VIEW",
- "CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC"
- ]
- },
- {
- "name": "CC_USE_LIGHT_PROBE",
- "type": "boolean",
- "defines": [],
- "default": 0
- },
- {
- "name": "CC_USE_RGBE_OUTPUT",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE"
- ]
- },
- {
- "name": "CC_USE_FLOAT_OUTPUT",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!CC_USE_RGBE_OUTPUT"
- ]
- },
- {
- "name": "CC_USE_HDR",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "CC_USE_LIGHT_PROBE"
- ]
- },
- {
- "name": "CC_TONE_MAPPING_TYPE",
- "type": "number",
- "defines": [
- "CC_USE_HDR",
- "CC_USE_LIGHT_PROBE",
- "!CC_USE_RGBE_OUTPUT",
- "!CC_USE_FLOAT_OUTPUT"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "HDR_TONE_MAPPING_ACES",
- "type": "boolean",
- "defines": [
- "CC_USE_HDR",
- "CC_TONE_MAPPING_TYPE",
- "CC_USE_LIGHT_PROBE",
- "!CC_USE_RGBE_OUTPUT",
- "!CC_USE_FLOAT_OUTPUT"
- ]
- },
- {
- "name": "USE_INSTANCING",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "CC_USE_LIGHT_PROBE"
- ]
- },
- {
- "name": "USE_FORWARD_PIPELINE",
- "type": "boolean",
- "defines": [
- "CC_USE_LIGHT_PROBE"
- ]
- }
- ],
- "name": "internal/editor/light-probe-visualization|gizmo-vs:vert|gizmo-fs:back"
- }
- ],
- "combinations": [],
- "hideInEditor": true
- }
|