Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract backend from standard.js #4254

Merged
merged 80 commits into from
Jun 20, 2022
Merged

Conversation

slimbuck
Copy link
Member

@slimbuck slimbuck commented May 17, 2022

This PR contains the first round of changes toward restructuring standard material and its chunks. (For background see #4250).

Summary of changes:

  • extract the material backend chunk-building code from standard.js into lit-shader.js
  • modify chunks into strict frontend and backend
  • reorder runtime chunks so all frontend code executes together (some frontend and backend chunks were previously interleaved)
  • remove toksvig specular AA (see Toksvig specular doesn't work #4260)

Notes:

  • these changes have been tested with test-server and engine examples
  • a followup PR will address the material options driving LitShader, which is currently a monolith that includes all options for frontend and backend

Questions:

Changes to frontend chunks

chunk end changes
clearCoatNormalPS front
  • refrain from generating world CC reflection, now done on the backend instead
  • normalize final world space normal
diffusePS front
  • Fix gamma handling relative to albedo detail
diffuseDetailMapPS front
  • Gamma correct detail map before combining with base albedo
emissivePS front
  • set dEmissive global instead of returning the value in order to bring it in line with the other frontend components
lightmapSingleVert.js front
  • removed (unused)
lightmapDirPS, lightmapSinglePS front
  • renamed the lightmap function to getLightMap() instead of addLightMap()
  • changed the implementation to write dLightmap and dLightmapDir global instead of updating dDiffuseLight and dSpecularLight directly
  • backend now handles combining lightmap in lightmapAddPS and lightmapDirAddPS
normalMapFastPS front
  • removed
normalMapPS front
  • added MAPTEXTURE #define like the other chunks
  • normalize final normal
  • when normal texture isn't defined, calculate normal from geometry normal instead
normalDetailMapPS front
  • remove two (mostly) unnecessary calls to normalise - final normal is normalized instead
clusteredLightPS back
  • remove dead code
endPS back
  • combine emissive with dEmissive instead of a call to getEmission()
lightmapAddPS, lightmapDirAddPS back
  • new chunks for adding the lightmap values passed in from the backend
lightSpecularAnisoGGXPS back
  • added clear coat #define
lightSpecularBlinnPS, lightSpecularPhongPS back
  • added clear coat #define, removed call to antiAliasGlossiness()
normalVertexPS back
  • removed chunk, moved functionality to normalMapPS frontend chunk
specularAaNonePS, specularAaToksvigPS, specularAaToksvigFastPS back
  • removed
startPS back
  • removed global declarations, generate them on demand instead

@slimbuck
Copy link
Member Author

slimbuck commented Jun 8, 2022

@kungfooman that is fixed now - I really appreciate you taking a look!

Copy link
Contributor

@mvaligursky mvaligursky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few small comments, otherwise great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants