sp614x / optifine

1.8k stars 418 forks source link

Secondary specular color to pass into shader #371

Open dotModded opened 7 years ago

dotModded commented 7 years ago

few things, can we get a secondary specular texture, and can we get a way to do 16 bit textures for normal and specular (hopefully specular 2) this would be greatly appreciated.

sp614x commented 7 years ago

How would the 2nd specular texture be used? Should it be loaded from the resource pack like "xxx_s.png"?

dotModded commented 7 years ago

Just to store more misc information, and_s2 or _a would both work.

sp614x commented 7 years ago

Are all the specular channels used? ChromaHills uses mostly the red and blue channels.

dotModded commented 7 years ago

With the new lighting model I'm fitting, being physically based, coupled with anisotropic reflectance, I'm essentially fitting Disney's material model into the game, it just needs more data than what I can store. I've even tried compressing normals to get a few extra bits.

sp614x commented 7 years ago

Are the "_s2" textures to be supplied by the resource pack? What should be the format?

dotModded commented 7 years ago

Format should be the same as the rest of the textures, RGB 8 with opacity.

jcm2606 commented 7 years ago

I agree with this suggestion. Nuff said.

robobo1221 commented 7 years ago

This suggestion is good. Esspecially when you need more information per block

dotModded commented 7 years ago

This shouldn't be as hard as you imagine, line 378 in ShadersTex is where it sets up the textures to be generated into an atlas, adding it to here should be easy enough. So now we have an atlas, it needs to be added to multiTexID, bindNS texture is important, so is beginRenderPass. I cant tell if ShaderProgramData is being used. line 2962 and 3020 are where the first specular textures are set to be active uniforms.

sp614x commented 7 years ago

Still not clear what should be the contents of the "_s2" texture. It will be supplied by the resource pack, so the RP author will have to know how to create it and how it will be used. For example: rgb = subsurface normal mutation, a = height map factor, etc. Disney BRDFs? https://i0.wp.com/project-asura.com/blog/wp-content/uploads/2015/10/DisneyBRDF_Fig_1.png

dotModded commented 7 years ago

That is how the current system is done, each channel means one thing. It is never used for specular color.

sp614x commented 7 years ago

From SEUS 10:

// Specularity
gl_FragData[3] = vec4(spec.r + spec.g, spec.b, 0.0f, 1.0f); 

How exactly is the specular map used?

dotModded commented 7 years ago

The way I have set things up for a pbr pipeline which is being included in many shaders now due to the ease on the artists, we simply use each component of the texture as a certain type of material parameter ie roughness, reflectance, metallic, emmisive, ao, subsurface amount, and the list goes on, I'm currently building a texture packer to make it even easier, the reason for this is to be able to specify a new color, with metallic it will become reflectance which needs an RGB value; however this is only for metals, emmisive color which is also RGB, and sub surface color which is also RGB, it's just a way to allow the shader to have more information on each surface to allow the proper rendering of all types of materials, this is broken down similar to the way every modern games adopt the rendering of materials. We simply don't have enough space to pass all the information we would want in a material for 8 bit textures.

sp614x commented 7 years ago

What is the current channel mapping for the specular map? The normal map is apparently "rgb = normal dx, dy, dz" and "a = height". It would be nice to document their channel usage.

dotModded commented 7 years ago

Pretty much the accepted standard is rgbo = x -y z height

mindforger commented 7 years ago

@dotModded one thing upfront, i have no idea what you have done and my knowledge to shaders is very small so bare with my stupidness in this case if i say things you have already dealt with :)

as someone who did some rendering on other games having a hard time to remap textures to their respective rendering channels, i would hint (or better said ask) to use common RGBA mappings like they are used to be in common tools like blender, cinema4d and such ...

i just do not want something fucked up like the texture system in eve online -.- that is a MAJOR P.I.T.A. to remap

dotModded commented 7 years ago

@mindforger that's why I'm building a baker, if you are accustomed to working with roughness values and normals this will be a breeze for you. The texture maps can't be done in a standard way for 2 reasons one we cant because we won't ever have unlimited textures, second it would cost so much to lookup all those textures all those times.

sp614x commented 7 years ago

OptiFine could combine the channels when loading them, so a packer is not strictly needed. N monochrome PNGs -> N/4 RBG textures

sp614x commented 6 years ago

Data types for specular channels:

A. From Sagacity159

B. From Zombye

C. Disney's BRDF https://github.com/wdas/brdf/blob/master/src/brdfs/disney.brdf

D. Blender https://docs.blender.org/manual/en/dev/render/cycles/nodes/types/shaders/principled.html

E. CryEngine http://docs.cryengine.com/display/SDKDOC4/Shading

F. Unity https://docs.unity3d.com/Manual/shader-StandardShader.html

dotModded commented 6 years ago

What about support for some more offline options as well like IOR as a color, better support for sub surface like the under layers color, absorbtion values and surface color. Maybe support for anisotropic brdfs so roughness x and roughness y.

sp614x commented 6 years ago

@dotModded are these just specular data types or is some preprocessing needed?