{"action":"created","issue":{"url":"https://api.github.com/repos/gonetz/GLideN64/issues/1581","repository_url":"https://api.github.com/repos/gonetz/GLideN64","labels_url":"https://api.github.com/repos/gonetz/GLideN64/issues/1581/labels{/name}","comments_url":"https://api.github.com/repos/gonetz/GLideN64/issues/1581/comments","events_url":"https://api.github.com/repos/gonetz/GLideN64/issues/1581/events","html_url":"https://github.com/gonetz/GLideN64/pull/1581","id":259288911,"number":1581,"title":"Optimize blender shaders","user":{"login":"loganmc10","id":848146,"avatar_url":"https://avatars0.githubusercontent.com/u/848146?v=4","gravatar_id":"","url":"https://api.github.com/users/loganmc10","html_url":"https://github.com/loganmc10","followers_url":"https://api.github.com/users/loganmc10/followers","following_url":"https://api.github.com/users/loganmc10/following{/other_user}","gists_url":"https://api.github.com/users/loganmc10/gists{/gist_id}","starred_url":"https://api.github.com/users/loganmc10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loganmc10/subscriptions","organizations_url":"https://api.github.com/users/loganmc10/orgs","repos_url":"https://api.github.com/users/loganmc10/repos","events_url":"https://api.github.com/users/loganmc10/events{/privacy}","received_events_url":"https://api.github.com/users/loganmc10/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-09-20T20:18:47Z","updated_at":"2017-09-20T21:19:55Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/gonetz/GLideN64/pulls/1581","html_url":"https://github.com/gonetz/GLideN64/pull/1581","diff_url":"https://github.com/gonetz/GLideN64/pull/1581.diff","patch_url":"https://github.com/gonetz/GLideN64/pull/1581.patch"},"body":"Based on discussion in https://github.com/gonetz/GLideN64/issues/1555\r\n\r\nI've copied the new code below so it's easier to look at, the git diff is a little messy.\r\n\r\nI haven't tested this on any GLES devices, but it gets rid of all the if statements as well as any non-constant array indexing.\r\n\r\nThanks to @standard-two-simplex for the help\r\n\r\n```\r\nclass ShaderBlender1 : public ShaderPart\r\n{\r\npublic:\r\n\tShaderBlender1()\r\n\t{\r\n\t\tm_part =\r\n\t\t\t\"  if (uForceBlendCycle1 != 0) {\t\\n\"\r\n\t\t\t\"    muxPM[0] = clampedColor;\t\t\\n\"\r\n\t\t;\r\n\t\tif (g_cycleType == G_CYC_2CYCLE) {\r\n\t\t\tm_part +=\r\n\t\t\t\t\"    muxPM[1] = clampedColor;\t\\n\"\r\n\t\t\t\t;\r\n\t\t}\r\n\t\tm_part +=\r\n\t\t\t\"    muxA[0] = clampedColor.a;\t\t\\n\"\r\n\t\t\t\"    lowp float muxa = dot(muxA,vec4(equal(vec4(uBlendMux1[1]),vec4(0,1,2,3))));\t\\n\"\r\n\t\t\t\"    muxB[0] = 1.0 - muxa;\t\t\t\\n\"\r\n\t\t\t\"    lowp vec4 muxpm0 = muxPM*vec4(equal(vec4(uBlendMux1[0]), vec4(0,1,2,3)));\t\\n\"\r\n\t\t\t\"    lowp vec4 muxpm2 = muxPM*vec4(equal(vec4(uBlendMux1[2]), vec4(0,1,2,3)));\t\\n\"\r\n\t\t\t\"    lowp float muxb = dot(muxB,vec4(equal(vec4(uBlendMux1[3]),vec4(0,1,2,3))));\t\\n\"\r\n\t\t\t\"    lowp vec4 blend1 = (muxpm0 * muxa) + (muxpm2 * muxb);\t\\n\"\r\n\t\t\t\"    clampedColor.rgb = clamp(blend1.rgb, 0.0, 1.0);\t\t\\n\"\r\n\t\t\t\"  }\t\t\t\t\t\t\t\t\\n\"\r\n\t\t\t;\r\n\t}\r\n};\r\n\r\nclass ShaderBlender2 : public ShaderPart\r\n{\r\npublic:\r\n\tShaderBlender2()\r\n\t{\r\n\t\tm_part =\r\n\t\t\t\"  if (uForceBlendCycle2 != 0) {\t\\n\"\r\n\t\t\t\"    muxPM[0] = clampedColor;\t\t\\n\"\r\n\t\t\t\"    muxPM[1] = vec4(0.0);\t\t\t\\n\"\r\n\t\t\t\"    muxA[0] = clampedColor.a;\t\t\\n\"\r\n\t\t\t\"    lowp float muxa = dot(muxA,vec4(equal(vec4(uBlendMux2[1]),vec4(0,1,2,3)))); \\n\"\r\n\t\t\t\"    muxB[0] = 1.0 - muxa;\t\t\t\\n\"\r\n\t\t\t\"    lowp vec4 muxpm0 = muxPM*vec4(equal(vec4(uBlendMux2[0]), vec4(0,1,2,3)));  \\n\"\r\n\t\t\t\"    lowp vec4 muxpm2 = muxPM*vec4(equal(vec4(uBlendMux2[2]), vec4(0,1,2,3)));  \\n\"\r\n\t\t\t\"    lowp float muxb = dot(muxB,vec4(equal(vec4(uBlendMux2[3]),vec4(0,1,2,3))));\t\\n\"\r\n\t\t\t\"    lowp vec4 blend2 = muxpm0 * muxa + muxpm2 * muxb;\t\\n\"\r\n\t\t\t\"    clampedColor.rgb = clamp(blend2.rgb, 0.0, 1.0);\t\\n\"\r\n\t\t\t\"  }\t\t\t\t\t\t\t\t\\n\"\r\n\t\t\t;\r\n\t}\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/gonetz/GLideN64/issues/comments/330984329","html_url":"https://github.com/gonetz/GLideN64/pull/1581#issuecomment-330984329","issue_url":"https://api.github.com/repos/gonetz/GLideN64/issues/1581","id":330984329,"user":{"login":"theboy181","id":9299743,"avatar_url":"https://avatars3.githubusercontent.com/u/9299743?v=4","gravatar_id":"","url":"https://api.github.com/users/theboy181","html_url":"https://github.com/theboy181","followers_url":"https://api.github.com/users/theboy181/followers","following_url":"https://api.github.com/users/theboy181/following{/other_user}","gists_url":"https://api.github.com/users/theboy181/gists{/gist_id}","starred_url":"https://api.github.com/users/theboy181/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theboy181/subscriptions","organizations_url":"https://api.github.com/users/theboy181/orgs","repos_url":"https://api.github.com/users/theboy181/repos","events_url":"https://api.github.com/users/theboy181/events{/privacy}","received_events_url":"https://api.github.com/users/theboy181/received_events","type":"User","site_admin":false},"created_at":"2017-09-20T21:19:55Z","updated_at":"2017-09-20T21:19:55Z","author_association":"NONE","body":"Not compatible with PJ64? \r\n"}}
{"actor":{"display_login":"theboy181"}}