9 個の投稿 / 0 new
最終投稿
#1 2018-01-17 19:00

Petrification encroach/spreading help

Yeah, it seems like its a newbie question to ask. But I have a problem(not really a problem considering I barely use the effect)

I wish to use this type of Effect but, I don't want it to instantly appear on the persons body but its more ore less something that spreads (ie: from the legs and up to the rest of the body). Does anyone have any idea or if I need anything to help this work.

2018-01-17 20:12

What effect are you working with? Like, where'd you get the effect from and what's the "something.fx" filename? There's probably more than one effect file out there that does this so I'd like to stay on the same page. I've done similar things in the past with the clipping plane effect I posted a while ago: http://ecchi.iwara.tv/images/clipping-plane-effect-distribution

Basically you can line up two clipping planes at the same position but in the opposite direction and make them move up the body like how you describe. There's a tutorial on how to apply the effect to existing effects, so make one version using the effect and the other not.

2018-01-17 20:49

All the effects within the folder
Stone.fx
Stone2.fx
marble.fx
carbonite.fx
Greystone.fx
Greystoneshiny.fx

I forgot who exactly did it, but it was definitely from deviantart (sockaccountlol, I think). And I'm kind of a bad learner, I've read your notes in the files and I'm not really grasping at it.

2018-01-18 01:58

Looks like he took the link down and wants me to pm him for it so I'll just try to clarify via text.

So what are you stuck on from my notes? Can you get the clipping plane set up normally without involving the stone effect?

Quick crash course on shaders (effects) (TL;DR at the end):

Background Info:

Every effect in MME is a shader program, which is code used directly by the graphics card to draw your object every frame. This code is written in HLSL (High Level Shader Language), but you shouldn't need to know it as long as you know very basic things about programming in general.

Each effect needs to define "techniques", which are sub-programs that define how an object is drawn given certain conditions. For example, if the object is textured, you might use one technique that loads that file and uses it, but if it's not, you could use a completely different one. MMD needs you to define 5 techniques in all: object, object_ss, zplot, shadow, and edge. This is because MMD has to draw and redraw its objects multiple times each frame to get the appearance that it does. For example, to get outlines, it first draws the model all in black and slightly larger using the "edge" technique, and then later draws the model again like normal on top of the outline using the "object" technique, and what doesn't get covered in the second drawing becomes the outline. Object is your basic drawing of the object, object_ss is more advanced and draws shadows on itself (ss stands for "self shadow"), Zplot is for objects casting shadows on things drawn from the light source's perspective, shadow flattens the object to the floor in the direction of the light, and edge is as we already explained.

Each technique can be made up of one or more "passes" which contain one "Vertex Shader" and one "Pixel Shader." Vertex Shaders take the information about a model's vertices like their position and texture coordinates and can make calculations on them. For example, the coordinates the Vertex Shader gets are not relative to the camera, so the Vertex Shader can use geometrical information about the camera to make those conversions.

The Vertex Shader passes whatever information it wants over to the Pixel Shader. As the name implies, the calculation is done per-pixel as opposed to the Vertex Shader which does the calculation only per-vertex. Because of this, we should want to perform more calculations on the Vertex Shader when possible and only use the Pixel Shader when we have to.

While rendering a triangle, the values the Pixel Shader actually uses are interpolated between the values received from the Vertex Shader based on where it is on the triangle. So for example, if you have a pixel you're trying to draw and you know it's on the edge of the triangle in the midpoint between the first two vertices, you know that the texture coordinate to use should similarly be at the midpoint between the texture coordinate of the first two vertices.

If they're simple enough, Vertex Shaders might just pass along the position of the vertex and nothing else, but usually they need to pass multiple pieces of information which is why they need to define a structure which contains all of them. These will usually look like

struct VS_OUTPUT {
    float4 Pos        : POSITION;
    float2 Tex        : TEXCOORD1;
    float3 Normal     : TEXCOORD2;
    float3 Eye        : TEXCOORD3;
    float2 SpTex      : TEXCOORD4;
    float4 Color      : COLOR0; 
    float3 Specular   : COLOR1;
};

It's kinda hard to explain what to do if it's not already in the struct format so it it's not already like that just show me what it does look like.

TL;DR - All you really need to know is that you need to look through your effect for functions labeled with either "VS" or "PS" as part of their name and edit them to use the clipping plane.

So going back to the clipping plane effect, we need to do 3 things:
1. Calculate the position and direction of the clipping plane once at the beginning of the file:

#define PLANE "ClipPlane1.x"

float3 clipPos: CONTROLOBJECT ;
float4x4 clipMat: CONTROLOBJECT ;

float4 calculate_clip_plane() {
	float4 normal = mul(float4(0,0,1,1) ,clipMat);
	normal /= normal.w;
	normal = normalize(float4(normal.xyz - clipPos, 1));
	
	normal.w = - dot(normal.xyz, clipPos) / dot(normal.xyz, normal.xyz); 
	return normal;
	
}

static float4 clipPlane = calculate_clip_plane();

2. Change the Vertex Shaders to calculate the position of the vertex in World coordinates (this just means it's in a form we can compare it to the clipping plane with).

Change the ???_OUTPUT struct I described earlier by adding this line:

float4 WorldPos   : TEXCOORD5;

For each Vertex Shader (VS) you can find, add the line somewhere:

Out.WorldPos = mul( Pos, WorldMatrix);

3. Change the Pixel Shaders to use this value to determine if it is on the correct side of the clipping plane and stop drawing if not.

For each Pixel Shader (PS) you can find, add the line to the beginning. I can't explain easily how this line works but just know that it does:

clip( dot( IN.WorldPos, clipPlane.xyz ) + clipPlane.w );

Hopefully that didn't just make things more confusing. Let me know if any of this made sense.

2018-01-18 15:28

Uh. You lost me the first paragraph in.

2018-01-18 17:23

Okay, so let's go back to the beginning. Does the original clipping plane effect work? Can you move the clipping plane around to see that it cuts the model and makes parts of it invisible?

If that's true, can you open the stone.fx file in a text editing program like Notepad++? Make backup copies of this effect by the way if you're editing them. Can you do a ctrl-f for all mentions of something with "VS" in the name and show me the surrounding few lines?

2018-01-18 18:54

The clipping effects does work, placing it in the accessories I could only have it attach to parts of the humanoid model. I can't move it freely, only by picking a different part of the model would the effect move.

And once I open up the file, it doesn't have "VS", most of it is in Japanese.

2018-01-18 21:15

probably be easier if you explained with pictures

2018-01-19 23:21

See how nicely Sora's feet turn to ice at 7:42-7:48 in this video: https://www.youtube.com/watch?v=JzSzsQxc20A&t=7m42s . The wish here is probably that a nude woman should turn to stone bit by bit in a similar manner? I seems like a good idea to make two versions of the woman for the same position, one entirely of stone and one of flesh. And then move the two clipping planes from top to toe along the woman's body, as described in post #2 here above, in order to bit by bit switch her from visible flesh woman to visible stone woman.