About Store Forum Documentation Contact



Post Reply 
How change ambient for material in code?
Author Message
Pherael Offline
Member

Post: #1
How change ambient for material in code?
In editor you can change ambient color for material (Ambient Red, Green and Blue parameters). This is something I want modify in game, but when I tried use LinkShaderParamChanges and Renderer.ambient_color it dosn't work.

If texture technique is Default or Alpha Test nothing happans at all and with Blend Light and Test Blend Light it's overwrite all lighting for material.

It is intendent? If yes, how can change ambient color like in editor with LinkShaderParamChanges?
07-10-2019 10:08 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: How change ambient for material in code?
For that case you should set some initial Material.ambient value at the start (not zero) so ambient shader gets set up for Mesh. This requires additional drawing pass for that material.
07-11-2019 01:00 AM
Find all posts by this user Quote this message in a reply
Pherael Offline
Member

Post: #3
RE: How change ambient for material in code?
Hi, I tried it, and it dosn't work at all. Objects in game have ambient that I set in editor, but it not change in game. I don't think my code is wrong, because I use it for material_color without any issue.

PHP Code:
changes.clear();
changes.New().set(Renderer.ambient_color).set(AmbientVec); // set its value
         
LinkShaderParamChanges(changes); 
mesh->draw(matrix);
UnlinkShaderParamChanges(changes); 
07-11-2019 01:43 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: How change ambient for material in code?
Renderer.ambient_color is not for materials but for global ambient D.ambient.
07-11-2019 03:22 PM
Find all posts by this user Quote this message in a reply
Pherael Offline
Member

Post: #5
RE: How change ambient for material in code?
Ok, thanks for information.
07-11-2019 05:09 PM
Find all posts by this user Quote this message in a reply
Post Reply