Page 25 of 29

Re: Shaders’ Outpost

Posted: Mon Feb 13, 2012 9:36 pm
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.

Re: Shaders’ Outpost

Posted: Mon Feb 13, 2012 9:44 pm
by Cody
Interesting new rank you have there, Ahruman... may I have one, please? Something like Decidedly Dodgy Assassin, maybe?

Re: Shaders’ Outpost

Posted: Mon Feb 13, 2012 9:47 pm
by JensAyton
I just moved an off-topic post out of here, you know, and it wasn’t even very off.

Re: Shaders’ Outpost

Posted: Wed Mar 07, 2012 10:42 pm
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.

Re: Shaders’ Outpost

Posted: Thu Mar 08, 2012 7:52 am
by Commander McLane
Looking at the rest of the syntax, have you tried "galaxyNumber" instead of "galaxy_number"?

Re: Shaders’ Outpost

Posted: Thu Mar 08, 2012 10:54 am
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.

Re: Shaders’ Outpost

Posted: Thu Mar 08, 2012 11:22 am
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.

Re: Shaders’ Outpost

Posted: Thu Mar 08, 2012 12:09 pm
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. :)

Re: Shaders’ Outpost

Posted: Mon Mar 12, 2012 1:18 pm
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;

Re: Shaders’ Outpost

Posted: Mon Mar 19, 2012 12:16 pm
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!

Re: Shaders’ Outpost

Posted: Mon Mar 19, 2012 12:35 pm
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.

Re: Shaders’ Outpost

Posted: Mon Mar 19, 2012 2:47 pm
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.

Re: Shaders’ Outpost

Posted: Mon Mar 19, 2012 6:29 pm
by Storm
Thanks cim, knew that there was probably an easy way to do it :)

Re: Shaders’ Outpost

Posted: Sun Apr 22, 2012 9:18 pm
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:

Re: Shaders’ Outpost

Posted: Sun Apr 22, 2012 11:03 pm
by Cody
Rather good fun, blowing multiple mini-Earths to pieces. They do look nice, though!