cables-gl / cables

cables is a tool for creating beautiful interactive content
https://cables.gl
MIT License
348 stars 15 forks source link

PhongMaterial environment mapping #1558

Closed simodrws closed 4 years ago

simodrws commented 4 years ago

https://pdfs.semanticscholar.org/682d/7fd5a2516a4bb6340a9893b0493ece1bcd0c.pdf

float MIPlevel =
     log2(environmentMapWidth * sqrt(3)) -
     0.5 * log2(glossyExponent + 1);
gl_FragColor.rgb =
    lambertianCoefficient * textureCubeLod(environmentMap,
                                       worldSpaceNormal,
                                       maxMIPLevel).rgb +
    glossyCoefficient     * textureCubeLod(environmentMap,
                                       worldSpaceReflectionVector,
                                       MIPlevel).rgb;
pandrr commented 4 years ago

i added matcap env map, would be cool to switch between cubemap and matcap (and cubemap: autodetect if real cubemap or equirectangular)...

steam0r commented 4 years ago

need an envmapping-mask texture input

simodrws commented 4 years ago

https://www.cg.tuwien.ac.at/courses/Seminar/SS2001/envmap/environment_mapping.pdf

gonna need a few reads on this one

pandrr commented 4 years ago
simodrws commented 4 years ago

breite = höhe --> spherical sonst equirect

simodrws commented 4 years ago

reevaluate matcap formula

simodrws commented 4 years ago

https://my.eng.utah.edu/~cs5610/handouts/environmentMapping.pdf

simodrws commented 4 years ago

https://cseweb.ucsd.edu/~ravir/6160/papers/illumap.pdf

simodrws commented 4 years ago

unified approach to env mapping:

http://timehost.cs.ucl.ac.uk/staff/j.kautz/publications/unifiedRW00.pdf

simodrws commented 4 years ago

even more :

http://www0.cs.ucl.ac.uk/staff/j.kautz/GameCourse/05_EnvMaps.pdf

simodrws commented 4 years ago

PR is up :)

pandrr commented 4 years ago

then merge it and test it make sure everything worksd

simodrws commented 4 years ago

ok

pandrr commented 4 years ago

please provide example patch then its easier for me to test

simodrws commented 4 years ago

Here is an example patch for you to test it:

https://dev.cables.gl/edit/QA-fmi

:) i am quite happy with it. took me a while to figure out all the stuff but I think we're there.. if you notice anything plz feel free to share

pandrr commented 4 years ago

looks great!

i guess we should have an env mask textureinput

so we can control where something is reflective and where not

(lets ignore all the roughness stuff for now, that we can do in pbr)

simodrws commented 4 years ago

Uhm... the input is there already.. it's called "Luminance Mask" .. maybe rename the port to "Env Map Mask"? (for clarity) @pandrr

pandrr commented 4 years ago

yes please rename it , luminance mask doesnt really make it clear

simodrws commented 4 years ago

Updated!