Is it possible to edit a texture's properties via code?

Discussions about Coding and Scripting
Post Reply
Christ
Novice
Posts: 23
Joined: Wed May 31, 2017 11:40 pm

Is it possible to edit a texture's properties via code?

Post by Christ »

I need to make sure all textures in a given map have its bUnlit variable set to false, since Texture is not a child class from Actor, I'm not sure if this can be done or how.
It doesn't have to be that specific, whatever code changes a value from a texture should guide me as to how to do this.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Is it possible to edit a texture's properties via code?

Post by Barbie »

I'm afraid that brushes and their properties (surface properties) are not available if the map is running. If you need this check only seldom, you could export the map as T3D, parse the text file for "Begin Polygon Flags=" and check the following integer if it contains 0x400000 (PF_Unlit).
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Christ
Novice
Posts: 23
Joined: Wed May 31, 2017 11:40 pm

Re: Is it possible to edit a texture's properties via code?

Post by Christ »

I was working on a Dark Match update and it works alright but unlit surfaces don't look so good. Thank you.
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Is it possible to edit a texture's properties via code?

Post by sektor2111 »

I'm not sure that you can really screw them, but somehow it seems that they can be read.

Exist a shadow decal in OlExtras (OldSkool chapter) which is able to make step sounds dependent on texture where is being attached for some more realistic foot steps sounds. I don't know if you can deal with changing surface or with angles...
This is the only deal with Textures related to Level as I know so far (perhaps NWIII has also something for explosions - wall fragments - if I'm not mistaking)... But I'm not sure if Textures can be easily modified...
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Is it possible to edit a texture's properties via code?

Post by PrinceOfFunky »

sektor2111 wrote:I'm not sure that you can really screw them, but somehow it seems that they can be read.

Exist a shadow decal in OlExtras (OldSkool chapter) which is able to make step sounds dependent on texture where is being attached for some more realistic foot steps sounds. I don't know if you can deal with changing surface or with angles...
This is the only deal with Textures related to Level as I know so far (perhaps NWIII has also something for explosions - wall fragments - if I'm not mistaking)... But I'm not sure if Textures can be easily modified...
I think this is the class you're talking about:

Code: Select all

class PalmShadow extends Decal;

var Texture Shadow;
var Texture Scripted;
var float ShadowUStart;
var float ShadowUsize;
var float ShadowVStart;
var float ShadowVsize;

simulated event PostBeginPlay()
{
    Shadow = Texture(DynamicLoadObject("davidmgras.palmsil", class'Texture'));
    Scripted = Texture;
    ScriptedTexture(Texture).NotifyActor = self;
    return;
}

simulated event Destroyed()
{
    super.Destroyed();
    ScriptedTexture(Texture).NotifyActor = none;
    return;
}

simulated function SetShadow(Actor Other, Vector BaseLoc)
{
    local float Length;
    local Vector temp, Temp2;
    local bool oldfog;

    temp = BaseLoc;
    temp.Z -= (float(25) * Other.DrawScale);
    Temp2 = Location - BaseLoc;
    Temp2.Z = 0.0;
    temp -= (Other.CollisionRadius * Normal(Temp2));
    Length = VSize(temp - Location) + float(25);
    DrawScale = FMax(Length / float(96), 0.20 * Other.DrawScale);
    ShadowUsize = (0.20 * Other.DrawScale) / DrawScale;
    ShadowUsize *= float(Texture.USize);
    ShadowUStart = (float(Texture.USize) - ShadowUsize) / float(2);
    ShadowVsize = ((Length - float(25)) / float(96)) / DrawScale;
    ShadowVsize *= float(Texture.VSize);
    ShadowVStart = (((float(Texture.VSize) - ShadowVsize) / float(2)) - (float(25) / DrawScale)) - ((float(2) * Other.CollisionRadius) / DrawScale);
    oldfog = Region.Zone.bFogZone;
    Region.Zone.bFogZone = false;
    // End:0x1FB
    if((AttachDecal(100.0, float(1000) * Normal(Location - BaseLoc))) == none)
    {
        LogInternal("Failed to attach decal!!!", 'PalmShadow');
        Destroy();
    }
    Region.Zone.bFogZone = oldfog;
    return;
}

event RenderTexture(ScriptedTexture Tex)
{
    Tex.UnresolvedNativeFunction_97(ShadowUStart, ShadowVStart, ShadowUsize, ShadowVsize, 0.0, 0.0, float(Shadow.USize), float(Shadow.VSize), Shadow, false);
    return;
}

defaultproperties
{
    Sounds=false
}
They dynamically create a texture object and render it onto the scripted texture which is used as a decal, looks like RenderTexture() can be called in any class then...
The native function "AttachDecal" from within Decal.uc is the only native function which lets you project a texture onto a surface:

Code: Select all

simulated native function Texture AttachDecal( float TraceDistance, optional vector DecalDir ); // trace forward and attach this decal to surfaces.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Is it possible to edit a texture's properties via code?

Post by sektor2111 »

Oh well... in topic was asked about changing Texture properties not really the Texture, however I would love a mutator (sorta "map patcher") able to change some lousy walls... And that unknownfunction is not part of UT I'm guessing... It was some "PawnShadow" or such doing STEPSOUNDS depending on texture attached, a tree is not walking, nvm, I'll try something...
Perhaps I have to fool around with XCGE at this point...
Edit:
I got an idea: Masking them with some decoration with a plane mesh spawned in the right place for covering the ugly crap - in run-time ?
Last edited by sektor2111 on Fri Jun 02, 2017 8:42 pm, edited 1 time in total.
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Is it possible to edit a texture's properties via code?

Post by PrinceOfFunky »

sektor2111 wrote:Oh well... in topic was asked about changing Texture properties not really the Texture, however I would love a mutator (sorta "map patcher") able to change some lousy walls... And that unknownfunction is not part of UT I'm guessing... It was some "PawnShadow" or such doing STEPSOUNDS depending on texture attached, a tree is not walking, nvm, I'll try something...
Perhaps I have to fool around with XCGE at this point...
sn260591 wrote:Not necessary to edit packages. D3d10 can use external textures http://kentie.net/article/d3d10drv/page2.htm#overrides
Example:
d3d10_test.zip
From here: viewtopic.php?f=5&t=6469#p76239
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Is it possible to edit a texture's properties via code?

Post by Barbie »

I'm not sure yet for what case the thread opener wants to access Textures: while map is running (aka "playing the map") or while map is opened in UnrealEd? If latter it should be possible to access Brushes and Textures, too.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Christ
Novice
Posts: 23
Joined: Wed May 31, 2017 11:40 pm

Re: Is it possible to edit a texture's properties via code?

Post by Christ »

Like I mentioned, I'm working on a Dark Math mutator which turns off all LightBrightness and AmbientBrightness, however, bUnlit textures still "light up" which doesn't look right at all, I wanted to turn all textures to bUnlit=False while the game runs so it all looks dark, however since Texture is not a child class from Actor I can't use ForEach AllActors. In the editor I can do that in two seconds but I don't want to replicate maps just to do that minimal change.
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Is it possible to edit a texture's properties via code?

Post by sektor2111 »

Try then "ConsoleCommand" but it must be adjusted for clients because there are visual related things.
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Is it possible to edit a texture's properties via code?

Post by JackGriffin »

I messed a bit with this idea, trying to create something that allowed the player to control lighting on the entire map on-the-fly. The simpler thread about it was here: http://www.oldunreal.com/cgi-bin/yabb2/ ... 1454258989 and then there was a much deeper discussion held via PM's and the private board. The end result is that console commands can work in a lot of instances but depending on the replication of the object you are trying to affect it may not work correctly each and every time. I ended up discarding the idea and doing it another way because of this.
So long, and thanks for all the fish
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Is it possible to edit a texture's properties via code?

Post by PrinceOfFunky »

JackGriffin wrote:I messed a bit with this idea, trying to create something that allowed the player to control lighting on the entire map on-the-fly. The simpler thread about it was here: http://www.oldunreal.com/cgi-bin/yabb2/ ... 1454258989 and then there was a much deeper discussion held via PM's and the private board. The end result is that console commands can work in a lot of instances but depending on the replication of the object you are trying to affect it may not work correctly each and every time. I ended up discarding the idea and doing it another way because of this.
Are you trying to just modify Light instances properties in real time?
"Your stuff is known to be buggy and unfinished/not properly tested"
JackGriffin
Godlike
Posts: 3774
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Is it possible to edit a texture's properties via code?

Post by JackGriffin »

Light instances you can modify (mostly) but it's their effects on the level and actors that causes the problems. It can get really involved and you have to make a bunch of checks and even then I was never satisfied once it got to online testing. There's a lot of information getting generated and applied to the map when you rebuild lighting, at least more than I really thought was getting made. Once this stuff gets applied to the map it just can't be changed in the needed ways.

This gets a little off-tangent but the best solution I found was invoking negative lighting (darkness "light" actor that functions as a reverse light) in the places where replication prevented me from killing the light source I wanted to remove. Sadly this answer only works with Unreal and Smirf's updates. Even then it looked more like a smudge than I wanted and that's why I discarded the entire idea.
So long, and thanks for all the fish
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Is it possible to edit a texture's properties via code?

Post by PrinceOfFunky »

Well, you cannot do it easily with standard maps, but you can make a map using only TriggerLights, there will be a loss of quality but you'll gain full control of all the lights.
"Your stuff is known to be buggy and unfinished/not properly tested"
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Is it possible to edit a texture's properties via code?

Post by sektor2111 »

So maps with triggeredlight are a "loss of quality"... Probably for those who cannot use them and don't know them.

Else, once again, topic is about MODIFYING Texture's properties and not new maps more exactly removing bUnlit because they are not suitable for a Dark Match. Something like...

Code: Select all

ConsoleCommand ("SET TEXTURE BUNLIT FALSE");
:arrow: At least bTranslucent works for sure...
Post Reply