Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Announcements and Showcase
sprite sheet
Author Text

samgrady
Registered User
Quote
2022-12-02 21:56:57

done spritesheet shader and coppercube basic logo animation
🔎︎



samgrady
Registered User
Quote
2022-12-02 21:59:40

🔎︎



edwin123
Registered User
Quote
2022-12-02 22:36:09

i like it


Robo
Guest
Quote
2022-12-03 11:34:59

Looks good.

Did you make the spritesheet shader or buy it off just_in_case ?


samgrady
Registered User
Quote
2022-12-03 20:30:04

Robo, i write all by myself, never use any code from other user i think thats good way to improve my coding level (cuz im not programmer)


Robo
Guest
Quote
2022-12-04 00:33:08

You should sell it on itchio then if it works well - ie you just input number vertically and horizontally and it gets the texture number you want from that....I will buy it off you if its not too expensive (like $1-2 or something like that).

Default animated textures in CC are a pain to have to split up a from a sprite sheet and then load each image into CC - its slower and less performance than just having a single texture....

post the link below if you could...cheers.


samgrady
Registered User
Quote
2022-12-04 05:21:52

Robo, there nothing to sell, in "before first drawing do something" execute js:

function shader(x,y,x1,y1){
ccbSetSceneNodeProperty(ccbGetCurrentNode(),"Visible",true);
var vertexShader =
"float4x4 mWorldViewProj; \n" +
"float4x4 mInvWorld; \n" +
"float4x4 mTransWorld; \n" +
"struct VS_OUTPUT \n" +
"{ \n" +
" float4 Position : POSITION; \n" +
" float4 Diffuse : COLOR0; \n" +
" float2 TexCoord : TEXCOORD0; \n" +
"}; \n" +
"VS_OUTPUT main ( in float4 vPosition : POSITION, \n" +
" in float3 vNormal : NORMAL, \n" +
" float2 texCoord : TEXCOORD0 ) \n" +
"{ \n" +
" VS_OUTPUT Output; \n" +
" Output.Position = mul(vPosition, mWorldViewProj); \n" +
" Output.Diffuse = float4(1.0, 1.0, 1.0, 1.0); \n" +
" Output.TexCoord = texCoord; \n" +
" return Output; \n" +
"} ";
var fragmentShader =
"struct PS_OUTPUT \n" +
"{ \n" +
" float4 RGBColor : COLOR0; \n" +
"}; \n" +
"sampler2D tex0; \n" +
"PS_OUTPUT main( float2 TexCoord : TEXCOORD0, \n" +
" float4 Position : POSITION, \n" +
" float4 Diffuse : COLOR0 ) \n" +
"{ \n" +
" PS_OUTPUT Output; \n" +
" TexCoord.y = (TexCoord.y+"+y1+")/"+y+"; \n"+
" TexCoord.x = (TexCoord.x+"+x1+")/"+x+"; \n"+
" float4 col = tex2D( tex0, TexCoord); \n" +
" Output.RGBColor = Diffuse * col; \n" +
" Output.RGBColor *= 1.0; \n" +
" return Output; \n" +
"}";
var newMaterial = ccbCreateMaterial(vertexShader, fragmentShader, 0, null);
ccbSetSceneNodeMaterialProperty(ccbGetCurrentNode(), 0, "Type", newMaterial);
}

and call shader(x_length,y_length,x_frame,y_frame) inside of "every few seconds do something" (x_frame and y_frame is yor frame so you can call this part of image in any way you want)


Robo
Guest
Quote
2022-12-05 02:47:45

Very cool 'samgrady' - thanks for that.
I haven't had much time for shaders of late - it worked !

Step 1 - I just created some global variables on first load:

var partX = 0;
var partY = 0;
var maxX = 4; // horizontal images
var maxY = 4; // vertical images

Step 2 - then just ran this little bit of code every 100ms:

if (partX == maxX) {
partX = 0;
partY += 1;
if (partY == maxY) {partY = 0;
}}

shader(maxX, maxY, partX, partY);
partX += 1;

and badda boom !! - she's a goer !!
I also just changed line 42 from 0 to 13 for transparent...

Cheers !


samgrady
Registered User
Quote
2022-12-05 15:51:59

Robo, i'm just start to study shader so glad to help)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact