hello poly counters.Im wanting to create a shader but i have no clue how to do so.there mite be a shader that already does what i need,if so then could someone please point me in the direction? Anyways,ill try to explain the best i can about the shader i need.
Basically,i want to be able to do the following: Have a diffuse map and a ambient occlusion map on a model.And have a light source (point light,directional,ect..) that effects the ambient occlusion map.i want the light to show up on the ambient occlusion map.that way if your AO map is on multiply,then when it displays it on your model,there will be no AO where the light source is.So the point of all this is to have a realistic AO setup.
For example,normally if you have an AO map on a house,the inside will probably be dark (considering the settings you baked the AO with) and if you put a light on the inside of the house,the light will barely light anything because of the AO map.But if the map was effected by the light.then even with an AO map on your house,putting a light in the inside would light the house realistically.
So,any help with this possible shader?
sorry for the complicated explanation.but thats the only way i can explain.
Replies
You could make it like you want with 2 (or 3)passes one diffuse pass and the ao pass which gets the lighting calculation you want and then gets blended with the diffuse afterwards, but i´m not sure if it´s worth the effort(having many passes+ambient map for everything)
so basically
AOMap = tex2D(your AO texture, texCoord)
NdotL = dot(N,L)
newAO= lerp(1.0, AOMap, NdotL)
you would multiply your "newAO" onto the diffuse texture or whatever :P
Hope this is easy enough to read.
*edit: here's a pic.
edit: duh,you said you can multiply that with your diffuse map.so scratch my diffuse map question.
Is this real time? If so, there is a node based shader editor for Unity, so I'm sure you could do it there. It would work on the same idea.
-There also is the ShaderFX editor for Max, same idea would work.
-Inside blender you can have custom shaders, you could ask someone on the blender forums to help you out with a custom OpenGL shader.
If this is offline, then I'm not sure I can help out inside Max or Blender
The only problem with this is the light would probably leak through to the other side of the model and mask it out where you don't want it to mask out... So the best option is to have some sort of Luminance texture(lighting, and shadows) and lerp/mix with that. Blender Game engine has a luminance texture I think.
actually getting ambient light is the hard part. in the above example i'm using a diffuse cubemap, but the easiest way is to just use unity's built-in ambient light, you can access it using the keyword UNITY_LIGHTMODEL_AMBIENT.
can't really help you with making anything like this in max.
Ah, very good idea. I didn't know you could access ambient lighting like that... :poly124: Did you do that with a shader editor in Unity?
thanks again guys!