Page 2 of 10

Posted: Tue Oct 05, 2010 6:10 pm
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

Posted: Tue Oct 05, 2010 6:17 pm
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.

Posted: Tue Oct 05, 2010 7:07 pm
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.

Posted: Wed Oct 06, 2010 1:15 am
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! ;)

Posted: Thu Oct 07, 2010 8:57 am
by maik
I linked to this thread in the new work in progress list in the Wiki. Hope that's ok.

Posted: Thu Oct 07, 2010 1:14 pm
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.

Posted: Mon Nov 01, 2010 1:24 pm
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.

Posted: Mon Nov 01, 2010 1:29 pm
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.

Posted: Mon Nov 01, 2010 1:35 pm
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

Posted: Mon Nov 01, 2010 6:12 pm
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.

Posted: Mon Nov 01, 2010 8:43 pm
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.

Posted: Mon Nov 01, 2010 8:50 pm
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...

Posted: Mon Nov 01, 2010 9:26 pm
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

Posted: Mon Nov 01, 2010 9:37 pm
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.

Posted: Mon Nov 01, 2010 9:52 pm
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;};

			}; 
		};