3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: oliver2s]
#420872
04/05/13 11:08
04/05/13 11:08
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
Is there a way to support real HDRR (floating-point textures as render targets)? I'm asking 'cause I'm currently working (actually it's finished now) on a high quality bloom with HDRR support. I will implement a switch for this to either create 32bpp, 64bpp or 128bpp rendertargets. Please note though, that i will always try to keep the default value at 32bpp in order to support older hardware. Is there a way to get shadows for point lights (moving one as well)? Using: Pointlights can't cast shadows at the moment. While it is trivial to add shadow support for pointlights and it is also rather easy to make it look good, it is absolutely NOT trivial to make it performant. I have an idea how to implement shadows for pointlights in a fast way, but it hasn't been a high priority at the moment. But is it possible to have more than one Projection texture? Oh...and i miss the Luminancemask from 0.91c. Only one projection texture per light. Luminancemask also made it into Shade-C EVO. Use:
#define SKIN_EMISSIVEMASK (skin3.x)
#define EMISSIVEMASK
in the shader to activate it (skin3.x defines where the emissivemask is located. You can change that to your liking) and also add either to set emissivecolor by material.emissive_red , material.emissive_red and material.emissive_red or to set emissivecolor by sc_skill(entity, SC_OBJECT_EMISSIVE, vector(red, green, blue));. any news on terrain and water implementation? While writing my masterthesis i also did some research on terrain shaders and how to keep them fast. There will be a terrainshader in the near future. About water: I have thought about some ways, but am not completly sure on how to implement it yet. Again, this is a matter of performance instead of "just" making it look good. Why does the framerate drops down with using Shade-C, even if there's an empty level (and deactivated effetcs like HDR, PSSM, SSAO, etc..)? Shade-C uses deferred rendering. The initial setup "costs" more than in a traditional forward rendering setup. Even if there is nothing on the screen and no pp effects are activated, a lot is going on behind the scenes. The scene is renderet into 4 render targets by using MRTs, these MRTs are then processed, lighting is added and finally everything is added together. It doesn't matter if there are objects on the screen or not, these steps always need to be done. After these initial costs, deferred rendering is often faster than traditional forward rendering. It depends on the type of game you are creating though. If you only have one directional light in your level and no other lights, forward rendering will most likely be faster. If you add in shadows for the directional light, deferred rendering might or might not be faster (hybrid methods also exist were only shadows are deferred). If you have lots of lights and shadows in your game, deferred rendering is the way to go. Roughly speaking, deferred rendering speed depends on the screen resolution while forward rendering speed depends on the number of objects/lights drawn. Forward, deferred and hybrid rendering all have their pros and cons. News: - No news for Shade-C. - Finished my paper "Power to the players: Developing a large scale MMORPG on a tight budget". - Currently working on creating a company together with 3 other guys and finishing my course of studies as well as prototyping various (mobile) games as launch titles for the company. - in general: much do to at the moment.
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: BoH_Havoc]
#420876
04/05/13 12:20
04/05/13 12:20
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Pointlights can't cast shadows at the moment. While it is trivial to add shadow support for pointlights and it is also rather easy to make it look good, it is absolutely NOT trivial to make it performant. I have an idea how to implement shadows for pointlights in a fast way, but it hasn't been a high priority at the moment. hmm... what I'd try: A single view without frustum culling and a shader which renders the scene 6 times (for each side) using the vertex shader to transform the scene to the right orientation. Edit: or dual paraboloid shadow mapping, but I don't know how to get it working properly.
Last edited by Kartoffel; 04/05/13 12:31.
POTATO-MAN saves the day! - Random
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: alibaba]
#421137
04/11/13 17:03
04/11/13 17:03
|
Joined: Apr 2005
Posts: 796 U.S.A. Michigan
exile
User
|
User
Joined: Apr 2005
Posts: 796
U.S.A. Michigan
|
I have a relatively complicated shader I want to include in my project and share for Shade-C. Would anyone be able to help me get this to work? I am not shader knowledgeable so this is kind of difficult for me. I'm not asking for someone to completely get the coding done FOR me, just looking to see if someone can point me in the right direction. //==========================================// #define COLORMAP_TEXTURE entSkin1 //#define NORMALMAP_TEXTURE entSkin2 //#define INTENSMASK_TEXTURE entSkin3
#define LIGHTGRADIANT_TEXTURE mtlSkin1 //==========================================//
//#define USE_TS_NORMALMAPPING //#define USE_OS_NORMALMAPPING //#define USE_SECOND_UVSET_FOR_NORMALMAPPING
//===================//
//#define USE_COLOR_INTENSITY_SHIFT //#define USE_COLOR_INTENSITY_MASK
const float max_colorintensity=4;
const float max_sunintensity=1.1; const float min_sunintensity=0.1;
//===================//
#define USE_OUTLINES #define USE_PIXELSIZED_OUTLINES #define USE_COLORED_OUTLINES
const float outline_thickness=1; const float3 outline_color=float3(0.5,0.6,0.8);//RGB in range 0..1 (instead of 0..255)
//===================// requires USE_COLORED_OUTLINES:
//#define USE_LIGHTING_ON_OUTLINES #define USE_TEXTURED_OUTLINES //#define USE_ALPHA_FOR_OUTLINES
const float texoutline_brightness=0.55;//0..darker..1..brighter.. const float texoutline_intensity=1;//0..less..1..more.. //==========================================//
bool AUTORELOAD;
float4x4 matWorldViewProj; float4x4 matWorld; float4x4 matWorldView; float4x4 matView;
float4 vecSunDir; float4 vecSunColor; float4 vecViewPort;
texture entSkin1; texture entSkin2; texture entSkin3; texture entSkin4;
texture mtlSkin1; texture mtlSkin2; texture mtlSkin3; texture mtlSkin4;
sampler COLOR_SAMPLER = sampler_state { Texture = <COLORMAP_TEXTURE>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = clamp; AddressV = clamp; }; sampler LGRAD_SAMPLER = sampler_state { Texture = <LIGHTGRADIANT_TEXTURE>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = clamp; AddressV = clamp; };
#if defined(USE_TS_NORMALMAPPING) || defined(USE_OS_NORMALMAPPING) sampler BUMP_SAMPLER = sampler_state { Texture = <NORMALMAP_TEXTURE>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = clamp; AddressV = clamp; }; #endif
#ifdef USE_COLOR_INTENSITY_SHIFT #ifdef USE_COLOR_INTENSITY_MASK sampler MASK_SAMPLER = sampler_state { Texture = <INTENSMASK_TEXTURE>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = clamp; AddressV = clamp; }; #endif #endif
//////////////////////////////////////////// #ifndef USE_COLORED_OUTLINES #undef USE_LIGHTING_ON_OUTLINES #undef USE_TEXTURED_OUTLINES #undef USE_ALPHA_FOR_OUTLINES #endif
#ifdef USE_ALPHA_FOR_OUTLINES #define USE_TEXTURED_OUTLINES #endif
#ifdef USE_TS_NORMALMAPPING #undef USE_OS_NORMALMAPPING #else #ifdef USE_OS_NORMALMAPPING #undef USE_TS_NORMALMAPPING #endif #endif
#if defined(USE_TS_NORMALMAPPING) || defined(USE_OS_NORMALMAPPING) #define USE_NORMALMAPPING #else #undef USE_SECOND_UVSET_FOR_NORMALMAPPING #endif //////////////////////////////////////////// void VS( in float4 vPos : POSITION, in float3 normal : NORMAL, in float2 InTex : TEXCOORD0,
#ifdef USE_SECOND_UVSET_FOR_NORMALMAPPING in float2 InTex2 : TEXCOORD1, #endif
#ifdef USE_TS_NORMALMAPPING in float4 InTangent : TEXCOORD2, #endif
out float2 OutTex : TEXCOORD0,
#ifdef USE_SECOND_UVSET_FOR_NORMALMAPPING out float2 OutTex2 : TEXCOORD2, #endif
#ifndef USE_NORMALMAPPING out float3 outnormal : TEXCOORD1, #else #ifdef USE_TS_NORMALMAPPING out float3 SunDir : TEXCOORD1, #endif #endif
out float4 Pos : POSITION ) {
#ifndef USE_NORMALMAPPING outnormal=mul(normal,matWorld); #else #ifdef USE_TS_NORMALMAPPING float3x3 matTangent;
matTangent[0] = mul(InTangent.xyz,matWorld); matTangent[1] = mul(cross(InTangent.xyz,normal),matWorld)*InTangent.w; matTangent[2] = mul(normal,matWorld);
SunDir = normalize(mul( matTangent,vecSunDir.xyz)); #endif #endif
Pos = mul(vPos,matWorldViewProj);
OutTex = InTex;
#ifdef USE_SECOND_UVSET_FOR_NORMALMAPPING OutTex2 = InTex2; #endif }
void PS( in float2 Tex : TEXCOORD0,
#ifdef USE_SECOND_UVSET_FOR_NORMALMAPPING in float2 Tex2 : TEXCOORD2, #endif
#ifndef USE_NORMALMAPPING in float3 normal : TEXCOORD1, #else #ifdef USE_TS_NORMALMAPPING in float3 SunDir : TEXCOORD1, #endif #endif
out float4 COL :COLOR0 ) {
#ifndef USE_NORMALMAPPING normal = normalize(normal); #else #ifdef USE_TS_NORMALMAPPING vecSunDir.xyz = normalize(SunDir); #ifndef USE_SECOND_UVSET_FOR_NORMALMAPPING float3 normal = normalize(tex2D(BUMP_SAMPLER,Tex).xyz*2.f-1.f); #else float3 normal = normalize(tex2D(BUMP_SAMPLER,Tex2).xyz*2.f-1.f); #endif #else matWorld[3]=float4(0,0,0,1); #ifndef USE_SECOND_UVSET_FOR_NORMALMAPPING float3 normal=normalize(mul(float4(tex2D(BUMP_SAMPLER,Tex).xyz*2.f-1.f,0),matWorld)).xzy; #else float3 normal=normalize(mul(float4(tex2D(BUMP_SAMPLER,Tex2).xyz*2.f-1.f,0),matWorld)).xzy; #endif normal.z*=-1.f; #endif #endif
COL = tex2D(COLOR_SAMPLER,Tex);
float sun_blub=dot(vecSunDir,normal)*0.5f+0.5f;
float sun_diff=tex1D(LGRAD_SAMPLER,sun_blub); sun_diff=lerp(min_sunintensity,max_sunintensity,sun_diff);
#ifdef USE_COLOR_INTENSITY_SHIFT
#ifdef USE_COLOR_INTENSITY_MASK COL.rgb=lerp(COL.rgb,pow(COL.rgb,lerp(max_colorintensity,1,min(1,sun_diff))),tex2D(MASK_SAMPLER,Tex)); #else COL.rgb=pow(COL.rgb,lerp(max_colorintensity,1,min(1,sun_diff))); #endif
#endif
COL.rgb=COL.rgb*sun_diff;//*vecSunColor; //COL=normal.y; COL.a=1; }
#ifdef USE_OUTLINES void VS_OUTLINES( in float4 vPos : POSITION, in float3 normal : NORMAL,
#ifdef USE_TEXTURED_OUTLINES in float2 InTex : TEXCOORD0, out float2 OutTex : TEXCOORD0, #endif
#ifdef USE_LIGHTING_ON_OUTLINES out float3 outnormal : TEXCOORD1, #endif
out float4 Pos : POSITION ) { #ifdef USE_PIXELSIZED_OUTLINES float3 viewnormal=mul(normal,matWorldView);
Pos = mul(vPos,matWorldViewProj);
float2 sTex=(Pos.xy/Pos.w)*0.5f+0.5f;
sTex+=viewnormal.xy*outline_thickness*vecViewPort.zw;
Pos.xy=(sTex*Pos.w*2.f-Pos.w); #else Pos = mul(float4(vPos.xyz+normal*outline_thickness*0.2f,1),matWorldViewProj); #endif
#ifdef USE_TEXTURED_OUTLINES OutTex = InTex; #endif
#ifdef USE_LIGHTING_ON_OUTLINES outnormal=mul(normal,matWorld); #endif }
#ifdef USE_COLORED_OUTLINES
void PS_OUTLINES( #ifdef USE_TEXTURED_OUTLINES in float2 Tex : TEXCOORD0, #endif
#ifdef USE_LIGHTING_ON_OUTLINES in float3 normal : TEXCOORD1, #endif
out float4 COL :COLOR0 ) { COL.a=1;
#ifdef USE_TEXTURED_OUTLINES COL = tex2D(COLOR_SAMPLER,Tex); #else COL.rgb=outline_color; #endif
#ifdef USE_LIGHTING_ON_OUTLINES normal = normalize(normal);
float sun_blub=dot(vecSunDir,normal)*0.5f+0.5f;
float sun_diff=tex1D(LGRAD_SAMPLER,sun_blub); sun_diff=lerp(min_sunintensity,max_sunintensity,sun_diff);
#ifdef USE_COLOR_INTENSITY_SHIFT
#if defined(USE_COLOR_INTENSITY_MASK) && defined(USE_TEXTURED_OUTLINES) COL.rgb=lerp(COL.rgb,pow(COL.rgb,lerp(max_colorintensity,1,min(1,sun_diff))),tex2D(MASK_SAMPLER,Tex)); #else COL.rgb=pow(COL.rgb,lerp(max_colorintensity,1,min(1,sun_diff))); #endif
#endif
COL.rgb=COL.rgb*sun_diff;//*vecSunColor; #endif
#ifdef USE_TEXTURED_OUTLINES #ifndef USE_ALPHA_FOR_OUTLINES COL.rgb=pow(COL.rgb,texoutline_intensity)*texoutline_brightness; #endif #endif
#ifndef USE_ALPHA_FOR_OUTLINES COL.a=1; #endif } #endif #endif
technique Shading { pass P0 { zenable=true; zwriteenable=true; alphablendenable=false; alphatestenable=true;
AlphaRef=0; AlphaFunc=Greater;
VertexShader = compile vs_2_0 VS(); PixelShader = compile ps_2_0 PS(); }
#ifdef USE_OUTLINES pass Outlines { cullmode=cw; VertexShader = compile vs_2_0 VS_OUTLINES();
#ifdef USE_ALPHA_FOR_OUTLINES zenable=true; zwriteenable=true; alphablendenable=false; alphatestenable=true;
AlphaRef=0; AlphaFunc=Greater; #endif
#ifdef USE_COLORED_OUTLINES PixelShader = compile ps_2_0 PS_OUTLINES(); #endif } #endif }
I am also having an issue where at the start of a level the shadows start kind of "dissolving". any reason or fix for that?
Last edited by exile; 04/14/13 08:35.
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: exile]
#421247
04/14/13 11:02
04/14/13 11:02
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
Edit: or dual paraboloid shadow mapping, but I don't know how to get it working properly. I used them in the past, but they aren't really worth it. Actually they are worse than doing traditional cubemapping. Apart from the seam that appears between the two paraboloid maps, they are also not as good to optimize. With cubemapping you have 6 views with a "relatively" small area to render. With dual paraboloidmapping you have 2 views rendering everything. Using 6 views, you can turn off 2-3 most of the time to save bandwith and drawcalls, whereas with dual paraboloidmapping you end up leaving both views on in most cases. Hey Havoc, i´ve got a problem here. If i activate the forward rendering then everything gets a blue color. Make sure you have a skycube in your scene and set it up with sc_sky(skyentity); If you don't have a skycube, create a dummycube and set that up. The blue you see is the camera clear color. I have a relatively complicated shader I want to include in my project and share for Shade-C. Would anyone be able to help me get this to work? I am not shader knowledgeable so this is kind of difficult for me. I'm not asking for someone to completely get the coding done FOR me, just looking to see if someone can point me in the right direction. You want to extend the default Shade-C Object shader. Look here for more information on how to do that: Custom Shaders (Advanced) Custom Shaders (Beginner)It might be more easy to write down the features of your shader though and re-implement it instead of porting it. Shade-C already comes with a lot of features you can use to start building your own shader. For example normalmapping and specular lighting is already supported and you don't have to re-implement it, as well as emissive lighting,colormasks and a few other things. Also, have a look at the shadec/examples/fx folder as well as shadec/examples/05.c . There's a bunch of custom shaders in there that should get you started. I am also having an issue where at the start of a level the shadows start kind of "dissolving". any reason or fix for that? Can you post a screenshot?
Last edited by BoH_Havoc; 04/14/13 11:04.
|
|
|
|