Shaders’ Outpost

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

Moderators: winston, another_commander

User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Shaders’ Outpost

Post by JensAyton »

Griff posted an example here related to discussion in the Progress thread. That discussion and the example have been joined together in a new topic.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Shaders’ Outpost

Post by Cody »

Interesting new rank you have there, Ahruman... may I have one, please? Something like Decidedly Dodgy Assassin, maybe?
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Shaders’ Outpost

Post by JensAyton »

I just moved an off-topic post out of here, you know, and it wasn’t even very off.
Storm
Dangerous
Dangerous
Posts: 91
Joined: Mon Jan 30, 2012 10:27 pm
Location: UK

Re: Shaders’ Outpost

Post by Storm »

Hi guys.

Query: How do I define galaxyNumber as a uniform bind in shipdata.plist shaders please?

uniforms =
{
uColorMap = { type = texture; value = 0; };
uNormalMap = { type = texture; value = 1; };
uEffectsMap = { type = texture; value = 2; };
uTime = "universalTime";
uGalaxy = "galaxy_number";
};

... is what I've got in the code but doesn't appear to be correct. Getting [shader.uniform.unpermittedMethod]: Did not bind uniform "uGalaxy" to property -[ShipEntity galaxy_number] - unpermitted method.
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:

Re: Shaders’ Outpost

Post by Commander McLane »

Looking at the rest of the syntax, have you tried "galaxyNumber" instead of "galaxy_number"?
Storm
Dangerous
Dangerous
Posts: 91
Joined: Mon Jan 30, 2012 10:27 pm
Location: UK

Re: Shaders’ Outpost

Post by Storm »

Yep, had tried that previously with no luck also. According to the wiki ( http://wiki.alioth.net/index.php/Shader ... :_uniforms ) right down at the bottom "Additionally, all state query scripting methods ending with _number may be used for the player."

So maybe you can't bind it unless its a player object? :(

I'd like to be able to use it to offset a texture depending on which galaxy the player is in (the docking display screen in my beta TCA.oxp for additional broadcast arrays in other galaxy charts) rather than add like_ships for each chart relisting all the subentities from the template ship.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Shaders’ Outpost

Post by cim »

Storm wrote:
I'd like to be able to use it to offset a texture depending on which galaxy the player is in (the docking display screen in my beta TCA.oxp for additional broadcast arrays in other galaxy charts) rather than add like_ships for each chart relisting all the subentities from the template ship.
Looks like those are player only, yes. A slight hack: in their ship script, set their fuel levels to 0 -> 0.7 LY depending on galaxy, so the fuel uniform will then have the chart number from 0-7.
Storm
Dangerous
Dangerous
Posts: 91
Joined: Mon Jan 30, 2012 10:27 pm
Location: UK

Re: Shaders’ Outpost

Post by Storm »

Thanks Cim, not got it working completely yet, but changing the fuel of the parent entity in the debug console changes the broadcast display on the fly now, so on the right track. :)
User avatar
submersible
Commodore
Commodore
Posts: 264
Joined: Thu Nov 10, 2011 7:49 am

Re: Shaders’ Outpost

Post by submersible »

Please forgive a possibly very novice question. I have been experimenting with shaders by modifying ahruman's cube_map test shaders to use cube maps for all cases. Currently parallax mapping has me a bit stumped. Picking the value for the parallax offset from a cube map was simple enough - however , perturbing the 'real' cube texture coordinates based on the parallax value and the position of the camera is _almost_ working. The effect I see appears correct for some 'faces' of the cube texture, but inverted on other faces.

Code: Select all

	// Get texture coords, using parallax mapping if appropriate
	//
	// float parallax = texture2D(uNormalMap, vTexCoord).a;
	float parallax = textureCube(uNormalMap, vCubeTexCoords).a ;
	parallax *= 0.02;
	vec3 ParallaxCubeTexCoords =  vCubeTexCoords + parallax * vEyeVector;
Storm
Dangerous
Dangerous
Posts: 91
Joined: Mon Jan 30, 2012 10:27 pm
Location: UK

Re: Shaders’ Outpost

Post by Storm »

I'm having trouble with getting uGalaxy (an int, passed as Fuel in Shipdata which is working fine as non-player entities cannot pass galaxyNumber) used to multiply the offset Y-coordinate of a texture. People with older versions of OpenGL are getting error messages about trying to multiply an int with a float. :(

I'm currently trying to create a float offsetY variable as a float based on the value of uGalaxy and use that instead (relevant code pieces):

Code: Select all

uniform int	uGalaxy;
const float offsetY = 0.0;

#ifndef OO_REDUCED_COMPLEXITY
	if(uGalaxy==1){offsetY=0.125;}
	if(uGalaxy==2){offsetY=0.25;}
	if(uGalaxy==3){offsetY=0.375;}
	if(uGalaxy==4){offsetY=0.5;}
	if(uGalaxy==5){offsetY=0.625;}
	if(uGalaxy==6){offsetY=0.75;}
	if(uGalaxy==7){offsetY=0.875;}
#endif
but I'm getting 'if' syntax errors for this. I'm pretty new to programming and so may have the format of the conditional statement wrong but googling so far has not turned up any fixes for me. Help would be appreciated!
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Shaders’ Outpost

Post by cim »

I think you should be able to do:

Code: Select all

uniform int uGalaxy;
float fGalaxy = float(uGalaxy);
to convert the type, and go from there.
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:

Re: Shaders’ Outpost

Post by Commander McLane »

cim wrote:
I think you should be able to do:

Code: Select all

uniform int uGalaxy;
float fGalaxy = float(uGalaxy);
to convert the type, and go from there.
That seems to do the trick for me. I have no errors in the log and see the Snoopers message.
Storm
Dangerous
Dangerous
Posts: 91
Joined: Mon Jan 30, 2012 10:27 pm
Location: UK

Re: Shaders’ Outpost

Post by Storm »

Thanks cim, knew that there was probably an easy way to do it :)
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2481
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Re: Shaders’ Outpost

Post by Griff »

From lusting after the lovely planet screenshots going up in the 'progress' thread i dug out the old Earth example shader (based on the example shader in ATI's Rendermonkey) and added in a small rim light atmosphere effect i pinched off a shader tutorial website
Image
Image
I couldn't find where the old oxp was stored so i've uploaded it again
https://www.box.com/s/8a7b8a4ba5cc6103366e
it just adds some big asteroids textured to look like Earth outside the station when the player launches so they'll be spinning around in all sorts of odd directions :lol:
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: Shaders’ Outpost

Post by Cody »

Rather good fun, blowing multiple mini-Earths to pieces. They do look nice, though!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
Post Reply