ZygoUgo's OXPs!

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

User avatar
ZygoUgo
---- E L I T E ----
---- E L I T E ----
Posts: 406
Joined: Mon Nov 17, 2008 4:15 pm
Location: Blighty

Post by ZygoUgo »

http://www.mediafire.com/?utvwba6712wzelf
@Smiv's.. You learn something new every day :D I've edited the file extension to match the others, v1.1 update! It's also reasonably smaller as there were a couple of textures in there left over from testing
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Downloaded - I'll give it a go. This quirk catches people all the time. I did correct my version, so have been enjoying these for a few days now. I can't run shaders but they are still lovely.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Yep, that works nicely...

Image

Looks like it's covered in space-Lichen - weird but nice. :)

By the way the .png extension can be upper or lower-case as long as they are the same. Lower-case is probably more conventional.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Nonono! :)

The craters are revealing brigher material underneath the much darker surface layer... As per the dirty snoball concept adopted for most comet nuclei! ;)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2020
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post by maik »

I linked to this thread in the new work in progress list in the Wiki. Hope that's ok.
User avatar
Pangloss
---- E L I T E ----
---- E L I T E ----
Posts: 303
Joined: Wed Dec 13, 2006 5:57 pm
Location: Scranton, PA (via Stevenage, Herts)

Post by Pangloss »

Just dowloaded, hopped to a system with some Rock Hermits, let's have a look --

Image

-- oh, oh my. It's beautiful. Can't wait for the boulders and splinters to be rendered in a similar fashion.
"All is for the best in this best of all possible worlds..."
Dr.Pangloss, Voltaire's 'Candide'.

Image
User avatar
ZygoUgo
---- E L I T E ----
---- E L I T E ----
Posts: 406
Joined: Mon Nov 17, 2008 4:15 pm
Location: Blighty

Post by ZygoUgo »

Thanks everyone :D
Erm, bit of a muddle at the mo as I'm trying to grasp basic scripting/plist interaction.
The script probably doesn't even function, but until I can get the Ship data to read it I can't test it.. Help!!
Here's the first entry in ship data, followed by the script. I'm guessing I just can't do it this way, but why? I need to understand, thanks for any help!

Code: Select all

{
	"asteroid-alternative" =
	{
		roles = "asteroid oolite-asteroid asteroid-alternative zygoroid zygosparkle";
    name = "Asteroid";
    scanClass = "CLASS_ROCK";
	  max_flight_pitch = 0.1;
	  max_flight_roll = 0.1;
	  max_flight_speed = 5;
		smooth = yes;	// Set to yes if using a normal-smoothed target mesh in Blender.
		model = "ZygoUgo-asteroid1.dat";
		
		materials =
		{
			"ZygoUgo-asteroid1" =
			{
				diffuse_map = "ASTaDIFFUSE.png";
			  //diffuse = "1 0.9 0.7 1";
			  script = "ColouroidsB.js";
			
				normal_and_parallax_map = "ZygoUgo-asteroid1-normal.png";
				parallax_scale = 0.02;
        parallax_bias = -0.01;
				
				//specular_modulate_color
				specular_map = "ZygoUgo-asteroid1-specularSparkles.png";
				shininess = 127;					// Maximum specularity - this is modulated by alpha channel of specular_map  
				// Originally specular = (0.8, 0.8, 0.85, 1);
				specular = (0, 0, 0, 0);	// Maximum intensity (and colouring) of specular effect - specular_map RGB
				// is modulated by this.
			};
		};
	};
And the script..

Code: Select all

this.name				= "ColouroidsB";
this.author				= "ZygoUgo";
this.copyright			= "Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license with clauses"
this.description			= "Random tints to asteroids without external shaders";
this.version			= "1.0";

function zygodiffuse(xr,xg,xb)
   {
     if(this.ship.hasRole("zygoroid"))
        {
        xr = parseInt (Math.random() * 1 + 0.15 (num.toFixed(4)+"xr"));
        xg = parseInt (Math.random() * 1 + 0.13 (num.toFixed(4)+"xg"));
        xb = parseInt (Math.random() * 1 + 0.1 (num.toFixed(4)+"xb"));
        RGBvalues = (diffuse = "xr xg xb 1"); 
        return RGBvalues;
       }
}
EDIT.. Ooh yeah, the values reading 0.1.. of Math.random are only where they are to allow strong colours for testing, the 0.1's will be replaced by 0.9's and are weighted towards the brown range, but should allow for other subtle colours too.
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

Wait for someone more knowledgeable than I to wander by, but I think you'll find the stuff you're doing in a script actually needs to be done in a shader.
User avatar
ZygoUgo
---- E L I T E ----
---- E L I T E ----
Posts: 406
Joined: Mon Nov 17, 2008 4:15 pm
Location: Blighty

Post by ZygoUgo »

Ah, well, my thinking is that the 'diffuse' calling is already inbuilt without shaders which is why I'm trying to bend it to mix colours, in order for it to still work with shaders turned off, my logic being that the military manta ray is still coloured in this mode as I have re-painted it a bright green in my version.
However I have little knowledge on the details of this myself either :D
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Like Cheyd says. What you are doing is a shader, not a script.

Griff is the resident shader wizard, so you should perhaps ask him how to correcty attach a shader to an entity. One of the developers could certainly help as well.
User avatar
ZygoUgo
---- E L I T E ----
---- E L I T E ----
Posts: 406
Joined: Mon Nov 17, 2008 4:15 pm
Location: Blighty

Post by ZygoUgo »

Hi! The problem is I want this to still work with shaders turned off, any advice from Griff is more than welcome. The script is only there to act as a DLL to spit out the variable that should be at that particular line in the ship-data, it shouldn't necessarily have anything to do with ship colours.
It would be the same thing if I wanted gun co-ordinates in the shipdata to vary randomly by being read from a script instead.
No idea I'm probably being nieve so as I said, any help is more than welcome.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

By the way, you can change the material of a ship/entity (ie its texture) using javascript now.

If the player isn't using shaders (yep, detectable via js! :) ), you could switch between 2 (or 3, etc) slightly different non-shader textures...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

I don't think that scripts are able to modify textures, as Kaks suggest your best bet might be to manually re-tint a few extra copies of your texture map in a graphics editing program and use a script to randomly select one as the diffuse texture when your asteroid is spawned (i think Eric has done something like this in his Asteroid Storm oxp updates) but i suppose this makes the oxp a bigger download and more of a graphics memory hog than you want it to be. I don't think there's going to be a way to recolour a texturemap on the fly without using shaders and even then it might be best to limit it to a 'full shader mode' only effect as the complete texture isn't recoloured in one go and held in memory in it's modified state ready to be fitted onto the model, as each polygon fragment is worked on the relevant pixels from the texture map are looked up, modified by the shader code and then passed to the frame buffer before the next polygon fragment is worked on - i'm not sure how small these polygon fragments are but they're probably smaller than the surface area of one pixel from the texture map, it all adds up to a massive amount of sums that need to get done per frame
Erk! RTFM Griff! :D
Last edited by Griff on Mon Nov 01, 2010 9:44 pm, edited 3 times in total.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

That's not what Kaks is saying - you can apply tints to textures via js using the setMaterials property.

It's not quite as powerful as using a different texture (although that is also possible by js), but you can use it to dye a texture a different colour, or to change some of the other attributes.

One of my recent OXPs uses this technique - I don't remember offhand which one I did it in though.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Well i never, i didn't realise all that stuff was possible! So can the 'Materials' access the randomUnitVector stuff that the shaders can, eg would this work?

Code: Select all

	materials = 
		{ 
			"myasteroidtexture.png" = 
			{ 

				diffuse_color  = {type = "randomUnitVector"; scale = 0.25;};

			}; 
		};
Post Reply