About Store Forum Documentation Contact



Post Reply 
Intensity value for materials
Author Message
Pixel Perfect Offline
Member

Post: #1
Intensity value for materials
I am able to adjust the RGBA values of the diffuse texture in the Editor but don't seem to have access to the intensity value that's used in the final lighting calculation.

I have some vegetation models that could do with a slight lift in lighting as they appear a little on the dark side under normal lighting conditions (with RGB values all maxed at 1). In my previous engine you could set an intensity value (a multiplier) per material to get round this.

I could of course manually update all of the textures but that's a lot of work so before doing this thought I'd ask the question in case I'm missing something.

Being a programmer I'm a little reliant on other peoples models. If I'd been an artist I suspect this would never have happened in the first place wink
04-14-2013 10:49 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #2
RE: Intensity value for materials
Guess I'm going to have to edit the individual textures then.
04-16-2013 08:20 AM
Find all posts by this user Quote this message in a reply
para Offline
Member

Post: #3
RE: Intensity value for materials
How many textures are we talking about here? For best results manual editing is the way to go anyway..

But just for fun and as an 10min exercise, I quickly cobbled something together, for batch changing the intensity and brightness of images (not true brigthness, just color value addition).. drag & drop the textures on the app window, change sliders, F2 to save (take care as it overwrites the originals!), use the button to move to the next image...
Code:
/******************************************************************************/
Memc<Str> FileNames;
Window   window  ; // gui window
Slider   slider1  ; // gui slider
Slider   slider2  ; // gui slider
Slider   slider3  ; // gui slider
Button   button1  ; // button
int  imgselect=0;
Image img, imgtemp;
/******************************************************************************/
void UpdateImage(ptr)
{
   imgtemp.del();
   img.copy(imgtemp);
   imgtemp.mulAdd(Vec4(slider1()*2,slider1()*2,slider1()*2, 1), Vec4(slider2(),slider2(),slider2(), 0) );  
}
void SelectImage(ptr)
{
   imgselect = Mod( ++imgselect, FileNames.elms());
   img.Import(FileNames[imgselect], -1, IMAGE_2D);
   UpdateImage(NULL);
}
/******************************************************************************/
void Drop(Memc<Str> &names, GuiObj *obj, C Vec2 &screen_pos)
{
   FileNames=names;
   img.Import(FileNames[0], -1, IMAGE_2D);
   UpdateImage(NULL);
}
/******************************************************************************/
void InitPre()
{
   EE_INIT();
   App.drop=Drop;
}
/******************************************************************************/
bool Init()
{
   DefaultTextStyle.color =BLACK;
   Gui   +=window .create(Rect(-0.5, -0.4, 0.5,  0.60), "Texture brightness and intensity");
   window+=slider1.create(Rect( 0.1, -0.2, 0.9, -0.12), 0.5).func(UpdateImage).desc("intensity (color * int)");
   window+=slider2.create(Rect( 0.1, -0.4, 0.9, -0.32), 0.0).func(UpdateImage).desc("brightness (color + bright)");
   window+=slider3.create(Rect( 0.1, -0.6, 0.9, -0.52), 0.0);
   window+=button1.create(Rect( 0.1, -0.8, 0.9, -0.72), "next image").func(SelectImage);  
   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   Gui.update();
   if(Kb.bp(KB_F2)) imgtemp.Export(FileNames[0]);
   return true;
}
/******************************************************************************/
void Draw()
{
   D.clear(WHITE);
   if(FileNames.elms() && imgtemp.is() ) imgtemp.drawFs();
   Gui.draw();
   if(FileNames.elms()) D.text(0, 0.9, FileNames[imgselect]);
}
/******************************************************************************/
04-16-2013 03:51 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #4
RE: Intensity value for materials
Hey thanks Para smile I have image editing software and I'm assuming I could even use some batch conversion in Gimp however I suspect the number of textures will be in the region of 100+ and it's unlikely that a universal set of values that can be applied as a batch would do the job effectively.

I'll give your code a run. Many thanks for that, I appreciate your help.
04-17-2013 08:28 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #5
RE: Intensity value for materials
Many thanks again Para. Your utility worked a treat, will take a little time to get them all converted but without being able to do this in situ in the level editor your util is the next best thing.

Just one small correction required in the code as detailed below, in case anyone else is has use for this. Everything was getting saved to the first file so just replace the third line in the Update function with this:

Code:
if(Kb.bp(KB_F2)) imgtemp.Export(FileNames[imgselect]);
04-18-2013 06:12 PM
Find all posts by this user Quote this message in a reply
Post Reply