2 registered members (ozgur, TipmyPip),
722
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: BoH_Havoc]
#414587
01/05/13 11:34
01/05/13 11:34
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I thought about creating a shader with relief mapping... It should be possible but I'm not sure how to implement it into a custom shader for shade-c. Are there any information about the #defines (especially the custom vs and ps), so how do they work and what do the input- / output-structs include? also I'd like to know if the depth for the deferred lighting's gBuffer is calculated in the object shader or with a second VIEW*. If it's done in the object shader it should be easy to manipulate it based on the relief-mapping's depth result which makes it possible to use SSAO for the displaced texture EDIT: ...and the shadowing would be correct, too. (except for self-shadowing, which can be done in the object shader)
Last edited by Kartoffel; 01/05/13 15:07.
POTATO-MAN saves the day! - Random
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: rojart]
#414694
01/06/13 17:22
01/06/13 17:22
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
"is it possible to use more then one diffuse textures, both with alpha channel?"
Yes it is. You need a custom pixelshader for that, nothing really complicated but I don't know how to use it. BohHavoc has to answer this.
"very nice effects in 05.c example, it is possible to combine two effects or more at once, eg. mtlDissolve with mtlLivingBloom?"
Yes but you have to combine both shaders to a single one, so some HLSL knowledge is required.
POTATO-MAN saves the day! - Random
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: Kartoffel]
#414806
01/08/13 02:50
01/08/13 02:50
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
Update: @Kartoffel: I'll compile a list with all possible hooks. I'll also implement a way to change the input and outputs of the vertexshader and pixelshader as i think you'll need the viewDir which currently isn't generated anywhere About the depth: It's rendered in the object shader, as well as the normals, emissive...well everthing which will be put in the gBuffer. There is no second view used to generate the gBuffer. @rojart: Is it possible to use more then one diffuse textures, both with alpha channel? You can use "unlimited" diffuse textures if you also add the other maps as well which are needed for the shader. If you have a model/material which has only needs diffuse maps you are good to go. If you have a model/material which has diffuse and normalmaps, you have to make sure they are applied the right way: For every diffuse map, there has to be a normalmap. The skines of a model with normalmapping and 2 or more diffusemaps would look like this: diffusemap1 normalmap1 diffusemap2 normalmap2 ... More info here: http://manual.conitec.net/med_manage_skins.htmLike your car model example, but you use only one diff texture vloga_car_CS.tga and have omitted the second diff texture vloga_szyby_DA.tga to the glass effect? The way the maps are applied is wrong (see above), as i didn't attach an additional normalmap for the windoe diffuse map. I didn't care for the windows when i created the example I'll fix that in a future version. Level maps dosen't works with normalmaps for now, they is a shader levelDefaultNM.fx implemented but without any effect? They do work. Have a look at common.h "mtl_levelDefaultNM". The levelmaps in the examples have this shader applied. It's just that the normalmaps aren't that strong in the example and therefor the effect might not be visible at first glance. BTW, very nice effects in 05.c example, it is possible to combine two effects or more at once, eg. mtlDissolve with mtlLivingBloom? Sure. In that SPECIFIC case you can just copy and paste from one to the other and it'll almost instantly work (you have to change vecSkill1 to vecSkill5). New living bloom OBJECT SHADER
//------------------------------------------------------------------------------
//----- USER INPUT -------------------------------------------------------------
//------------------------------------------------------------------------------
//assign skins
#define SKIN_ALBEDO (skin1.xyz) //diffusemap
#define SKIN_NORMAL (skin2.xyz) //normalmap
#define SKIN_GLOSS (skin2.w) //glossmap
//...
#define NORMALMAPPING //do normalmapping?
#define GLOSSMAP //entity has glossmap?
#define GLOSSSTRENGTH 0 //glossmap channel will be set to this value if GLOSSMAP is not defined
//------------------------------------------------------------------------------
// ! END OF USER INPUT !
//------------------------------------------------------------------------------
#include <scHeaderObject>
#define CUSTOM_VS_POSITION
#ifndef MATWORLD
#define MATWORLD
float4x4 matWorld;
#endif
#ifndef MATWORLDVIEWPROJ
#define MATWORLDVIEWPROJ
float4x4 matWorldViewProj;
#endif
#ifndef VECTIME
#define VECTIME
float4 vecTime;
#endif
#ifndef VECSKILL1
#define VECSKILL1
float4 vecSkill1;
#endif
float4 Custom_VS_Position(vsIn In)
{
float3 P = mul(In.Pos, matWorld);
float force_x = vecSkill1.x;
float force_y = vecSkill1.y;
float speed = sin((vecTime.w+0.2*(P.x+P.y+P.z)) * vecSkill1.z);
if (In.Pos.y > 0 ) // move only upper part of tree
{
In.Pos.x += speed * force_x * In.Pos.y;
In.Pos.z += speed * force_y * In.Pos.y;
In.Pos.y -= 0.1*abs(speed*(force_x+force_y)) * In.Pos.y;
}
return mul(In.Pos,matWorldViewProj);
}
#define CUSTOM_PS_EMISSIVEMASK
float Custom_PS_EmissiveMask(vsOut In, float emissive)
{
return vecSkill1.w;
}
#define CUSTOM_PS_EXTEND
#ifndef VECSKILL5
#define VECSKILL5
float4 vecSkill5;
#endif
psOut Custom_PS_Extend(vsOut InPs, psOut OutPs)
{
//fetch output color and calculate clip value from it
half clipValue = (dot(OutPs.AlbedoAndEmissiveMask.xyz,1)*vecSkill5.x)-1;
//apply clipping
clip(clipValue);
//output clipvalue to emissive buffer for some nice glow on edges where clipping will occur in the near future
OutPs.AlbedoAndEmissiveMask.w = (1-saturate(clipValue))*0.5;
//set emissive color
OutPs.AlbedoAndEmissiveMask.xyz = lerp(OutPs.AlbedoAndEmissiveMask.xyz, vecSkill5.yzw, pow(1-saturate(clipValue),2));
return OutPs;
}
#include <scObject>
New living bloom SHADOW SHADER:
#include <scHeaderLightShadowmap>
#define CUSTOM_PS_EXTEND
#ifndef VECSKILL1
#define VECSKILL1
float4 vecSkill1;
#endif
#ifndef ENTSKIN1
#define ENTSKIN1
texture entSkin1;
#endif
sampler colorSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = WRAP;
AddressV = WRAP;
};
psOut Custom_PS_Extend(vsOut InPs, psOut OutPs)
{
half clipValue = (dot(tex2D(colorSampler, InPs.Tex).rgb,1)*vecSkill1.x)-1;
clip(clipValue);
return OutPs;
}
#include <scLightShadowmap>
CHANGED 05.c
/***************************************************************************
Basic Example on how to use write and use custom materials/shaders
***************************************************************************/
#include <litec.h>
#include <acknex.h>
#include <default.c>
//#define DEBUG_PSSM
//include Shade-C
#define PRAGMA_PATH "shadec"
#include "shade-c.h"
#include "common.h"
void setupMaterial()
{
//convert skills to floats so they can be used in the shader
mtl.skill1 = floatv(mtl.skill1);
mtl.skill2 = floatv(mtl.skill2);
mtl.skill3 = floatv(mtl.skill3);
mtl.skill4 = floatv(mtl.skill4);
//after setting everything up, switch to Shade-C's material event.
// !! THIS IS IMPORTANT !!
mtl.flags = ENABLE_RENDER;
mtl.event = sc_materials_event;
}
MATERIAL* mtlTexMove =
{
//this effect adds texture movement
effect = "05_animatedTexture.fx";
flags = ENABLE_RENDER;
event = setupMaterial;
skill1 = 0.1; //texture movement speed in x direction
skill2 = 0.8; //texture movement speed in y direction
power = 25;
}
MATERIAL* mtlLivingBloom =
{
//this effects moves the vertexes of the model around
//it also adds the whole model to the emissive buffer, which will make the object glow
effect = "05_livingBloom.fx";
flags = ENABLE_RENDER;
event = setupMaterial;
skill1 = 0.25; // x vertex movement strength
skill2 = 0.25; // y vertex movement strength
skill3 = 0.1; // movement speed
skill4 = 0.1; // glow strength
skill5 = 10; //dissolve value, the lower this gets, the more of the object will be dissolved
skill6 = 1; //emissive color red
skill7 = 0.5; //emissive color green
skill8 = 0.25; //emissive color blue
power = 25;
}
MATERIAL* mtlLivingBloomShadow =
{
//this effect does the same as the effect above, but this time its for the shadowmap shader
effect = "05_livingBloomShadow.fx";
}
MATERIAL* mtlDissolve =
{
//this effect dissolves/desintegrates the object
//it also adds emissive color to parts where desintegration will occur next
effect = "05_dissolve.fx";
flags = ENABLE_RENDER;
event = setupMaterial;
skill1 = 10; //dissolve value, the lower this gets, the more of the object will be dissolved
skill2 = 1; //emissive color red
skill3 = 0.5; //emissive color green
skill4 = 0.25; //emissive color blue
power = 25;
}
MATERIAL* mtlDissolveShadow =
{
//this effect does the same as the effect above, but this time its for the shadowmap shader
effect = "05_dissolveShadow.fx";
}
ENTITY* skycube =
{
type = "plain_abraham+6.tga";
flags2 = SKY | CUBE | SHOW;
red = 130;
green = 130;
blue = 130;
}
//simple camera script...
void v_camera()
{
set(my,INVISIBLE);
set(my,PASSABLE);
while(1)
{
c_move(my,vector(key_force.y*25*time_step,-key_force.x*25*time_step,0),nullvector,IGNORE_PASSABLE);
my.pan -= mickey.x;
my.tilt -= mickey.y;
vec_set(camera.x,my.x);
vec_set(camera.pan,my.pan);
wait(1);
}
}
void main()
{
shadow_stencil = -1; //turn off all engine intern shadow calculations. THIS IS IMPORTANT!
level_load("05.wmb");
wait(3); //wait for level load
//set suncolor to zero (setting sun_color in WED to zero does NOTHING! This is a bug in gamestudio)
//if suncolor == 0, sun will not be rendered. Set this for pure indoor scenes to boost performance!
vec_set(sun_color, vector(0,0,0));
//sun_angle.pan = 45;
//vec_set(sun_color, vector(255,240,230));
//set ambient color to zero as we want a dark level with nice shadows ;)
vec_set(ambient_color, vector(0,0,0));
//vec_set(ambient_color, vector(96,96,96));
//create a camera object so we can move around the scene
you = ent_create(NULL, vector(-800,0, 200), v_camera);
you.tilt = -10;
camera.clip_far = 5000; //set this as low as possible to increase performance AND visuals!
//set resolution before calling sc_setup
//if you want to change resolution again, simple call sc_setup() again after you changed the resolution
//video_set(1280, 720, 0, 2);
video_set(800, 600, 0, 2);
//setup skies
sc_sky(skycube);
//set camera as main view of sc_screen_default
sc_screen_default = sc_screen_create(camera);
//enable/disable Shade-C effects. You have to set these before calling sc_setup()
//If you want to change these during runtime, simply call sc_setup() again after you enabled/disabled an effect
// -> more info in sc_core.h, in struct SC_SETTINGS
sc_screen_default.settings.hdr.enabled = 1; //enable Bloom/HDR
//initialize shade-c, use default screen object
sc_setup(sc_screen_default);
//tweak effect parameters anytime you want
// -> more info in sc_core.h, in struct SC_SETTINGS
sc_screen_default.settings.hdr.brightpass = 0.85;
sc_screen_default.settings.hdr.intensity = 2;
sc_screen_default.settings.hdr.lensflare.brightpass = 0.0;
sc_screen_default.settings.hdr.lensflare.intensity = 0.25;
//Add objects and apply custom materials
//Texture Movement
you = ent_create("vloga.mdl", vector(-200,0,60), NULL);
vec_scale(you.scale_x, 0.5);
you.material = mtlTexMove;
set(you, SHADOW);
//Living Bloom Thingy
you = ent_create("vloga.mdl", vector(200,-300,60), NULL);
ENTITY* livingBloomObject= you;
vec_scale(you.scale_x, 0.5);
you.material = mtlLivingBloom;
set(you, SHADOW);
//we have to set a custom shadowmap shader for this object, as the object's vertices are changed by the living bloom shader
sc_skill(you, SC_OBJECT_MATERIAL_SHADOWMAP, mtlLivingBloomShadow);
livingBloomObject.skill5 = 4;
//Dissolve
ENTITY* dissolveObject = ent_create("vloga.mdl", vector(0,200,60), NULL);
vec_scale(dissolveObject.scale_x, 0.5);
dissolveObject.material = mtlDissolve;
set(dissolveObject, SHADOW);
//we have to set a custom shadowmap shader for this object, as the object's alpha is changed by the dissolve shader
sc_skill(dissolveObject, SC_OBJECT_MATERIAL_SHADOWMAP, mtlDissolveShadow);
dissolveObject.skill1 = 4; //this one will be counted to zero in a loop. The resulting value will then be passed to the dissolve shader
while(1)
{
//animate dissolve effect
dissolveObject.skill1 -= time_step*0.05;
if(dissolveObject.skill1 <= 0) dissolveObject.skill1 = 7;
dissolveObject.material.skill1 = floatv(dissolveObject.skill1);
livingBloomObject.skill5 -= time_step*0.05;
if(livingBloomObject.skill5 <= 0) livingBloomObject.skill5 = 7;
livingBloomObject.material.skill5 = floatv(livingBloomObject.skill5);
wait(1);
}
}
Thanks for your feedback
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: BoH_Havoc]
#414835
01/08/13 19:53
01/08/13 19:53
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
@Kartoffel: I'll compile a list with all possible hooks. I'll also implement a way to change the input and outputs of the vertexshader and pixelshader as i think you'll need the viewDir which currently isn't generated anywhere laugh About the depth: It's rendered in the object shader, as well as the normals, emissive...well everthing which will be put in the gBuffer. There is no second view used to generate the gBuffer.
Good to know. Yes, for relief-mapping I need ViewDir and the 3x3 Tangent mat (should be already avaiable because normalmapping needs this). I think I'll use the alpha channel of the diffuse texture as heightmap since alpha doesn't work with deferred lighting. oh and, anything new about the implementation of my hdr-mod?
POTATO-MAN saves the day! - Random
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: Kartoffel]
#414869
01/09/13 15:58
01/09/13 15:58
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
Added some (very spartanic) info in how to create your own custom shaders as well as how to extend them with your own code. https://github.com/BoHHavoc/ShadeC-EVO/wiki@Kartoffel: I started implementing your code some days ago [edit] New Update Added ability to set ubershader compile target
Last edited by BoH_Havoc; 01/09/13 16:31.
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: BoH_Havoc]
#414878
01/09/13 17:29
01/09/13 17:29
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Thank you very much for the very spartanic information ...but I've got some problems there are defines like '#define CUSTOM_PS_DIFFUSE' to replace the default functions but the reliefmapping changes color, alpha, normalmap and depth - all based on a ray intersection. Do I really have to use one custom function for every single of these? The problem is that they all need the depth information and doing the intersection for color, alpha, normalmap and depth is just too inefficient another thing is that this:
#define CUSTOM_VS_OUTPUT_EXTEND float3 ViewDir : TEXCOORD5; // View Direction, needed for relief mapping
[...]
float4 Custom_PS_Diffuse(vsOut In, half3 skinAlbedo)
{
float4 Color = 0;
In.ViewDir = normalize(In.ViewDir);
...results in an 'invalid subscript "ViewDir"' - Error @Kartoffel: I started implementing your code some days ago nice btw. I made slight changes at the tonemapping and added a bleach-bypass effect to it. It still needs some optimization but if you think it's worth implementing this modification I'll send it to you when I'm finished
POTATO-MAN saves the day! - Random
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: BoH_Havoc]
#414916
01/10/13 11:49
01/10/13 11:49
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
Thanks for explanation, I'll check it later. ... Level maps dosen't works with normalmaps for now, they is a shader levelDefaultNM.fx implemented but without any effect?
They do work. Have a look at common.h "mtl_levelDefaultNM". The levelmaps in the examples have this shader applied. It's just that the normalmaps aren't that strong in the example and therefor the effect might not be visible at first glance. ... One thing makes me problems. Please check this file. I noticed that the Level normalmaps only works if I added the default WED light? Without default light: With default light: Thanks again for updates and wiki! PS. Manual as chm would be very useful, too.
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: Kartoffel]
#414929
01/10/13 14:52
01/10/13 14:52
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
Small Update: Added CUSTOM_PS_TEX hook up ...but I've got some problems there are defines like '#define CUSTOM_PS_DIFFUSE' to replace the default functions but the reliefmapping changes color, alpha, normalmap and depth - all based on a ray intersection.
Do I really have to use one custom function for every single of these?
The problem is that they all need the depth information and doing the intersection for color, alpha, normalmap and depth is just too inefficient
I made a small update which lets you customize the In.Tex.xy in the PixelShader. That way you just have to worry about moving the texcoords around in your custom Parallax Shader and everything else will be done by the ubershader. Use CUSTOM_PS_TEX , float4 Custom_PS_Tex(vsOut In) to access. XY fetches the model's skins, ZW fetches the static shadowmap applied to the model (if there is one) (not implemented yet, will be in a future update). another thing is that this: Code: #define CUSTOM_VS_OUTPUT_EXTEND float3 ViewDir : TEXCOORD5; // View Direction, needed for relief mapping
[...]
float4 Custom_PS_Diffuse(vsOut In, half3 skinAlbedo) { float4 Color = 0; In.ViewDir = normalize(In.ViewDir);
...results in an 'invalid subscript "ViewDir"' - Error
Works for me, make sure you are putting the #define CUSTOM_VS_OUTPUT in the correct place
#define CUSTOM_VS_OUTPUT_EXTEND float3 ViewDir : TEXCOORD7;
#include <scHeaderObject>
<your code here>
#include <scObject>
Also please don't use TEXCOORD5 if TEXCOORD7 and TEXCOORD6 are still empty. I MIGHT change the ubershader in the future and MIGHT make use of TEXCOORD5 then. By using TEXCOORD7 or TEXCOORD6 the chance is higher that your shader will still work with future updates without giving an error about TEXCOORD5 already in use . If you are using TEXCOORD7 and TEXCOORD6 already then yes: You have to use TEXCOORD5 for additional data. One thing makes me problems. Please check this file. I noticed that the Level normalmaps only works if I added the default WED light?
Without default light:
With default light:
Interesting... i'll have a look at it.
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: BoH_Havoc]
#414930
01/10/13 15:00
01/10/13 15:00
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Again, thanks a lot for all the info (and the custom tex-coord hookup) I'll try to get it working now The last thing I don't know how to do is how to correct the depth so that SSAO, shadows and lighting are calculated correctly on the surface. A little workaround should do this but that's not very important right now. EDIT: sorry, but I've got another question : what are the texture-samplers' names? ...ok I've got it. Just had to look into default.fx
Last edited by Kartoffel; 01/10/13 22:57.
POTATO-MAN saves the day! - Random
|
|
|
|